Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
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 =
|
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)
|