kbarnard commited on
Commit
45c5b51
1 Parent(s): 9d422be

Add gradio app with requirements

Browse files
Files changed (2) hide show
  1. app.py +36 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import glob
2
+ import gradio as gr
3
+ from ultralytics import YOLO
4
+
5
+ model_path = "best.pt"
6
+ model = YOLO(model_path)
7
+
8
+
9
+ PREDICT_KWARGS = {
10
+ "classes": 0,
11
+ "conf": 0.25,
12
+ }
13
+
14
+
15
+ def run(image_path):
16
+ results = model.predict(image_path, **PREDICT_KWARGS)
17
+ return results[0].plot()[:, :, ::-1] # reverse channels for gradio
18
+
19
+
20
+ title = "Megalodon Detector"
21
+ description = (
22
+ ""
23
+ )
24
+
25
+ examples = glob.glob("images/*.png")
26
+
27
+ interface = gr.Interface(
28
+ run,
29
+ inputs=[gr.components.Image(type="filepath")],
30
+ outputs=gr.components.Image(type="numpy"),
31
+ title=title,
32
+ description=description,
33
+ examples=examples,
34
+ )
35
+
36
+ interface.queue().launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ultralytics==8.0.158