|
import gradio as gr |
|
import requests |
|
import numpy as np |
|
from PIL import Image |
|
|
|
def enlarge_image(image, scale): |
|
|
|
img_byte_arr = image.tobytes() |
|
|
|
response = requests.post("https://api.dall-e.com/v1/enlarge", |
|
data=img_byte_arr, |
|
params={"size": scale}) |
|
|
|
image_bytes = response.content |
|
|
|
img_np = np.array(Image.open(BytesIO(image_bytes))) |
|
return img_np |
|
|
|
|
|
input_image = gr.inputs.Image(label="Input Image") |
|
scale = gr.inputs.Number(label="Scale", default=2) |
|
output_image = gr.outputs.Image(label="Enlarged Image") |
|
|
|
title = "DALL-E 2 Image Enlarger" |
|
description = "Enlarges an image using DALL-E 2. Enter a scale factor and upload an image." |
|
examples = [["examples/butterfly.jpg"]] |
|
|
|
gr.Interface(fn=enlarge_image, inputs=[input_image, scale], outputs=output_image, |
|
title=title, description=description, examples=examples).launch() |
|
|