mennamostafa55555 commited on
Commit
857e0c5
·
1 Parent(s): 38f8579

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -2,7 +2,7 @@ import supervision as sv
2
  import gradio as gr
3
  from ultralytics import YOLO
4
  import sahi
5
-
6
 
7
 
8
 
@@ -28,19 +28,20 @@ annotatorbbox = sv.BoxAnnotator()
28
  annotatormask=sv.MaskAnnotator()
29
  model = YOLO("best_Receipt.pt")
30
 
 
31
  def yolov8_inference(
32
  image: gr.inputs.Image = None,
33
- model_name: gr.inputs.Dropdown = None,
34
- image_size: gr.inputs.Slider = 320,
35
- conf_threshold: gr.inputs.Slider = 0.25,
36
  iou_threshold: gr.inputs.Slider = 0.45,
37
  ):
38
 
39
-
40
- results = model(image,conf=conf_threshold,iou=iou_threshold ,imgsz=320)[0]
 
 
41
  detections = sv.Detections.from_yolov8(results)
42
- annotated_image = annotatorbbox.annotate(scene=image, detections=detections)
43
- annotated_image = annotatormask.annotate(scene=annotated_image, detections=detections)
44
 
45
 
46
 
 
2
  import gradio as gr
3
  from ultralytics import YOLO
4
  import sahi
5
+ import numpy as np
6
 
7
 
8
 
 
28
  annotatormask=sv.MaskAnnotator()
29
  model = YOLO("best_Receipt.pt")
30
 
31
+
32
  def yolov8_inference(
33
  image: gr.inputs.Image = None,
34
+ conf_threshold: gr.inputs.Slider = 0.5,
 
 
35
  iou_threshold: gr.inputs.Slider = 0.45,
36
  ):
37
 
38
+ image=image[:, :, ::-1].astype(np.uint8)
39
+ model = YOLO("https://huggingface.co/spaces/devisionx/first-demo/blob/main/best_Receipt.pt")
40
+ results = model(image,imgsz=320)[0]
41
+ image=image[:, :, ::-1].astype(np.uint8)
42
  detections = sv.Detections.from_yolov8(results)
43
+ annotated_image = annotatormask.annotate(scene=image, detections=detections)
44
+ annotated_image = annotatorbbox.annotate(scene=annotated_image , detections=detections)
45
 
46
 
47