Spaces:
Sleeping
Sleeping
Commit
·
905f062
1
Parent(s):
992cb5a
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ SECRET_TOKEN = os.getenv("SECRET_TOKEN")
|
|
9 |
API_URL = "https://api-inference.huggingface.co/models/facebook/detr-resnet-50-dc5-panoptic"
|
10 |
headers = {"Authorization": f'Bearer {SECRET_TOKEN}'}
|
11 |
|
|
|
12 |
|
13 |
def rb(img):
|
14 |
# initialiaze io to_bytes converter
|
@@ -17,14 +18,13 @@ def rb(img):
|
|
17 |
img.save(img_byte_arr, format='JPEG', subsampling=0, quality=100)
|
18 |
# converts image array to bytesarray
|
19 |
img_byte_arr = img_byte_arr.getvalue()
|
20 |
-
|
21 |
-
|
22 |
-
estimator = pipeline("depth-estimation")
|
23 |
-
result = estimator("http://images.cocodataset.org/val2017/000000039769.jpg")
|
24 |
|
25 |
|
26 |
inputs = gr.inputs.Image(type="pil", label="Upload an image")
|
27 |
|
28 |
-
|
|
|
29 |
#demo = gr.Interface(fn=rb, inputs=inputs, outputs=result["depth"])
|
30 |
demo.launch()
|
|
|
9 |
API_URL = "https://api-inference.huggingface.co/models/facebook/detr-resnet-50-dc5-panoptic"
|
10 |
headers = {"Authorization": f'Bearer {SECRET_TOKEN}'}
|
11 |
|
12 |
+
estimator = pipeline("depth-estimation")
|
13 |
|
14 |
def rb(img):
|
15 |
# initialiaze io to_bytes converter
|
|
|
18 |
img.save(img_byte_arr, format='JPEG', subsampling=0, quality=100)
|
19 |
# converts image array to bytesarray
|
20 |
img_byte_arr = img_byte_arr.getvalue()
|
21 |
+
result = estimator(img_byte_arr)
|
22 |
+
return result
|
|
|
|
|
23 |
|
24 |
|
25 |
inputs = gr.inputs.Image(type="pil", label="Upload an image")
|
26 |
|
27 |
+
|
28 |
+
demo = gr.Interface(fn=rb, inputs=inputs, outputs="json")
|
29 |
#demo = gr.Interface(fn=rb, inputs=inputs, outputs=result["depth"])
|
30 |
demo.launch()
|