| import os | |
| import huggingface_hub as hf_hub | |
| import gradio as gr | |
| client = hf_hub.InferenceClient(token = os.environ['HF_TOKEN']) | |
| client.headers["x-use-cache"] = "0" | |
| def predict(image, label_list): | |
| labels = label_list.split(",") | |
| response = zero_shot_image_classification( | |
| image, | |
| labels | |
| ) | |
| return response | |
| app = gr.Interface( | |
| fn = predict, | |
| inputs = [ | |
| gr.Image(), | |
| gr.Textbox() | |
| ], | |
| outputs = gr.Label(), | |
| title = 'Zero Shot Image Classification', | |
| description = 'Vinay Kumar Thakur' | |
| ) | |
| app.launch() |