Spaces:
Configuration error
Configuration error
fix preview start
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import os
|
| 2 |
-
print(os.listdir('examples'))
|
| 3 |
|
| 4 |
import random
|
| 5 |
import torch
|
|
@@ -8,7 +7,6 @@ import spaces
|
|
| 8 |
import numpy as np
|
| 9 |
import gradio as gr
|
| 10 |
from PIL import Image
|
| 11 |
-
Image.open("examples/wukong.png")
|
| 12 |
|
| 13 |
from diffusers import DDPMScheduler
|
| 14 |
from schedulers.lcm_single_step_scheduler import LCMSingleStepScheduler
|
|
@@ -131,8 +129,8 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
| 131 |
def unpack_pipe_out(preview_row, index):
|
| 132 |
return preview_row[index][0]
|
| 133 |
|
| 134 |
-
def dynamic_preview_slider(
|
| 135 |
-
return gr.Slider(label="Restoration Previews", value=
|
| 136 |
|
| 137 |
def dynamic_guidance_slider(sampling_steps):
|
| 138 |
return gr.Slider(label="Start Free Rendering", value=sampling_steps, minimum=0, maximum=sampling_steps, step=1)
|
|
@@ -206,8 +204,8 @@ with gr.Blocks() as demo:
|
|
| 206 |
### **InstantIR can not only help you restore your broken image, but also capable of imaginative re-creation following your text prompts. See advance usage for more details!**
|
| 207 |
## Basic usage: revitalize your image
|
| 208 |
1. Upload an image you want to restore;
|
| 209 |
-
2. By default InstantIR will restore your image at original size, you can change output size by setting `Height` and `Width
|
| 210 |
-
3. Optionally, tune the `Steps` `CFG Scale` parameters. Typically higher steps lead to better results
|
| 211 |
4. Click `InstantIR magic!`.
|
| 212 |
""")
|
| 213 |
with gr.Row():
|
|
@@ -248,7 +246,7 @@ with gr.Blocks() as demo:
|
|
| 248 |
outputs=[output, pipe_out], api_name="InstantIR"
|
| 249 |
)
|
| 250 |
steps.change(dynamic_guidance_slider, inputs=steps, outputs=guidance_end)
|
| 251 |
-
output.change(dynamic_preview_slider, inputs=
|
| 252 |
index.release(unpack_pipe_out, inputs=[pipe_out, index], outputs=preview)
|
| 253 |
output.change(show_final_preview, inputs=pipe_out, outputs=preview)
|
| 254 |
gr.Markdown(
|
|
@@ -261,6 +259,8 @@ with gr.Blocks() as demo:
|
|
| 261 |
1. Check the `Creative Restoration` checkbox;
|
| 262 |
2. Input your text prompts in the `Restoration prompts` textbox;
|
| 263 |
3. Set `Start Free Rendering` slider to a medium value (around half of the `steps`) to provide adequate room for InstantIR creation.
|
|
|
|
|
|
|
| 264 |
""")
|
| 265 |
gr.Markdown(
|
| 266 |
"""
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
|
| 3 |
import random
|
| 4 |
import torch
|
|
|
|
| 7 |
import numpy as np
|
| 8 |
import gradio as gr
|
| 9 |
from PIL import Image
|
|
|
|
| 10 |
|
| 11 |
from diffusers import DDPMScheduler
|
| 12 |
from schedulers.lcm_single_step_scheduler import LCMSingleStepScheduler
|
|
|
|
| 129 |
def unpack_pipe_out(preview_row, index):
|
| 130 |
return preview_row[index][0]
|
| 131 |
|
| 132 |
+
def dynamic_preview_slider(preview_row):
|
| 133 |
+
return gr.Slider(label="Restoration Previews", value=len(preview_row)-1, minimum=0, maximum=len(preview_row)-1, step=1)
|
| 134 |
|
| 135 |
def dynamic_guidance_slider(sampling_steps):
|
| 136 |
return gr.Slider(label="Start Free Rendering", value=sampling_steps, minimum=0, maximum=sampling_steps, step=1)
|
|
|
|
| 204 |
### **InstantIR can not only help you restore your broken image, but also capable of imaginative re-creation following your text prompts. See advance usage for more details!**
|
| 205 |
## Basic usage: revitalize your image
|
| 206 |
1. Upload an image you want to restore;
|
| 207 |
+
2. By default InstantIR will restore your image at original size, you can change output size by setting `Height` and `Width`, and set to `0` to keep original size;
|
| 208 |
+
3. Optionally, tune the `Steps` `CFG Scale` parameters. Typically higher steps lead to better results. We recommend values between 30-50 for a balanced quality and speed;
|
| 209 |
4. Click `InstantIR magic!`.
|
| 210 |
""")
|
| 211 |
with gr.Row():
|
|
|
|
| 246 |
outputs=[output, pipe_out], api_name="InstantIR"
|
| 247 |
)
|
| 248 |
steps.change(dynamic_guidance_slider, inputs=steps, outputs=guidance_end)
|
| 249 |
+
output.change(dynamic_preview_slider, inputs=pipe_out, outputs=index)
|
| 250 |
index.release(unpack_pipe_out, inputs=[pipe_out, index], outputs=preview)
|
| 251 |
output.change(show_final_preview, inputs=pipe_out, outputs=preview)
|
| 252 |
gr.Markdown(
|
|
|
|
| 259 |
1. Check the `Creative Restoration` checkbox;
|
| 260 |
2. Input your text prompts in the `Restoration prompts` textbox;
|
| 261 |
3. Set `Start Free Rendering` slider to a medium value (around half of the `steps`) to provide adequate room for InstantIR creation.
|
| 262 |
+
### Fidelity enhancement:
|
| 263 |
+
If you find the output deviate from the original input, try to slightly increase `Preview Start`. To ensure quality, we recommend not exceeding half of `steps`.
|
| 264 |
""")
|
| 265 |
gr.Markdown(
|
| 266 |
"""
|