Update app.py
Browse files
app.py
CHANGED
@@ -320,27 +320,27 @@ Expected JSON format:
|
|
320 |
|
321 |
# Gradio interface function
|
322 |
def process_pdf(pdf):
|
323 |
-
text = read_pdf(pdf.
|
324 |
output = generate(text) # Generate structured JSON
|
325 |
|
326 |
return output
|
327 |
|
328 |
-
def show_to_UI(pdf):
|
329 |
-
|
330 |
-
|
331 |
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
|
343 |
-
|
344 |
|
345 |
# Define Gradio interface
|
346 |
with gr.Blocks() as demo:
|
@@ -353,6 +353,6 @@ with gr.Blocks() as demo:
|
|
353 |
metadata_output = gr.Markdown(label="Metadata")
|
354 |
lab_test_output = gr.Dataframe(label="Lab Test Results")
|
355 |
|
356 |
-
submit_btn.click(
|
357 |
|
358 |
-
demo.launch(
|
|
|
320 |
|
321 |
# Gradio interface function
|
322 |
def process_pdf(pdf):
|
323 |
+
text = read_pdf(pdf.path) # Extract text from PDF
|
324 |
output = generate(text) # Generate structured JSON
|
325 |
|
326 |
return output
|
327 |
|
328 |
+
# def show_to_UI(pdf):
|
329 |
+
# # output = process_pdf(pdf) # Call process_pdf to get JSON
|
330 |
+
# output= {"metadata": {"name": "John Doe", "age": 30}, "lab_tests": [{"test": "Blood Sugar", "value": "120 mg/dL"}]}
|
331 |
|
332 |
+
# # Extract metadata
|
333 |
+
# metadata = output["metadata"]
|
334 |
+
# labtests = pd.DataFrame(output["lab_tests"])
|
335 |
+
# # reds = pd.DataFrame(output["reds"])
|
336 |
|
337 |
+
# metadata_str = f"**Patient Name:** {metadata['patient_name']}\n\n" \
|
338 |
+
# f"**Age:** {metadata['age']}\n\n" \
|
339 |
+
# # f"**Gender:** {metadata['gender']}\n\n" \
|
340 |
+
# # f"**Lab Name:** {metadata['lab_name']}\n\n" \
|
341 |
+
# # f"**Report Date:** {metadata['report_date']}"
|
342 |
|
343 |
+
# return metadata_str, labtests
|
344 |
|
345 |
# Define Gradio interface
|
346 |
with gr.Blocks() as demo:
|
|
|
353 |
metadata_output = gr.Markdown(label="Metadata")
|
354 |
lab_test_output = gr.Dataframe(label="Lab Test Results")
|
355 |
|
356 |
+
submit_btn.click(process_pdf, inputs=[pdf_input], outputs=[output])
|
357 |
|
358 |
+
demo.launch()
|