Spaces:
Sleeping
Sleeping
Update app.py
Browse files123456789101112131415161718192021import gradio as grimport cv2from ultralytics import YOLO# Load your custom trained modelmodel = YOLO("best.pt")def detect(frame):# If the frame is empty (can happen during stream initialization), return Noneif frame is None:return None, 0# ---> THIS IS THE MAGIC FIX <---# Create a writable copy of the read-only array provided by Gradioframe = frame.copy()results = model(frame, conf=0.4)pothole_count = 0for r in results:if r.boxes is not None:123456789101112131415161718192021import gradio as grimport cv2from ultralytics import YOLOpothole_count = 0# Load your custom trained modelmodel = YOLO("best.pt")def detect(frame):# If the frame is empty (can happen during stream initialization), return Noneif frame is None:return None, pothole_count+0# ---> THIS IS THE MAGIC FIX <---# Create a writable copy of the read-only array provided by Gradioframe = frame.copy()results = model(frame, conf=0.4)for r in results:if r.boxes is not None:
app.py+3-3