File size: 656 Bytes
7df6ff3 22e5a22 17dcf9a 1026ade 9d524b4 7df6ff3 0b16ed1 93b5ece e8585dd 1026ade 14e4177 2ef19d7 7a8f49a 2ef19d7 9d524b4 7df6ff3 9d524b4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
import asyncio
from huggingface_hub import AsyncInferenceClient
import os
hf = os.getenv("HF")
client = AsyncInferenceClient("openai/clip-vit-large-patch14", token=hf)
def image_classifier(inp):
class_names = ["0", "1"]
inp.save("why.png")
sunflower_path = "why.png"
hf = os.getenv("HF")
r = asyncio.run(client.zero_shot_image_classification("why.png", candidate_labels=["mouth", "other"]), token=)
c = {}
c[r[0]["label"]] = r[0]["score"]
c[r[1]["label"]] = 1 - r[0]["score"]
return c
demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="label")
demo.launch(debug=True)
|