Ramendra commited on
Commit
c651427
1 Parent(s): ed6b321

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +39 -0
  2. best.pt +3 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ultralytics import YOLO
2
+ import gradio as gr
3
+ import PIL.Image as Image
4
+
5
+ path="best.pt"
6
+
7
+ model=YOLO(path)
8
+
9
+ def predict_image(img, conf_threshold, iou_threshold):
10
+ """Predicts objects in an image using a YOLOv8 model with adjustable confidence and IOU thresholds."""
11
+ results = model.predict(
12
+ source=img,
13
+ conf=conf_threshold,
14
+ iou=iou_threshold,
15
+ show_labels=True,
16
+ show_conf=True,
17
+ imgsz=640,
18
+ )
19
+
20
+ for r in results:
21
+ im_array = r.plot()
22
+ im = Image.fromarray(im_array[..., ::-1])
23
+
24
+ return im
25
+
26
+
27
+ iface = gr.Interface(
28
+ fn=predict_image,
29
+ inputs=[
30
+ gr.Image(type="pil", label="Upload Image"),
31
+ gr.Slider(minimum=0, maximum=1, value=0.25, label="Confidence threshold"),
32
+ gr.Slider(minimum=0, maximum=1, value=0.45, label="IoU threshold"),
33
+ ],
34
+ outputs=gr.Image(type="pil", label="Result"),
35
+ title="Object tetection Gradio",
36
+ description="Upload images for inference.",
37
+ )
38
+
39
+ iface.launch()
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56500fedd925e8b61057a56951161dac5a911437954c1191ebb9c37d76c2f11f
3
+ size 87653491
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ultralytics
2
+ gradio