Spaces:
Running
on
Zero
Running
on
Zero
gokaygokay
commited on
Commit
•
0022789
1
Parent(s):
c975ceb
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from gradio_imageslider import ImageSlider
|
3 |
+
|
4 |
+
from PIL import Image
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
from aura_sr import AuraSR
|
8 |
+
import spaces
|
9 |
+
|
10 |
+
# Load the AuraSR model
|
11 |
+
aura_sr = AuraSR.from_pretrained("fal-ai/AuraSR")
|
12 |
+
|
13 |
+
@spaces.GPU
|
14 |
+
def process_image(input_image):
|
15 |
+
if input_image is None:
|
16 |
+
return None
|
17 |
+
|
18 |
+
# Resize input image to 256x256
|
19 |
+
input_image = Image.fromarray(input_array).resize((256, 256))
|
20 |
+
|
21 |
+
# Upscale the image using AuraSR
|
22 |
+
upscaled_image = aura_sr.upscale_4x(input_image)
|
23 |
+
|
24 |
+
# Convert result to numpy array
|
25 |
+
result_array = np.array(upscaled_image)
|
26 |
+
|
27 |
+
return [input_array, result_array]
|
28 |
+
|
29 |
+
with gr.Blocks() as demo:
|
30 |
+
gr.Markdown("# Image Upscaler using AuraSR")
|
31 |
+
with gr.Row():
|
32 |
+
with gr.Column(scale=1):
|
33 |
+
input_image = gr.Image(label="Input Image", type="pil")
|
34 |
+
process_btn = gr.Button("Upscale Image")
|
35 |
+
with gr.Column(scale=1):
|
36 |
+
output_slider = ImageSlider(label="Before / After", type="numpy")
|
37 |
+
|
38 |
+
process_btn.click(
|
39 |
+
fn=process_image,
|
40 |
+
inputs=[input_image],
|
41 |
+
outputs=output_slider
|
42 |
+
)
|
43 |
+
|
44 |
+
demo.launch(debug=True)
|