|
import requests |
|
import os, io |
|
import gradio as gr |
|
|
|
|
|
|
|
|
|
|
|
API_URL = "https://api-inference.huggingface.co/models/facebook/detr-resnet-50-dc5-panoptic" |
|
headers = {"Authorization": "Bearer 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"} |
|
|
|
|
|
def image_classifier(inp): |
|
return {'cat': 0.3, 'dog': 0.7} |
|
|
|
def query(filename): |
|
with open(filename, "rb") as f: |
|
data = f.read() |
|
response = requests.post(API_URL, headers=headers, data=data) |
|
return response.json() |
|
|
|
def rb(img): |
|
|
|
img_byte_arr = io.BytesIO() |
|
|
|
img.save(img_byte_arr, format='JPEG', subsampling=0, quality=100) |
|
|
|
img_byte_arr = img_byte_arr.getvalue() |
|
|
|
|
|
response = requests.post(API_URL, headers=headers, data=img_byte_arr) |
|
logits = response.score |
|
|
|
|
|
return response.json() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gr.Interface.load("spaces/eugenesiow/remove-bg").launch(); |
|
|