amjadfqs commited on
Commit
22a9bc1
·
verified ·
1 Parent(s): e36a241

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -1,10 +1,25 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def predict(image):
4
- # Load your Hugging Face model here and make a prediction
5
- model = gr.load("models/amjadfqs/finalProject")
6
  return model(image)
7
 
 
8
  image_cp = gr.Image(type="pil", label='Brain')
9
  interface = gr.Interface(fn=predict, inputs=image_cp, outputs="text")
10
  interface.launch()
 
1
  import gradio as gr
2
+ import requests
3
+ from PIL import Image
4
+
5
+ def load_model(model_name):
6
+ # Use the Hugging Face API to load the model
7
+ api_url = f"https://huggingface.co/{model_name}"
8
+ response = requests.get(api_url)
9
+ if response.status_code == 200:
10
+ # Assume the model is an image processing model
11
+ return lambda image: image # Replace with actual model processing code
12
+ else:
13
+ raise ValueError("Model not found")
14
+
15
+ # Load the model once during initialization
16
+ model = load_model("amjadfqs/finalProject")
17
 
18
  def predict(image):
19
+ # Use the model to make a prediction
 
20
  return model(image)
21
 
22
+ # Set up the Gradio interface
23
  image_cp = gr.Image(type="pil", label='Brain')
24
  interface = gr.Interface(fn=predict, inputs=image_cp, outputs="text")
25
  interface.launch()