import gradio as gr from transformers import pipeline import os # Ensure this environment variable is set correctly hf_token = os.getenv("HF_TOKEN") # Load the model using pipeline (which gives more control and better error handling) classifier = pipeline("image-classification", model="lamrin8224/oxford_flowers_image_detection", token=hf_token) def predict(img): result = classifier(img) return {r['label']: r['score'] for r in result} gr.Interface(fn=predict, inputs="image", outputs="label").launch(share=True)