RandomCatLover commited on
Commit
30ac55c
·
1 Parent(s): 5672bf3
Files changed (9) hide show
  1. .gitignore +1 -0
  2. app.py +34 -0
  3. imgs/1.jpg +0 -0
  4. imgs/2.jpg +0 -0
  5. imgs/3.jpg +0 -0
  6. imgs/4.jpg +0 -0
  7. imgs/5.jpg +0 -0
  8. imgs/6.jpg +0 -0
  9. requirements.txt +4 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ *.pt
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #%%
2
+ import gradio as gr
3
+ from ultralytics import YOLO
4
+ import cv2
5
+ from huggingface_hub import hf_hub_download
6
+
7
+ REPO_ID = "RandomCatLover/bird_detector"
8
+ FILENAME = "best.pt"
9
+
10
+ hf_hub_download(repo_id=REPO_ID, filename=FILENAME, local_dir=".")
11
+ #%%
12
+ yolo = YOLO("best.pt")
13
+
14
+ def predict(img):
15
+ results = yolo(img)
16
+ for result in results:
17
+ try:
18
+ bbox = result.boxes.xyxy[0]
19
+ except:
20
+ continue
21
+ bbox = [int(i) for i in bbox]
22
+ img = cv2.rectangle(img, (bbox[0], bbox[1]), (bbox[2], bbox[3]), (0, 255, 0), 2)
23
+ return img
24
+ #%%
25
+ demo = gr.Interface(predict,
26
+ "image",
27
+ "image",
28
+ examples=[
29
+ f"imgs/{i}.jpg" for i in range(1,7)
30
+ ],
31
+ cache_examples=True,
32
+ allow_flagging='never')
33
+
34
+ demo.launch(debug=True)
imgs/1.jpg ADDED
imgs/2.jpg ADDED
imgs/3.jpg ADDED
imgs/4.jpg ADDED
imgs/5.jpg ADDED
imgs/6.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==3.47.1
2
+ huggingface_hub==0.18.0
3
+ opencv_python==4.8.1.78
4
+ ultralytics==8.0.198