snicolau commited on
Commit
5f15b01
β€’
1 Parent(s): 5c91952

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -4
app.py CHANGED
@@ -1,7 +1,29 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import requests
3
+ from PIL import Image
4
+ from io import BytesIO
5
 
6
+ # Function to upload the image to the Hugging Face model
7
+ def upload_image(image):
8
+ # Send the image to Hugging Face
9
+ response = requests.post(
10
+ "https://api.deepai.org/api/analyze-image",
11
+ files={"image": image},
12
+ headers={"api-key": "YOUR_HUGGING_FACE_API_KEY"}
13
+ )
14
 
15
+ # Parse the response and get the result
16
+ result = response.json()
17
+ prediction = result.get("output", "Error")
18
+
19
+ return prediction
20
+
21
+ # Gradio interface
22
+ iface = gr.Interface(
23
+ fn=upload_image,
24
+ inputs=gr.Image(type="pil", label="Upload Image"),
25
+ outputs="text"
26
+ )
27
+
28
+ # Launch the Gradio app
29
+ iface.launch()