yoloKYS commited on
Commit
edcea04
·
verified ·
1 Parent(s): d095e60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -17,9 +17,19 @@ model = YOLO(model_path)
17
 
18
  # ---- Detection function ----
19
  def detect_objects(image):
20
- img = np.array(image)
21
- # use predict() with confidence and image size settings
22
- results = model.predict(source=img, imgsz=640, conf=0.25)
 
 
 
 
 
 
 
 
 
 
23
  annotated = results[0].plot()
24
  return Image.fromarray(annotated)
25
 
 
17
 
18
  # ---- Detection function ----
19
  def detect_objects(image):
20
+ # Convert PIL to RGB NumPy array (YOLO expects RGB)
21
+ img = np.array(image.convert("RGB"))
22
+
23
+ # Run prediction with same settings used during training
24
+ results = model.predict(
25
+ source=img,
26
+ imgsz=640, # same resolution as training
27
+ conf=0.25, # lower confidence threshold to catch subtle detections
28
+ iou=0.45, # standard non-max suppression
29
+ verbose=False
30
+ )
31
+
32
+ # Visualize results
33
  annotated = results[0].plot()
34
  return Image.fromarray(annotated)
35