import gradio as gr import requests from PIL import Image def load_model(model_name): # Use the Hugging Face API to load the model api_url = f"https://huggingface.co/{model_name}" response = requests.get(api_url) if response.status_code == 200: # Assume the model is an image processing model return lambda image: image # Replace with actual model processing code else: raise ValueError("Model not found") # Load the model once during initialization model = load_model("amjadfqs/finalProject") def predict(image): # Use the model to make a prediction return model(image) # Set up the Gradio interface image_cp = gr.Image(type="pil", label='Brain') interface = gr.Interface(fn=predict, inputs=image_cp, outputs="text") interface.launch()