Spaces:
Running
Running
File size: 865 Bytes
6671e18 18bd2aa 6671e18 18bd2aa 6671e18 aa5ae13 6671e18 18bd2aa 6671e18 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio as gr
from PIL import Image
from urllib.request import Request, urlopen
def display_image_from_url(url, input_image):
if url == '' and input_image is None:
return None, "", ""
image = None
if url != '':
req = Request(
url=url,
headers={'User-Agent': 'Mozilla/5.0'}
)
res = urlopen(req)
image = Image.open(res)
image.load()
if input_image is not None:
image = input_image
parameters = "Parameters have been erased from this image"
if 'parameters' in image.info:
parameters = image.info['parameters']
return image, parameters, image.info
server = gr.Interface(display_image_from_url, ["text", gr.Image(type='pil')], [gr.Image(type='pil'), gr.Textbox(label="Generation Parameters"), gr.Textbox(label="Metadata")])
server.launch()
|