yuragoithf
commited on
Commit
•
882c6dd
1
Parent(s):
587c6f4
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import requests
|
2 |
import os
|
3 |
import gradio as gr
|
|
|
4 |
|
5 |
API_URL = "https://api-inference.huggingface.co/models/facebook/detr-resnet-50-panoptic"
|
6 |
headers = {"Authorization": "Bearer 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"}
|
@@ -16,12 +17,16 @@ def query(filename):
|
|
16 |
|
17 |
def rb(data):
|
18 |
response = requests.post(API_URL, headers=headers, data=data.tobytes())
|
|
|
19 |
return response.json()
|
20 |
|
21 |
# train = os.listdir("./")
|
22 |
# print(train)
|
23 |
output = query("./09_truck.jpg")
|
24 |
|
|
|
|
|
25 |
inputs = gr.inputs.Image(type="pil", label="Upload an image")
|
|
|
26 |
demo = gr.Interface(fn=rb, inputs=inputs, outputs="json")
|
27 |
demo.launch()
|
|
|
1 |
import requests
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
+
# from PIL import Image
|
5 |
|
6 |
API_URL = "https://api-inference.huggingface.co/models/facebook/detr-resnet-50-panoptic"
|
7 |
headers = {"Authorization": "Bearer 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"}
|
|
|
17 |
|
18 |
def rb(data):
|
19 |
response = requests.post(API_URL, headers=headers, data=data.tobytes())
|
20 |
+
response = requests.post(API_URL, headers=headers, data=data)
|
21 |
return response.json()
|
22 |
|
23 |
# train = os.listdir("./")
|
24 |
# print(train)
|
25 |
output = query("./09_truck.jpg")
|
26 |
|
27 |
+
|
28 |
+
|
29 |
inputs = gr.inputs.Image(type="pil", label="Upload an image")
|
30 |
+
inputs = PIL.Image.frombuffer(data, decoder_name='raw', *args)[source]
|
31 |
demo = gr.Interface(fn=rb, inputs=inputs, outputs="json")
|
32 |
demo.launch()
|