Commit ·
990c881
1
Parent(s): 13642a2
Upload app.py
Browse files3 unmodified lines4567891011121314151610 unmodified lines27282930313233343536373839404142433 unmodified lineslearn = load_learner('resnet18_model.pkl')categories = ('Black','White')def classify_image(image):is_people,_,probs = learn.predict(PILImage.create(image))return dict(zip(categories,map(float,probs)))def capture_image(cam):cam = cv2.VideoCapture(0)10 unmodified linesframe = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)yield frameimage = gr.inputs.Image(shape=(192, 192), label="Upload Image", source="upload")webcam = gr.inputs.Image(shape=(192, 192), label="Webcam Image", source="webcam")label = gr.outputs.Label()examples=['example1.jpg','example2.jpg','example3.jpg']intf = gr.Interface(fn=classify_image, inputs=[image, webcam], outputs=label, examples=examples,allow_flagging=False, capture_session=True)intf.launch(inline=False)3 unmodified lines4567891011121314151610 unmodified lines27282930313233343536373839403 unmodified lineslearn = load_learner('resnet18_model.pkl')categories = ('Black', 'White')def classify_image(image):is_people, _, probs = learn.predict(PILImage.create(image))return dict(zip(categories, map(float, probs)))def capture_image(cam):cam = cv2.VideoCapture(0)10 unmodified linesframe = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)yield frameimage = gr.inputs.Image(shape=(192, 192), label="Upload Image", source="upload")webcam = gr.inputs.Image(shape=(192, 192), label="Webcam Image", source="webcam")label = gr.outputs.Label()examples = [['example1.jpg'], ['example2.jpg'], ['example3.jpg']] # Nested list for multiple input componentsintf = gr.Interface(fn=classify_image, inputs=[image, webcam], outputs=label, examples=examples,allow_flagging='never') # Set allow_flagging parameter as a stringintf.launch()
app.py+8-11