Spaces:
Sleeping
Sleeping
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() |