Rasleen commited on
Commit
7d51cef
·
verified ·
1 Parent(s): 17b186a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -15,6 +15,7 @@ def paint(frame: np.ndarray) -> np.ndarray:
15
  global canvas
16
  h, w, _ = frame.shape
17
 
 
18
  if canvas is None:
19
  canvas = np.zeros((h, w, 3), dtype=np.uint8)
20
 
@@ -29,10 +30,11 @@ def paint(frame: np.ndarray) -> np.ndarray:
29
  # Blend live frame and canvas
30
  return cv2.addWeighted(frame, 0.5, canvas, 0.5, 0)
31
 
 
32
  demo = gr.Interface(
33
  fn=paint,
34
- inputs=gr.inputs.Image(source="webcam", type="numpy"),
35
- outputs=gr.outputs.Image(type="numpy"),
36
  live=True,
37
  title="🖌️ Virtual Painter",
38
  description="Move your index finger in front of the camera to draw!"
 
15
  global canvas
16
  h, w, _ = frame.shape
17
 
18
+ # Initialize canvas once
19
  if canvas is None:
20
  canvas = np.zeros((h, w, 3), dtype=np.uint8)
21
 
 
30
  # Blend live frame and canvas
31
  return cv2.addWeighted(frame, 0.5, canvas, 0.5, 0)
32
 
33
+ # --- Gradio interface using gr.components ---
34
  demo = gr.Interface(
35
  fn=paint,
36
+ inputs=gr.components.Image(source="webcam", type="numpy"),
37
+ outputs=gr.components.Image(type="numpy"),
38
  live=True,
39
  title="🖌️ Virtual Painter",
40
  description="Move your index finger in front of the camera to draw!"