ariankhalfani commited on
Commit
c5f9028
1 Parent(s): 47ea195

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -17
app.py CHANGED
@@ -40,11 +40,11 @@ def predict_image(input_image, name, patient_id):
40
 
41
  # Determine the label based on the class index
42
  if class_index == 0:
43
- label = "Mature"
44
- color = (255, 0, 0) # Red for Mature
45
- elif class_index == 1:
46
  label = "Immature"
47
  color = (0, 255, 255) # Yellow for Immature
 
 
 
48
  else:
49
  label = "Normal"
50
  color = (0, 255, 0) # Green for Normal
@@ -238,24 +238,25 @@ with app:
238
  with gr.Column():
239
  name = gr.Textbox(label="Name")
240
  patient_id = gr.Textbox(label="Patient ID")
241
- input_image = gr.Image(type="pil", label="Upload an Image", image_mode="RGB")
242
-
243
- with gr.Row():
244
- download_choice = gr.Radio(label="Download Choice", choices=["Database (.db)", "Last Predicted Image (.png)"], value="Database (.db)")
245
- download_button = gr.Button("Download")
246
 
247
  with gr.Column():
248
- predicted_image = gr.Image(label="Predicted Image")
249
- raw_result = gr.Textbox(label="Raw Prediction Results", interactive=False)
250
- submit_status = gr.Textbox(label="Submission Status", interactive=False)
 
 
 
 
251
 
252
- predict_button = gr.Button("Predict")
253
- view_db_button = gr.Button("View Database")
 
 
 
254
 
255
- # Button actions
256
- predict_button.click(interface, inputs=[name, patient_id, input_image], outputs=[predicted_image, raw_result, submit_status])
257
- view_db_button.click(view_db_interface, outputs=gr.Dataframe())
258
- download_button.click(download_interface, inputs=[download_choice], outputs=[gr.File(), gr.Textbox()])
259
 
260
  # Launch the Gradio app
261
  app.launch()
 
40
 
41
  # Determine the label based on the class index
42
  if class_index == 0:
 
 
 
43
  label = "Immature"
44
  color = (0, 255, 255) # Yellow for Immature
45
+ elif class_index == 1:
46
+ label = "Mature"
47
+ color = (255, 0, 0) # Red for Mature
48
  else:
49
  label = "Normal"
50
  color = (0, 255, 0) # Green for Normal
 
238
  with gr.Column():
239
  name = gr.Textbox(label="Name")
240
  patient_id = gr.Textbox(label="Patient ID")
241
+ input_image = gr.Image(label="Input Image", tool="editor", type="pil")
 
 
 
 
242
 
243
  with gr.Column():
244
+ output_image = gr.Image(label="Predicted Image")
245
+ raw_result = gr.Textbox(label="Raw Predictions", lines=5)
246
+ submit_status = gr.Textbox(label="Submit Status")
247
+
248
+ predict_button = gr.Button("Predict")
249
+
250
+ predict_button.click(fn=interface, inputs=[name, patient_id, input_image], outputs=[output_image, raw_result, submit_status])
251
 
252
+ with gr.Row():
253
+ with gr.Column():
254
+ view_button = gr.Button("View Database")
255
+ download_choice = gr.Dropdown(label="Download Option", choices=["Database (.db)", "Predicted Image (.png)"])
256
+ download_button = gr.Button("Download")
257
 
258
+ view_button.click(fn=view_db_interface, inputs=[], outputs=[gr.Dataframe()])
259
+ download_button.click(fn=download_interface, inputs=[download_choice], outputs=[gr.File(), gr.Textbox()])
 
 
260
 
261
  # Launch the Gradio app
262
  app.launch()