LimaLimao commited on
Commit
0f65929
·
verified ·
1 Parent(s): a10b295

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +13 -13
  2. app.py +55 -0
  3. best.pt +3 -0
  4. requirements.txt +0 -0
README.md CHANGED
@@ -1,13 +1,13 @@
1
- ---
2
- title: Yolo IFMT
3
- emoji: 🦀
4
- colorFrom: indigo
5
- colorTo: green
6
- sdk: gradio
7
- sdk_version: 4.39.0
8
- app_file: app.py
9
- pinned: false
10
- license: cc-by-4.0
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ ---
2
+ title: Yolo Ifmt
3
+ emoji: 📈
4
+ colorFrom: gray
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 4.39.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: cc-by-4.0
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cv2
3
+ from ultralytics import YOLOv10
4
+ from moviepy.editor import *
5
+
6
+
7
+ model = YOLOv10("best.pt")
8
+
9
+ def predict_image(img):
10
+ results = model.predict(
11
+ source=img,
12
+ # conf=conf_threshold,
13
+ # iou=iou_threshold,
14
+ # show_labels=True,
15
+ # show_conf=True,
16
+ )
17
+ im_rgb = cv2.cvtColor(results[0].plot(), cv2.COLOR_BGR2RGB)
18
+ return im_rgb if results else None
19
+
20
+
21
+ def predict_video(video):
22
+ results = model.predict(source=video, save_dir='./')
23
+ # print(results)
24
+ images_list = []
25
+
26
+ for r in results:
27
+ im_rgb = cv2.cvtColor(r.plot(), cv2.COLOR_BGR2RGB)
28
+ images_list.append(im_rgb)
29
+
30
+ clip = ImageSequenceClip(images_list, fps=15)
31
+ clip.ipython_display(width = 360)
32
+
33
+ return '__temp__.mp4' if results else None
34
+
35
+
36
+ Image = gr.Interface(fn=predict_image,
37
+ inputs=gr.Image(type="pil", label="Upload Image"),
38
+ outputs=gr.Image(type="pil", label="Result"),
39
+ description="Upload images for YOLOv10 object detection.",
40
+ )
41
+
42
+ Video = gr.Interface(fn=predict_video,
43
+ inputs=gr.Video(),
44
+ outputs=gr.Video(),
45
+ description="Upload Video for YOLOv10 object detection.",
46
+ )
47
+
48
+ demo = gr.TabbedInterface(
49
+ [Image, Video],
50
+ ["Image", "Video"],
51
+ title="Ultralytics Gradio YOLOv10",
52
+ )
53
+
54
+
55
+ demo.launch(share=True)
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5609255604b716b245c8281dfac6d9af494bb1108d8103b4079bd575c1b9f7e7
3
+ size 5766244
requirements.txt ADDED
Binary file (234 Bytes). View file