Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,19 +31,12 @@ def apply_effects(frame):
|
|
| 31 |
|
| 32 |
return frame
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
ret, frame = cap.read() # Read a frame from the webcam
|
| 38 |
-
if not ret:
|
| 39 |
-
break
|
| 40 |
-
|
| 41 |
-
processed_frame = apply_effects(frame) # Apply effects to the frame
|
| 42 |
-
|
| 43 |
-
cv2.imshow("Webcam with Effects", processed_frame) # Display the processed frame
|
| 44 |
-
|
| 45 |
-
if cv2.waitKey(1) & 0xFF == ord('q'): # Press 'q' to exit
|
| 46 |
-
break
|
| 47 |
-
|
| 48 |
-
cap.release() # Release the webcam
|
| 49 |
-
cv2.destroyAllWindows() # Close all windows
|
|
|
|
| 31 |
|
| 32 |
return frame
|
| 33 |
|
| 34 |
+
iface = gr.Interface(
|
| 35 |
+
fn=apply_effects,
|
| 36 |
+
inputs="webcam",
|
| 37 |
+
outputs="image",
|
| 38 |
+
live=True, # This enables the live webcam feed
|
| 39 |
+
capture_session=True # This ensures the webcam feed is properly closed when the interface is closed
|
| 40 |
+
)
|
| 41 |
|
| 42 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|