Spaces:
Running
Running
cocktailpeanut
commited on
Commit
•
8ed81aa
1
Parent(s):
53c30dc
update
Browse files- gradio_demo/app.py +19 -11
gradio_demo/app.py
CHANGED
@@ -13,6 +13,7 @@ from schedulers.lcm_single_step_scheduler import LCMSingleStepScheduler
|
|
13 |
|
14 |
from module.ip_adapter.utils import load_adapter_to_pipe
|
15 |
from pipelines.sdxl_instantir import InstantIRPipeline
|
|
|
16 |
|
17 |
def resize_img(input_image, max_side=1280, min_side=1024, size=None,
|
18 |
pad_to_max_side=False, mode=Image.BILINEAR, base_pixel_number=64):
|
@@ -170,6 +171,12 @@ def instantir_restore(
|
|
170 |
)
|
171 |
for i, preview_img in enumerate(out[1]):
|
172 |
preview_img.append(f"preview_{i}")
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
return out[0][0], out[1]
|
174 |
|
175 |
examples = [
|
@@ -186,17 +193,18 @@ css="""
|
|
186 |
"""
|
187 |
|
188 |
with gr.Blocks() as demo:
|
189 |
-
gr.
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
200 |
with gr.Row():
|
201 |
with gr.Column():
|
202 |
lq_img = gr.Image(label="Low-quality image", type="pil")
|
|
|
13 |
|
14 |
from module.ip_adapter.utils import load_adapter_to_pipe
|
15 |
from pipelines.sdxl_instantir import InstantIRPipeline
|
16 |
+
import gc
|
17 |
|
18 |
def resize_img(input_image, max_side=1280, min_side=1024, size=None,
|
19 |
pad_to_max_side=False, mode=Image.BILINEAR, base_pixel_number=64):
|
|
|
171 |
)
|
172 |
for i, preview_img in enumerate(out[1]):
|
173 |
preview_img.append(f"preview_{i}")
|
174 |
+
|
175 |
+
gc.collect()
|
176 |
+
if torch.cuda.is_available():
|
177 |
+
torch.cuda.empty_cache()
|
178 |
+
elif torch.backends.mps.is_available():
|
179 |
+
torch.mps.empty_cache()
|
180 |
return out[0][0], out[1]
|
181 |
|
182 |
examples = [
|
|
|
193 |
"""
|
194 |
|
195 |
with gr.Blocks() as demo:
|
196 |
+
with gr.Accordion("More info"):
|
197 |
+
gr.Markdown(
|
198 |
+
"""
|
199 |
+
# InstantIR: Blind Image Restoration with Instant Generative Reference.
|
200 |
+
|
201 |
+
### **Official 🤗 Gradio demo of [InstantIR](https://arxiv.org/abs/2410.06551).**
|
202 |
+
### **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!**
|
203 |
+
## Basic usage: revitalize your image
|
204 |
+
1. Upload an image you want to restore;
|
205 |
+
2. Optionally, tune the `Steps` `CFG Scale` parameters. Typically higher steps lead to better results, but less than 50 is recommended for efficiency;
|
206 |
+
3. Click `InstantIR magic!`.
|
207 |
+
""")
|
208 |
with gr.Row():
|
209 |
with gr.Column():
|
210 |
lq_img = gr.Image(label="Low-quality image", type="pil")
|