demo / app.py
Imadsarvm's picture
Update app.py
9f67494 verified
raw
history blame
1.23 kB
import cv2
import gradio as gr
import os
import functools
from PIL import Image
from rembg import remove
from io import BytesIO
import numpy as np
import torch
from torch.autograd import Variable
from torchvision import transforms
import torch.nn.functional as F
import gdown
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings("ignore")
import requests
@functools.lru_cache()
def get_url_im(t):
user_agent = {'User-agent': 'gradio-app'}
response = requests.get(t, headers=user_agent)
return (BytesIO(response.content))
def inference(image):
im_path = get_url_im(image)
im = Image.open(im_reader(im_path))
return im, im , im
title = "Bg remover for sarvm catalog"
description = "Bg remover for sarvm catalog"
article = "<div><center><img src='https://visitor-badge.glitch.me/badge?page_id=max_skobeev_dis_cmp_public' alt='visitor badge'></center></div>"
interface = gr.Interface(
fn=inference,
inputs=gr.Textbox(label="Text or Image URL", interactive=True),
outputs=["image", "image", "image"],
title=title ,
description=description,
article=article,
allow_flagging='never',
cache_examples=False,
).queue().launch(show_error=True, share = True)