Spaces:
Runtime error
Runtime error
unable to fix KeyError: 'input_components' when loading interface.
Browse files
app.py
CHANGED
@@ -1,21 +1,4 @@
|
|
1 |
# %%
|
2 |
-
import os
|
3 |
-
|
4 |
-
from PIL import Image
|
5 |
-
|
6 |
-
os.system('wget https://github.com/JingyunLiang/SwinIR/releases/download/v0.0/003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth -P experiments/pretrained_models')
|
7 |
-
|
8 |
-
def super_resolution_inference(img_path):
|
9 |
-
os.system('mkdir test')
|
10 |
-
basewidth = 256
|
11 |
-
img = Image.open(open(img_path, 'rb'))
|
12 |
-
wpercent = (basewidth/float(img.size[0]))
|
13 |
-
hsize = int((float(img.size[1])*float(wpercent)))
|
14 |
-
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
|
15 |
-
img.save("test/1.jpg", "JPEG")
|
16 |
-
os.system('python main_test_swinir.py --task real_sr --model_path experiments/pretrained_models/003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth --folder_lq test --scale 4')
|
17 |
-
return 'results/swinir_real_sr_x4/1_SwinIR.png'
|
18 |
-
# %%
|
19 |
import gradio as gr
|
20 |
|
21 |
example_generated_ape_super = "examples/generated_ape_super_resolution.jpg"
|
@@ -31,7 +14,6 @@ examples = [
|
|
31 |
|
32 |
ape_gen = gr.Interface.load("spaces/ykilcher/apes")
|
33 |
super_resolution = gr.Interface.load("spaces/akhaliq/SwinIR")
|
34 |
-
# super_resolution = super_resolution_inference
|
35 |
style_transfer = gr.Interface.load("spaces/aravinds1811/neural-style-transfer")
|
36 |
|
37 |
def generate_ape(num_images=1, interpolate=False):
|
@@ -46,12 +28,12 @@ def perform_style_transfer(content_image, style_image, is_super_resolution=False
|
|
46 |
# %%
|
47 |
with gr.Blocks() as demo:
|
48 |
button_generate_ape = gr.Button("Generate Ape")
|
49 |
-
|
50 |
generated_ape = gr.Image(example_generated_ape, label="Generated Ape", type="filepath")
|
51 |
-
style_image_input = gr.Image(example_style_starry_night, label="Stylish Image")
|
52 |
style_in_super_resolution = gr.Checkbox(True, label="Super resolution!")
|
53 |
stylish_ape = gr.Image(example_stylish_ape, label="Stylish Ape")
|
54 |
-
|
55 |
gr.Interface(
|
56 |
fn=perform_style_transfer,
|
57 |
inputs=[generated_ape, style_image_input, style_in_super_resolution],
|
@@ -66,5 +48,5 @@ with gr.Blocks() as demo:
|
|
66 |
|
67 |
button_generate_ape.click(generate_ape, inputs=[], outputs=generated_ape)
|
68 |
|
69 |
-
demo.launch(enable_queue=False
|
70 |
-
# %%
|
|
|
1 |
# %%
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
example_generated_ape_super = "examples/generated_ape_super_resolution.jpg"
|
|
|
14 |
|
15 |
ape_gen = gr.Interface.load("spaces/ykilcher/apes")
|
16 |
super_resolution = gr.Interface.load("spaces/akhaliq/SwinIR")
|
|
|
17 |
style_transfer = gr.Interface.load("spaces/aravinds1811/neural-style-transfer")
|
18 |
|
19 |
def generate_ape(num_images=1, interpolate=False):
|
|
|
28 |
# %%
|
29 |
with gr.Blocks() as demo:
|
30 |
button_generate_ape = gr.Button("Generate Ape")
|
31 |
+
|
32 |
generated_ape = gr.Image(example_generated_ape, label="Generated Ape", type="filepath")
|
33 |
+
style_image_input = gr.Image(example_style_starry_night, label="Stylish Image", type="filepath")
|
34 |
style_in_super_resolution = gr.Checkbox(True, label="Super resolution!")
|
35 |
stylish_ape = gr.Image(example_stylish_ape, label="Stylish Ape")
|
36 |
+
|
37 |
gr.Interface(
|
38 |
fn=perform_style_transfer,
|
39 |
inputs=[generated_ape, style_image_input, style_in_super_resolution],
|
|
|
48 |
|
49 |
button_generate_ape.click(generate_ape, inputs=[], outputs=generated_ape)
|
50 |
|
51 |
+
demo.launch(enable_queue=False)
|
52 |
+
# %%
|