sayedM commited on
Commit
35eddcc
·
1 Parent(s): 753a485

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -21
app.py CHANGED
@@ -46,30 +46,64 @@ def yolov8_inference(
46
 
47
  return annotated_image
48
 
49
- image_input = gr.inputs.Image() # Adjust the shape according to your requirements
50
-
51
- inputs = [
52
- gr.inputs.Image(label="Input Image"),
53
- gr.Slider(
54
- minimum=0.0, maximum=1.0, value=0.25, step=0.05, label="Confidence Threshold"
55
- ),
56
- gr.Slider(minimum=0.0, maximum=1.0, value=0.45, step=0.05, label="IOU Threshold"),
57
- ]
58
-
59
- outputs = gr.Image(type="filepath", label="Output Image")
60
- title = "Brain Tumor Demo"
61
  import os
62
  examples = [
63
  ["tu1.jpg", 0.6, 0.45],
64
  ["tu2.jpg", 0.25, 0.45],
65
  ["tu3.jpg", 0.25, 0.45],
66
  ]
67
- demo_app = gr.Interface(examples=examples,
68
- fn=yolov8_inference,
69
- inputs=inputs,
70
- outputs=outputs,
71
- title=title,
72
- cache_examples=True,
73
- theme="default",
74
- )
75
- demo_app.launch(debug=False, enable_queue=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  return annotated_image
48
 
49
+ # image_input = gr.inputs.Image() # Adjust the shape according to your requirements
50
+
51
+ # inputs = [
52
+ # gr.inputs.Image(label="Input Image"),
53
+ # gr.Slider(
54
+ # minimum=0.0, maximum=1.0, value=0.25, step=0.05, label="Confidence Threshold"
55
+ # ),
56
+ # gr.Slider(minimum=0.0, maximum=1.0, value=0.45, step=0.05, label="IOU Threshold"),
57
+ # ]
58
+
59
+ # outputs = gr.Image(type="filepath", label="Output Image")
60
+ # title = "Brain Tumor Demo"
61
  import os
62
  examples = [
63
  ["tu1.jpg", 0.6, 0.45],
64
  ["tu2.jpg", 0.25, 0.45],
65
  ["tu3.jpg", 0.25, 0.45],
66
  ]
67
+ # demo_app = gr.Interface(examples=examples,
68
+ # fn=yolov8_inference,
69
+ # inputs=inputs,
70
+ # outputs=outputs,
71
+ # title=title,
72
+ # cache_examples=True,
73
+ # theme="default",
74
+ # )
75
+ # demo_app.launch(debug=False, enable_queue=True)
76
+ gr.Examples(examples) # Add the examples to the app
77
+ with gr.Blocks() as demo:
78
+ gr.Markdown(
79
+ """
80
+ # Tuba Brain Tumor Demo
81
+
82
+ [Tuba](https://Tuba.ai)
83
+ """
84
+ )
85
+ # Define the input components and add them to the layout
86
+ with gr.Row():
87
+ image_input = gr.inputs.Image()
88
+
89
+
90
+ outputs = gr.Image(type="filepath", label="Output Image")
91
+
92
+ # Define the output component and add it to the layout
93
+ with gr.Row():
94
+ conf_slider=gr.Slider(minimum=0.0, maximum=1.0, value=0.25, step=0.05, label="Confidence Threshold" )
95
+ with gr.Row():
96
+ IOU_Slider=gr.Slider(minimum=0.0, maximum=1.0, value=0.45, step=0.05, label="IOU Threshold")
97
+
98
+ gr.Examples(examples) # Add the examples to
99
+
100
+ with gr.Row():
101
+ button = gr.Button("Run")
102
+
103
+ # Define the event listener that connects the input and output components and triggers the function
104
+ button.click(fn=get_results, inputs=[image_input, conf_slider,IOU_Slider], outputs=output, api_name="yolov8_inference")
105
+ # Add the description below the layout
106
+ gr.Markdown(description_html)
107
+ # Launch the app
108
+ demo.launch(share=False)
109
+