Inigozr commited on
Commit
8b7fae6
1 Parent(s): 4114862

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -20,22 +20,19 @@ templates = Jinja2Templates(directory="templates")
20
 
21
 
22
  def predict_yolo(image_path):
23
- # Assuming you have a YOLO API endpoint that accepts an image and returns predictions
24
- with open(image_path, "rb") as file:
25
- files = {"file": file}
26
- # Load a model
27
- model = YOLO('yolov8n.pt') # pretrained YOLOv8n model
28
 
29
- # Run batched inference on a list of images
30
- results = model(image_path) # return a list of Results objects
31
 
32
- # Process results list
33
- for result in results:
34
- boxes = result.boxes # Boxes object for bbox outputs
35
- # masks = result.masks # Masks object for segmentation masks outputs
36
- # keypoints = result.keypoints # Keypoints object for pose outputs
37
- # probs = result.probs # Probs object for classification outputs
38
- predictions = boxes.json()
39
  return predictions
40
 
41
 
 
20
 
21
 
22
  def predict_yolo(image_path):
23
+ # Load a model
24
+ model = YOLO('yolov8n.pt') # pretrained YOLOv8n model
 
 
 
25
 
26
+ # Run batched inference on a list of images
27
+ results = model(image_path) # return a list of Results objects
28
 
29
+ # Process results list
30
+ for result in results:
31
+ boxes = result.boxes # Boxes object for bbox outputs
32
+ # masks = result.masks # Masks object for segmentation masks outputs
33
+ # keypoints = result.keypoints # Keypoints object for pose outputs
34
+ # probs = result.probs # Probs object for classification outputs
35
+ predictions = boxes.json()
36
  return predictions
37
 
38