ammariii08 commited on
Commit
d06ef8c
·
verified ·
1 Parent(s): b343b31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -1,18 +1,14 @@
1
  import gradio as gr
2
- import torch
3
  import cv2
4
  import numpy as np
5
- from ultralytics import YOLO
6
-
7
- def load_model(model_path="ddr.pt"):
8
- return YOLO(model_path)
9
-
10
- model = load_model()
11
 
12
- def predict(image):
13
- results = model(image, conf=0.1)
14
- pred_img = results[0].plot() # Visualize detections
15
- return pred_img
 
 
16
 
17
  iface = gr.Interface(
18
  fn=predict,
 
1
  import gradio as gr
2
+ from ultralytics import YOLO
3
  import cv2
4
  import numpy as np
 
 
 
 
 
 
5
 
6
+ def detect_objects(image):
7
+ model = YOLO("./ddr.pt") # Load the trained model
8
+ results = model(image, conf=0.10) # Run inference with confidence threshold
9
+
10
+ output_image = results[0].plot() # Get the image with bounding boxes
11
+ return output_image
12
 
13
  iface = gr.Interface(
14
  fn=predict,