Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,17 +4,16 @@ from PIL import Image
|
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
# Load YOLOv12 model
|
| 7 |
-
model = YOLO("best.pt")
|
| 8 |
|
| 9 |
def predict(image):
|
| 10 |
-
# Ensure RGB and convert to NumPy
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
# Run inference
|
| 15 |
-
results = model.predict(img_array)
|
| 16 |
-
|
| 17 |
-
# Annotate
|
| 18 |
annotated_img = results[0].plot()
|
| 19 |
return annotated_img
|
| 20 |
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
# Load YOLOv12 model
|
| 7 |
+
model = YOLO("best.pt")
|
| 8 |
|
| 9 |
def predict(image):
|
| 10 |
+
# Ensure RGB and convert to NumPy
|
| 11 |
+
img_array = np.array(image.convert("RGB"))
|
| 12 |
+
|
|
|
|
| 13 |
# Run inference
|
| 14 |
+
results = model.predict(img_array, imgsz=640) # specify size for safety
|
| 15 |
+
|
| 16 |
+
# Annotate image
|
| 17 |
annotated_img = results[0].plot()
|
| 18 |
return annotated_img
|
| 19 |
|