Spaces:
Running
Running
debug
Browse files
app.py
CHANGED
@@ -2345,14 +2345,8 @@ def extract_text_from_image(image):
|
|
2345 |
config=generate_content_config,
|
2346 |
)
|
2347 |
|
2348 |
-
# 返回識別的文字
|
2349 |
return response.text
|
2350 |
|
2351 |
-
# 使用 OCR 工具
|
2352 |
-
def extract_text_from_file(file):
|
2353 |
-
"""從上傳的文件中提取文字"""
|
2354 |
-
return "test"
|
2355 |
-
|
2356 |
|
2357 |
# === INIT PARAMS ===
|
2358 |
def init_params(request: gr.Request):
|
@@ -4021,12 +4015,6 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
4021 |
with gr.Column():
|
4022 |
chinese_full_paragraph_input = gr.Textbox(label="輸入段落全文", lines=5)
|
4023 |
with gr.Row():
|
4024 |
-
with gr.Column(scale=1, visible=False):
|
4025 |
-
# 修正文件類型設置
|
4026 |
-
chinese_file_upload = gr.File(
|
4027 |
-
label="上傳文件",
|
4028 |
-
file_count="single" # 確保只能上傳一個文件
|
4029 |
-
)
|
4030 |
with gr.Column(scale=1):
|
4031 |
chinese_image_upload = gr.Image(label="上傳圖片或拍照", type="pil", sources=["upload", "webcam", "clipboard"])
|
4032 |
with gr.Column():
|
@@ -4037,13 +4025,6 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
4037 |
with gr.Row():
|
4038 |
chinese_full_paragraph_evaluate_output_table = gr.Dataframe(label="段落全文分析表格", wrap=True, column_widths=[20, 15, 65], interactive=False)
|
4039 |
|
4040 |
-
# 處理上傳文件和圖片的事件
|
4041 |
-
chinese_file_upload.change( # 使用 change 而不是 upload
|
4042 |
-
fn=extract_text_from_file,
|
4043 |
-
inputs=[chinese_file_upload],
|
4044 |
-
outputs=[chinese_full_paragraph_input]
|
4045 |
-
)
|
4046 |
-
|
4047 |
chinese_image_upload.change( # 使用 change 而不是 upload
|
4048 |
fn=extract_text_from_image,
|
4049 |
inputs=[chinese_image_upload],
|
|
|
2345 |
config=generate_content_config,
|
2346 |
)
|
2347 |
|
|
|
2348 |
return response.text
|
2349 |
|
|
|
|
|
|
|
|
|
|
|
2350 |
|
2351 |
# === INIT PARAMS ===
|
2352 |
def init_params(request: gr.Request):
|
|
|
4015 |
with gr.Column():
|
4016 |
chinese_full_paragraph_input = gr.Textbox(label="輸入段落全文", lines=5)
|
4017 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
4018 |
with gr.Column(scale=1):
|
4019 |
chinese_image_upload = gr.Image(label="上傳圖片或拍照", type="pil", sources=["upload", "webcam", "clipboard"])
|
4020 |
with gr.Column():
|
|
|
4025 |
with gr.Row():
|
4026 |
chinese_full_paragraph_evaluate_output_table = gr.Dataframe(label="段落全文分析表格", wrap=True, column_widths=[20, 15, 65], interactive=False)
|
4027 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4028 |
chinese_image_upload.change( # 使用 change 而不是 upload
|
4029 |
fn=extract_text_from_image,
|
4030 |
inputs=[chinese_image_upload],
|