PedroNovaesNeto commited on
Commit
22a2034
·
verified ·
1 Parent(s): 18f76a5

Upload of app and models

Browse files
Files changed (5) hide show
  1. app.py +34 -0
  2. model/best.pt +3 -0
  3. model/bestV2.pt +3 -0
  4. model/model_merged1.pt +3 -0
  5. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ultralytics import YOLO
3
+ import cv2
4
+
5
+ MODELOS = [
6
+ "model/best.pt", "model/bestV2.pt", "model/model_merged1.pt"
7
+ ]
8
+
9
+ m = 2
10
+
11
+ def predict_image(img):
12
+ if img is None:
13
+ return None
14
+
15
+ model = YOLO(MODELOS[m])
16
+ results = model(img)
17
+
18
+ annotated_img = results[0].plot()
19
+
20
+ annotated_img_rgb = cv2.cvtColor(annotated_img, cv2.COLOR_BGR2RGB)
21
+
22
+ return annotated_img_rgb
23
+
24
+ demo = gr.Interface(
25
+ fn=predict_image,
26
+ inputs=gr.Image(sources=["webcam"], type="numpy", label="Tirar foto"),
27
+ outputs=gr.Image(type="numpy", label="Resultado do modelo"),
28
+ title="Detecção de Objetos com YOLO",
29
+ description="Clique no ícone de câmera para tirar uma foto e o modelo fará a detecção automaticamente!",
30
+ live=True
31
+ )
32
+
33
+ if __name__ == "__main__":
34
+ demo.launch()
model/best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:59a9095ad5630a083fc24082af5a963afa60af8c94c2637126f965fd33b24e6e
3
+ size 5451994
model/bestV2.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b28ea4d9afeccf42d0ae9c298d8eb1dbd979e37fcb8844689dc2d754525b4349
3
+ size 5476186
model/model_merged1.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60c77ebffcfe94e80eee4138f55ea13ec425d216b7bddec026b5cbccbbf041d1
3
+ size 5459546
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ ultralytics
2
+ gradio
3
+ numpy
4
+ opencv-python