arham061 commited on
Commit
4b26ce8
1 Parent(s): 1fd49da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from fastai.vision.all import *
2
  import gradio as gr
 
3
 
4
  __all__ = ['is_rock', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
5
 
@@ -14,16 +15,16 @@ def classify_images(img):
14
  pred, idx, probs = learn.predict(img)
15
  return dict(zip(categories, map(float, probs)))
16
 
17
- #def get_webcam_image():
18
- # cap = cv2.VideoCapture(0)
19
- # _, frame = cap.read()
20
- # cap.release()
21
- # return frame
22
 
23
 
24
  image = gr.inputs.Image(shape=(192,192))
25
  label = gr.outputs.Label()
26
  examples = ['rock.jpg', 'paper.jpg', 'scissor.jpg']
27
 
28
- intf = gr.Interface(fn = classify_images, inputs = webcam_image, outputs = label, examples = examples)
29
  intf.launch(inline=False)
 
1
  from fastai.vision.all import *
2
  import gradio as gr
3
+ import cv2
4
 
5
  __all__ = ['is_rock', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
6
 
 
15
  pred, idx, probs = learn.predict(img)
16
  return dict(zip(categories, map(float, probs)))
17
 
18
+ def get_webcam_image():
19
+ cap = cv2.VideoCapture(0)
20
+ _, frame = cap.read()
21
+ cap.release()
22
+ return frame
23
 
24
 
25
  image = gr.inputs.Image(shape=(192,192))
26
  label = gr.outputs.Label()
27
  examples = ['rock.jpg', 'paper.jpg', 'scissor.jpg']
28
 
29
+ intf = gr.Interface(fn = classify_images, inputs = get_webcam_imageimage, outputs = label, examples = examples)
30
  intf.launch(inline=False)