yuragoithf
commited on
Commit
·
29007e0
1
Parent(s):
1e1f9d1
Upload 12 files
Browse files- 00_plane.jpg +0 -0
- 01_car.jpg +0 -0
- 02_bird.jpg +0 -0
- 03_cat.jpg +0 -0
- 04_deer.jpg +0 -0
- 05_dog.jpg +0 -0
- 06_frog.jpg +0 -0
- 07_horse.jpg +0 -0
- 08_ship.jpg +0 -0
- 09_truck.jpg +0 -0
- app.py +37 -0
- requirements.txt +1 -0
00_plane.jpg
ADDED
01_car.jpg
ADDED
02_bird.jpg
ADDED
03_cat.jpg
ADDED
04_deer.jpg
ADDED
05_dog.jpg
ADDED
06_frog.jpg
ADDED
07_horse.jpg
ADDED
08_ship.jpg
ADDED
09_truck.jpg
ADDED
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
import gdown
|
4 |
+
from PIL import Image
|
5 |
+
|
6 |
+
import requests
|
7 |
+
|
8 |
+
API_URL = "https://api-inference.huggingface.co/models/facebook/detr-resnet-50-panoptic"
|
9 |
+
headers = {"Authorization": "Bearer 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"}
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
output = query("cats.jpg")
|
14 |
+
|
15 |
+
|
16 |
+
# Perform image segmentation for multy class output
|
17 |
+
def query(inputs):
|
18 |
+
with open(inputs, "rb") as f:
|
19 |
+
data = f.read()
|
20 |
+
response = requests.post(API_URL, headers=headers, data=data)
|
21 |
+
return response.json()
|
22 |
+
|
23 |
+
|
24 |
+
inputs = gr.inputs.Image(type="pil", label="Upload an image")
|
25 |
+
# outputs = gr.outputs.HTML() #uncomment for single class output
|
26 |
+
#outputs = query(inputs)
|
27 |
+
|
28 |
+
title = "<h1 style='text-align: center;'>Image Segmentation</h1>"
|
29 |
+
description = "Upload an image and get the segmentation result."
|
30 |
+
|
31 |
+
gr.Interface(fn=classify_image,
|
32 |
+
inputs=inputs,
|
33 |
+
outputs=query(inputs),
|
34 |
+
title=title,
|
35 |
+
examples=[["00_plane.jpg"], ["01_car.jpg"], ["02_bird.jpg"], ["03_cat.jpg"], ["04_deer.jpg"]],
|
36 |
+
description=description,
|
37 |
+
enable_queue=True).launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradio
|