Update app.py
Browse files使用 gr.File 和 gr.Textbox 组件来定义输入。
使用 gr.Textbox 组件来定义输出。
app.py
CHANGED
@@ -43,13 +43,19 @@ def analyze_document(file, prompt):
|
|
43 |
return tokenizer.decode(outputs[0])
|
44 |
|
45 |
# Gradio interface
|
|
|
|
|
|
|
|
|
46 |
iface = gr.Interface(
|
47 |
fn=analyze_document,
|
48 |
-
inputs=[
|
49 |
-
gr.inputs.File(label="Upload PDF or TXT Document"),
|
50 |
-
gr.inputs.Textbox(label="Enter your prompt")
|
51 |
-
],
|
52 |
-
outputs="text",
|
|
|
|
|
53 |
title="Medical Report Analyzer",
|
54 |
description="Upload a medical report (PDF or TXT) and enter a prompt to analyze the report."
|
55 |
)
|
|
|
43 |
return tokenizer.decode(outputs[0])
|
44 |
|
45 |
# Gradio interface
|
46 |
+
file_input = gr.File(label="Upload TXT or PDF Document", file_count="single")
|
47 |
+
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your structured prompt here")
|
48 |
+
output_text = gr.Textbox(label="Analysis Result")
|
49 |
+
|
50 |
iface = gr.Interface(
|
51 |
fn=analyze_document,
|
52 |
+
# inputs=[
|
53 |
+
# gr.inputs.File(label="Upload PDF or TXT Document"),
|
54 |
+
# gr.inputs.Textbox(label="Enter your prompt")
|
55 |
+
# ],
|
56 |
+
# outputs="text",
|
57 |
+
inputs=[file_input, prompt_input],
|
58 |
+
outputs=output_text,
|
59 |
title="Medical Report Analyzer",
|
60 |
description="Upload a medical report (PDF or TXT) and enter a prompt to analyze the report."
|
61 |
)
|