Spaces:
Sleeping
Sleeping
File size: 561 Bytes
8a25ce2 15784aa 8a25ce2 b10f252 8a25ce2 5883283 ddd484c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import gradio as gr
from transformers import pipeline
pipe = pipeline("zero-shot-image-classification", model="openai/clip-vit-base-patch32")
def predict(photo,Label1,Label2,Label3):
out1= pipe(images=photo,candidate_labels=[Label1,Label2,Label3])
out2=out1[0]
out3=out2['label']
out4=out2['score']
if out4<0.9:
out3='No Match'
return out3
label1='Apple'
label2='Orange'
label3='Banana'
demo = gr.Interface(fn=predict,inputs=[gr.Image(type="pil"),'text','text','text'],outputs='text',examples=[['Banana.jpg',label1,label2,label3]])
demo.launch() |