Aleksander Bojda commited on
Commit
35bfc71
·
1 Parent(s): c1f3dcb

Initial version supporting yolov5_s and yolov5_m

Browse files
Files changed (7) hide show
  1. .gitignore +2 -0
  2. app.py +35 -0
  3. examples/ex1.jpg +0 -0
  4. examples/ex2.jpg +0 -0
  5. examples/ex3.jpg +0 -0
  6. examples/ex4.jpg +0 -0
  7. requirements.txt +1 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ flagged/
2
+ __pycache__/
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ import yolov5
4
+
5
+ models = {
6
+ "yolov5s": yolov5.load("akbojda/yolov5s-aquarium"),
7
+ "yolov5m": yolov5.load("akbojda/yolov5m-aquarium"),
8
+ }
9
+
10
+ def predict(img, model_type):
11
+ model = models[model_type]
12
+ results = model(img, size=640)
13
+ detection_img = results.render()[0]
14
+
15
+ return detection_img
16
+
17
+ # Interface
18
+ inputs = [
19
+ "image",
20
+ gr.Dropdown(["yolov5s", "yolov5m"], label="Model", value="yolov5s")
21
+ ]
22
+
23
+ outputs = [
24
+ "image"
25
+ ]
26
+
27
+ examples = [
28
+ ["examples/ex1.jpg", None],
29
+ ["examples/ex2.jpg", None],
30
+ ["examples/ex3.jpg", None],
31
+ ["examples/ex4.jpg", None],
32
+ ]
33
+
34
+ iface = gr.Interface(fn=predict, inputs=inputs, outputs=outputs, examples=examples)
35
+ iface.launch()
examples/ex1.jpg ADDED
examples/ex2.jpg ADDED
examples/ex3.jpg ADDED
examples/ex4.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ yolov5