demo / app.py
Imadsarvm's picture
Update app.py
c26e4a8 verified
raw
history blame
968 Bytes
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
interface = gr.Interface(
fn=inference,
inputs=gr.Textbox(label="Text or Image URL", interactive=True),
outputs=["image"],
title="Dsdsd",
description="dsds",
article="dsd",
allow_flagging='never',
cache_examples=False,
).queue().launch(show_error=True, share = True)