paoyingheng commited on
Commit
cf43e68
·
1 Parent(s): 5b370fd
Files changed (2) hide show
  1. README.md +2 -2
  2. app.py +2 -3
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
- title: Parasitic Egg Detection
3
- emoji: 🐢
4
  colorFrom: gray
5
  colorTo: green
6
  sdk: gradio
 
1
  ---
2
+ title: Parasite Egg Detection
3
+ emoji: 🦠
4
  colorFrom: gray
5
  colorTo: green
6
  sdk: gradio
app.py CHANGED
@@ -7,8 +7,7 @@ torch.hub.download_url_to_file('https://st4.depositphotos.com/3687893/27930/i/45
7
  torch.hub.download_url_to_file('https://sanangelo.tamu.edu/files/2021/06/Image_4_whipworm_egg.jpg', 'three.jpg')
8
 
9
  def para_func(image: gr.Image = None, image_size: gr.Slider = 640, conf_threshold: gr.Slider = 0.4, iou_threshold: gr.Slider = 0.50):
10
- # model = YOLO('yolov8n.pt') #yolov8 trained model
11
- model = YOLO('best.pt') # custom trained model
12
 
13
  # Perform object detection on the input image using YOLO model
14
  results = model.predict(image, conf=conf_threshold, iou=iou_threshold, imgsz=image_size)
@@ -17,7 +16,7 @@ def para_func(image: gr.Image = None, image_size: gr.Slider = 640, conf_threshol
17
  box = results[0].boxes
18
  print("Object type:", box.cls)
19
  print("Coordinates:", box.xyxy)
20
- print("Probability:", box.conf)
21
 
22
  # Render the output image with bounding boxes around detected objects
23
  render = render_result(model=model, image=image, result=results[0])
 
7
  torch.hub.download_url_to_file('https://sanangelo.tamu.edu/files/2021/06/Image_4_whipworm_egg.jpg', 'three.jpg')
8
 
9
  def para_func(image: gr.Image = None, image_size: gr.Slider = 640, conf_threshold: gr.Slider = 0.4, iou_threshold: gr.Slider = 0.50):
10
+ model = YOLO('best.pt') # Custom trained model
 
11
 
12
  # Perform object detection on the input image using YOLO model
13
  results = model.predict(image, conf=conf_threshold, iou=iou_threshold, imgsz=image_size)
 
16
  box = results[0].boxes
17
  print("Object type:", box.cls)
18
  print("Coordinates:", box.xyxy)
19
+ print("Probability:", f'{box.conf * 100:.1f}%')
20
 
21
  # Render the output image with bounding boxes around detected objects
22
  render = render_result(model=model, image=image, result=results[0])