Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,16 @@
|
|
1 |
import gradio as gr
|
2 |
import asyncio
|
3 |
from huggingface_hub import AsyncInferenceClient
|
4 |
-
|
|
|
|
|
5 |
|
6 |
def image_classifier(inp):
|
7 |
class_names = ["0", "1"]
|
8 |
inp.save("why.png")
|
9 |
sunflower_path = "why.png"
|
10 |
-
|
|
|
11 |
c = {}
|
12 |
c[r[0]["label"]] = r[0]["score"]
|
13 |
c[r[1]["label"]] = 1 - r[0]["score"]
|
|
|
1 |
import gradio as gr
|
2 |
import asyncio
|
3 |
from huggingface_hub import AsyncInferenceClient
|
4 |
+
import os
|
5 |
+
hf = os.getenv("HF")
|
6 |
+
client = AsyncInferenceClient("openai/clip-vit-large-patch14", token=hf)
|
7 |
|
8 |
def image_classifier(inp):
|
9 |
class_names = ["0", "1"]
|
10 |
inp.save("why.png")
|
11 |
sunflower_path = "why.png"
|
12 |
+
hf = os.getenv("HF")
|
13 |
+
r = asyncio.run(client.zero_shot_image_classification("why.png", candidate_labels=["mouth", "other"]), token=)
|
14 |
c = {}
|
15 |
c[r[0]["label"]] = r[0]["score"]
|
16 |
c[r[1]["label"]] = 1 - r[0]["score"]
|