Spaces:
Sleeping
Sleeping
Update app.py
Browse files9 unmodified lines1011121314156 unmodified lines22232425262728293031323334359 unmodified linesif frame is None:return None, 0results = model(frame, conf=0.4)pothole_count = 06 unmodified linesx1, 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 partcv2.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 countreturn frame, pothole_count# Use Gradio Blocks for a cleaner, modern interfacewith gr.Blocks() as demo:gr.Markdown("# Live Pothole Detection")9 unmodified lines101112131415161718196 unmodified lines26272829303132333435369 unmodified linesif 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 = 06 unmodified linesx1, y1, x2, y2 = map(int, box.xyxy[0])cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)cv2.putText(frame, f"Potholes: {pothole_count}",(20, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 3)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