Spaces:
Runtime error
Runtime error
File size: 1,563 Bytes
fcc9852 |
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 32 33 34 35 |
from PIL import Image
import gradio as gr
from diffusers import LDMSuperResolutionPipeline
import torch
import keras
model_id = "CompVis/ldm-super-resolution-4x-openimages"
# load model and scheduler
pipeline = LDMSuperResolutionPipeline.from_pretrained(model_id)
#pipeline = pipeline.to(device)
# let's download an image
#url = "https://user-images.githubusercontent.com/38061659/199705896-b48e17b8-b231-47cd-a270-4ffa5a93fa3e.png"
#response = requests.get(url)
def infer(original_image):
#low_res_img = Image.open(BytesIO(response.content)).convert("RGB")
image = keras.utils.img_to_array(original_image)
image = image.astype("float32") / 255.0
image = np.expand_dims(image, axis=0)
# run pipeline in inference (sample random noise and denoise)
upscaled_image = pipeline(image, num_inference_steps=100, eta=1).images[0]
return upscaled_image
# save image
#upscaled_image.save("ldm_generated_image.png")
iface = gr.Interface(
fn=infer,
title="Enhancement Resolution",
description = "OpenCV implementation of Enhancement Resolution ππ",
inputs=[gr.inputs.Image(label="image", type="pil")],
outputs="image",
examples=examples,
cache_examples=True,
article = "Authors: <a href=\"https://github.com/Uviveknarayan\">Vivek Narayan</a>, <a href=\"https://github.com/chiranjan-7\">Chiranjan</a>,<a href=\"https://github.com/GangaSrujan\">Srujan</a>,<a href=\"https://github.com/RohanPawar3399\">Rohan Pawar</a>,<a href=\"https://github.com/pavankarthik77\">Pavan Karthik</a>").launch(enable_queue=True)
|