Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import huggingface_hub as hf_hub
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
client = hf_hub.InferenceClient(token = os.environ['HF_TOKEN'])
|
| 6 |
+
client.headers["x-use-cache"] = "0"
|
| 7 |
+
|
| 8 |
+
def predict(image, label_list):
|
| 9 |
+
labels = label_list.split(",")
|
| 10 |
+
response = zero_shot_image_classification(
|
| 11 |
+
image,
|
| 12 |
+
labels
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
return response
|
| 16 |
+
|
| 17 |
+
app = gr.Interface(
|
| 18 |
+
fn = predict,
|
| 19 |
+
inputs = [
|
| 20 |
+
gr.Image(),
|
| 21 |
+
gr.Textbox()
|
| 22 |
+
],
|
| 23 |
+
outputs = gr.Label(),
|
| 24 |
+
title = 'Zero Shot Image Classification',
|
| 25 |
+
description = 'Vinay Kumar Thakur'
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
app.launch()
|