Spaces:
Sleeping
Sleeping
Update app.py
Browse files9 unmodified lines101112131415161718196 unmodified lines26272825293031293233323435369 unmodified lines if frame is None: return None, 0
# ---> THIS IS THE MAGIC FIX <--- # Create a writable copy of the read-only array provided by Gradio frame = frame.copy()
results = model(frame, conf=0.4) pothole_count = 0
6 unmodified lines x1, y1, x2, y2 = map(int, box.xyxy[0]) cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
# You can keep the text on the video if you want, or remove this part cv2.putText(frame, f"Potholes: {pothole_count}", (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 3)
# RETURN BOTH: The modified image, and the total count return frame, pothole_count
# Use Gradio Blocks for a cleaner, modern interfacewith gr.Blocks() as demo: gr.Markdown("# Live Pothole Detection")app.py+4-3