VaneshDev commited on
Commit
0efc414
·
verified ·
1 Parent(s): 395bedc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -103,6 +103,10 @@ def predict_xray(image):
103
  <p><b>Confidence:</b> {confidence:.2f}%</p>
104
  <p><b>Note:</b> The model is not confident enough to provide a clear diagnosis.</p>
105
  <p><b>Recommendation:</b> Please consult a radiologist or upload a better-quality image.</p>
 
 
 
 
106
  </div>
107
  """
108
 
@@ -113,6 +117,10 @@ def predict_xray(image):
113
  <p><b>Confidence:</b> {confidence:.2f}%</p>
114
  <p><b>Description:</b> {info['description']}</p>
115
  <p><b>Recommendation:</b> {info['recommendation']}</p>
 
 
 
 
116
  </div>
117
  """
118
 
@@ -139,7 +147,7 @@ def analyze_report(file):
139
  condition, disease, status = "Fracture", "Bone Injury", "Orthopedic Attention Required"
140
 
141
  preview = text[:300] + "..." if text else "No readable content."
142
- return f"Condition: {condition}\nDisease: {disease}\nStatus: {status}\n\nPreview:\n{preview}"
143
 
144
  except Exception as e:
145
  return f"Failed to process PDF: {str(e)}"
@@ -153,12 +161,14 @@ def create_interface():
153
  with gr.TabItem("X-ray Analysis"):
154
  img_input = gr.Image(label="Upload Chest X-ray", type="pil")
155
  img_output = gr.HTML()
156
- gr.Button("Analyze X-ray").click(predict_xray, inputs=img_input, outputs=img_output)
 
157
 
158
  with gr.TabItem("Report Analysis"):
159
  pdf_input = gr.File(label="Upload PDF Report", file_types=[".pdf"])
160
  pdf_output = gr.Textbox(label="Extracted Summary", lines=10)
161
- gr.Button("Analyze Report").click(analyze_report, inputs=pdf_input, outputs=pdf_output)
 
162
 
163
  return demo
164
 
 
103
  <p><b>Confidence:</b> {confidence:.2f}%</p>
104
  <p><b>Note:</b> The model is not confident enough to provide a clear diagnosis.</p>
105
  <p><b>Recommendation:</b> Please consult a radiologist or upload a better-quality image.</p>
106
+ </div>, <div style="font-family:Arial">
107
+ <h4>Summary:</h4>
108
+ <p><b>Diagnosis:</b> Uncertain</p>
109
+ <p><b>Confidence Level:</b> {confidence:.2f}%</p>
110
  </div>
111
  """
112
 
 
117
  <p><b>Confidence:</b> {confidence:.2f}%</p>
118
  <p><b>Description:</b> {info['description']}</p>
119
  <p><b>Recommendation:</b> {info['recommendation']}</p>
120
+ </div>, <div style="font-family:Arial">
121
+ <h4>Summary:</h4>
122
+ <p><b>Diagnosis:</b> {top_condition}</p>
123
+ <p><b>Confidence Level:</b> {confidence:.2f}%</p>
124
  </div>
125
  """
126
 
 
147
  condition, disease, status = "Fracture", "Bone Injury", "Orthopedic Attention Required"
148
 
149
  preview = text[:300] + "..." if text else "No readable content."
150
+ return f"Condition: {condition}\nDisease: {disease}\nStatus: {status}\n\nPreview:\n{preview}, <h4>Summary:</h4><p><b>Condition:</b> {condition}</p><p><b>Status:</b> {status}</p>"
151
 
152
  except Exception as e:
153
  return f"Failed to process PDF: {str(e)}"
 
161
  with gr.TabItem("X-ray Analysis"):
162
  img_input = gr.Image(label="Upload Chest X-ray", type="pil")
163
  img_output = gr.HTML()
164
+ summary_output = gr.HTML(label="Summary Result")
165
+ gr.Button("Analyze X-ray").click(predict_xray, inputs=img_input, outputs=[img_output, summary_output])
166
 
167
  with gr.TabItem("Report Analysis"):
168
  pdf_input = gr.File(label="Upload PDF Report", file_types=[".pdf"])
169
  pdf_output = gr.Textbox(label="Extracted Summary", lines=10)
170
+ summary_output_report = gr.Textbox(label="Summary Result", lines=5)
171
+ gr.Button("Analyze Report").click(analyze_report, inputs=pdf_input, outputs=[pdf_output, summary_output_report])
172
 
173
  return demo
174