Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -42,6 +42,21 @@ print("Loading the transformer model...")
|
|
42 |
# Initialize the transformer vectorizer
|
43 |
transformer_vectorizer = TransformerVectorizer()
|
44 |
vectorizer = TfidfVectorizer()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
def process_input(input_type, user_input, uploaded_file):
|
46 |
if input_type == "File Upload" and uploaded_file is not None:
|
47 |
file_ext = os.path.splitext(uploaded_file.name)[1].lower()
|
@@ -80,7 +95,7 @@ def process_input(input_type, user_input, uploaded_file):
|
|
80 |
return user_input
|
81 |
else:
|
82 |
return "无效的输入类型或未上传文件。"
|
83 |
-
|
84 |
|
85 |
def toggle_visibility(input_type):
|
86 |
user_input_visible = input_type == "Text Input"
|
|
|
42 |
# Initialize the transformer vectorizer
|
43 |
transformer_vectorizer = TransformerVectorizer()
|
44 |
vectorizer = TfidfVectorizer()
|
45 |
+
def process_input(input_type, user_input, uploaded_file):
|
46 |
+
print('ooooocr')
|
47 |
+
if input_type == "File Upload" and uploaded_file is not None:
|
48 |
+
# 读取上传的文件
|
49 |
+
with open(uploaded_file.name, "rb") as f:
|
50 |
+
image = f.read()
|
51 |
+
results = reader.readtext(image)
|
52 |
+
# 提取识别的文本
|
53 |
+
extracted_text = ' '.join([text[1] for text in results])
|
54 |
+
print("提取的文本:")
|
55 |
+
print(extracted_text)
|
56 |
+
return extracted_text
|
57 |
+
elif input_type == "Text Input":
|
58 |
+
return user_input
|
59 |
+
'''
|
60 |
def process_input(input_type, user_input, uploaded_file):
|
61 |
if input_type == "File Upload" and uploaded_file is not None:
|
62 |
file_ext = os.path.splitext(uploaded_file.name)[1].lower()
|
|
|
95 |
return user_input
|
96 |
else:
|
97 |
return "无效的输入类型或未上传文件。"
|
98 |
+
'''
|
99 |
|
100 |
def toggle_visibility(input_type):
|
101 |
user_input_visible = input_type == "Text Input"
|