mennamostafa55555 commited on
Commit
4d26a0d
·
1 Parent(s): 641a29d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -2,6 +2,7 @@ import supervision as sv
2
  import gradio as gr
3
  from ultralytics import YOLO
4
  import sahi
 
5
 
6
 
7
 
@@ -20,6 +21,8 @@ sahi.utils.file.download_from_url(
20
  )
21
 
22
 
 
 
23
  annotatorbbox = sv.BoxAnnotator()
24
  annotatormask=sv.MaskAnnotator()
25
 
@@ -33,13 +36,14 @@ def yolov8_inference(
33
  ):
34
 
35
 
36
- model = YOLO("https://huggingface.co/spaces/devisionx/Fifth_model/blob/main/best_weigh.pt")
 
 
37
 
38
  results = model(image,conf=conf_threshold,iou=iou_threshold ,imgsz=360)[0]
 
39
  detections = sv.Detections.from_yolov8(results)
40
  annotated_image = annotatorbbox.annotate(scene=image, detections=detections)
41
- annotated_image = annotatormask.annotate(scene=annotated_image, detections=detections)
42
-
43
 
44
 
45
 
@@ -71,4 +75,4 @@ demo_app = gr.Interface(examples=examples,
71
  cache_examples=True,
72
  theme="default",
73
  )
74
- demo_app.launch(debug=True, enable_queue=True)
 
2
  import gradio as gr
3
  from ultralytics import YOLO
4
  import sahi
5
+ import numpy as np
6
 
7
 
8
 
 
21
  )
22
 
23
 
24
+
25
+
26
  annotatorbbox = sv.BoxAnnotator()
27
  annotatormask=sv.MaskAnnotator()
28
 
 
36
  ):
37
 
38
 
39
+
40
+ image=image[:, :, ::-1].astype(np.uint8)
41
+ model = YOLO("/content/segment/train/weights/best.pt")
42
 
43
  results = model(image,conf=conf_threshold,iou=iou_threshold ,imgsz=360)[0]
44
+ image=image[:, :, ::-1].astype(np.uint8)
45
  detections = sv.Detections.from_yolov8(results)
46
  annotated_image = annotatorbbox.annotate(scene=image, detections=detections)
 
 
47
 
48
 
49
 
 
75
  cache_examples=True,
76
  theme="default",
77
  )
78
+ demo_app.launch(debug=False, enable_queue=True)