finalProject2 / app.py
amjadfqs's picture
Update app.py
22a9bc1 verified
raw
history blame
794 Bytes
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()