Update app.py
Browse files
app.py
CHANGED
@@ -128,7 +128,7 @@ Structure your responses to allow for seamless concatenation, presenting all tab
|
|
128 |
|
129 |
|
130 |
def update_input():
|
131 |
-
return en_1
|
132 |
|
133 |
|
134 |
with gr.Blocks(title="Automated Enzyme Kinetics Extractor") as demo:
|
@@ -137,33 +137,51 @@ with gr.Blocks(title="Automated Enzyme Kinetics Extractor") as demo:
|
|
137 |
<p>How to use:
|
138 |
<br><strong>1</strong>: Upload your PDF.
|
139 |
<br><strong>2</strong>: Click "View PDF" to preview it.
|
140 |
-
<br><strong>3</strong>:
|
141 |
-
<br><strong>4</strong>:
|
|
|
142 |
</p>'''
|
143 |
)
|
144 |
with gr.Row():
|
145 |
with gr.Column(scale=1):
|
146 |
file_input = gr.File(label="Upload your PDF", type="filepath")
|
147 |
example = gr.Examples(examples=[["./sample.pdf"]], inputs=file_input)
|
148 |
-
|
|
|
|
|
149 |
file_out = gr.Gallery(label="PDF Viewer", columns=1, height="auto", object_fit="contain")
|
150 |
|
151 |
-
with gr.Column(scale=
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|------------|-------------------|-------------|-----|---------|------|-----------|---------|--------------|------------------|----------------|--------------------|-------------------------|
|
159 |
| Enzyme1 | Bacillus subtilis | Substrate_A | 7.3 | mM | 6.4 | s^-1 | 1.4 × 10^4 | M^-1s^-1 | 37°C | 5.0 | WT | NADP^+ |
|
160 |
| Enzyme2 | Escherichia coli | Substrate_B | 5.9 | mM | 9.8 | s^-1 | 29000 | mM^-1min^-1 | 60°C | 10.0 | Q176E | NADPH |
|
161 |
| Enzyme3 | Homo sapiens | Substrate_C | 6.9 | mM | 15.6 | s^-1 | 43000 | µM^-1s^-1 | 65°C | 8.0 | T253S | NAD^+ |
|
162 |
|
163 |
""")
|
|
|
164 |
exp.click(update_input, outputs=model_input)
|
165 |
gen.click(fn=predict, inputs=[model_input, file_input], outputs=outputs)
|
166 |
clr.click(fn=lambda: [gr.update(value=""), gr.update(value="")], inputs=None, outputs=[model_input, outputs])
|
167 |
viewer_button.click(display_pdf_images, inputs=file_input, outputs=file_out)
|
168 |
|
|
|
169 |
demo.launch()
|
|
|
|
128 |
|
129 |
|
130 |
def update_input():
|
131 |
+
return en_1
|
132 |
|
133 |
|
134 |
with gr.Blocks(title="Automated Enzyme Kinetics Extractor") as demo:
|
|
|
137 |
<p>How to use:
|
138 |
<br><strong>1</strong>: Upload your PDF.
|
139 |
<br><strong>2</strong>: Click "View PDF" to preview it.
|
140 |
+
<br><strong>3</strong>: Click "Extract Text" to extract Text.
|
141 |
+
<br><strong>4</strong>: Enter your extraction prompt in the input box.
|
142 |
+
<br><strong>5</strong>: Click "Generate" to extract, and the extracted information will display below.
|
143 |
</p>'''
|
144 |
)
|
145 |
with gr.Row():
|
146 |
with gr.Column(scale=1):
|
147 |
file_input = gr.File(label="Upload your PDF", type="filepath")
|
148 |
example = gr.Examples(examples=[["./sample.pdf"]], inputs=file_input)
|
149 |
+
with gr.Row():
|
150 |
+
viewer_button = gr.Button("View PDF", variant="secondary")
|
151 |
+
extract_button = gr.Button("Extract Text", variant="primary")
|
152 |
file_out = gr.Gallery(label="PDF Viewer", columns=1, height="auto", object_fit="contain")
|
153 |
|
154 |
+
with gr.Column(scale=1):
|
155 |
+
text_output = gr.Textbox(
|
156 |
+
label="Extracted Text",
|
157 |
+
interactive=True,
|
158 |
+
placeholder="Extracted text will appear here...",
|
159 |
+
lines=39,
|
160 |
+
max_lines=39, # 设置最大行数,如果超过将显示滚动条
|
161 |
+
autoscroll=False, # 设置自动滚动到底部
|
162 |
+
show_copy_button=True,
|
163 |
+
elem_id="text-output"
|
164 |
+
)
|
165 |
+
|
166 |
+
with gr.Column():
|
167 |
+
model_input = gr.Textbox(lines=7, value=en_1, placeholder='Enter your extraction prompt here', label='Input Prompt')
|
168 |
+
exp = gr.Button("Example Prompt")
|
169 |
+
with gr.Row():
|
170 |
+
gen = gr.Button("Generate")
|
171 |
+
clr = gr.Button("Clear")
|
172 |
+
outputs = gr.Markdown(label='Output', value="""| Enzyme | Organism | Substrate | Km | Unit_Km | Kcat | Unit_Kcat | Kcat/Km | Unit_Kcat/Km | Commentary[Temp] | Commentary[pH] | Commentary[Mutant] | Commentary[Cosubstrate] |
|
173 |
|------------|-------------------|-------------|-----|---------|------|-----------|---------|--------------|------------------|----------------|--------------------|-------------------------|
|
174 |
| Enzyme1 | Bacillus subtilis | Substrate_A | 7.3 | mM | 6.4 | s^-1 | 1.4 × 10^4 | M^-1s^-1 | 37°C | 5.0 | WT | NADP^+ |
|
175 |
| Enzyme2 | Escherichia coli | Substrate_B | 5.9 | mM | 9.8 | s^-1 | 29000 | mM^-1min^-1 | 60°C | 10.0 | Q176E | NADPH |
|
176 |
| Enzyme3 | Homo sapiens | Substrate_C | 6.9 | mM | 15.6 | s^-1 | 43000 | µM^-1s^-1 | 65°C | 8.0 | T253S | NAD^+ |
|
177 |
|
178 |
""")
|
179 |
+
extract_button.click(extract_pdf_pypdf, inputs=file_input, outputs=text_output)
|
180 |
exp.click(update_input, outputs=model_input)
|
181 |
gen.click(fn=predict, inputs=[model_input, file_input], outputs=outputs)
|
182 |
clr.click(fn=lambda: [gr.update(value=""), gr.update(value="")], inputs=None, outputs=[model_input, outputs])
|
183 |
viewer_button.click(display_pdf_images, inputs=file_input, outputs=file_out)
|
184 |
|
185 |
+
|
186 |
demo.launch()
|
187 |
+
|