Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,16 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
import numpy as np
|
| 4 |
-
from PIL import Image
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
img_byte_arr = image.tobytes()
|
| 9 |
-
# make request to DALL-E 2 API
|
| 10 |
-
response = requests.post("https://api.dall-e.com/v1/enlarge",
|
| 11 |
-
data=img_byte_arr,
|
| 12 |
-
params={"size": scale})
|
| 13 |
-
# get the image bytes from the response
|
| 14 |
-
image_bytes = response.content
|
| 15 |
-
# convert bytes to numpy array
|
| 16 |
-
img_np = np.array(Image.open(BytesIO(image_bytes)))
|
| 17 |
-
return img_np
|
| 18 |
|
| 19 |
-
# create the Gradio interface
|
| 20 |
-
input_image = gr.inputs.Image(label="Input Image")
|
| 21 |
-
scale = gr.inputs.Number(label="Scale", default=2)
|
| 22 |
-
output_image = gr.outputs.Image(label="Enlarged Image")
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
gr.Interface(
|
| 29 |
-
title=title, description=description, examples=examples).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
model_name = "waifu2x-multi-lang"
|
| 5 |
+
waifu2x = pipeline("image-upscaling", model=model_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
def waifu2x_enlarge(input_image):
|
| 9 |
+
output_image = waifu2x(input_image)
|
| 10 |
+
return output_image
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
input_image = gr.inputs.Image(label="Input Image")
|
| 14 |
+
output_image = gr.outputs.Image(label="Enlarged Image", type="numpy")
|
| 15 |
|
| 16 |
+
gr.Interface(waifu2x_enlarge, input_image, output_image).launch()
|
|
|