Spaces:
Sleeping
Sleeping
File size: 803 Bytes
0251dfb 4b26ce8 0251dfb 40ea620 0251dfb 2a57eb8 c511ff9 0251dfb 12197c3 0251dfb 4b26ce8 d39566a 0251dfb 4092fbb 0251dfb 40ea620 63e42be |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from fastai.vision.all import *
import gradio as gr
import cv2
__all__ = ['is_rock', 'learn', 'classify_images', 'get_webcam_image' 'categories', 'image', 'label', 'examples', 'intf']
def is_rock(x): return x[0].issuper()
learn = load_learner('RPS_model2.pkl')
categories = ('paper', 'rock', 'scissors')
def classify_images(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
def get_webcam_image():
cap = cv2.VideoCapture(0)
_, frame = cap.read()
cap.release()
return frame
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['rock.jpg', 'paper.jpg', 'scissor.jpg']
intf = gr.Interface(fn = classify_images, inputs = get_webcam_image, outputs = label, examples = examples)
intf.launch(inline=False) |