Spaces:
Running
on
Zero
Running
on
Zero
shuanholmes
commited on
Commit
·
03e3d16
1
Parent(s):
3489c30
[FireFlow] Fix OOM
Browse files
app.py
CHANGED
|
@@ -65,6 +65,20 @@ def edit(init_image, source_prompt, target_prompt, editing_strategy, num_steps,
|
|
| 65 |
torch.cuda.empty_cache()
|
| 66 |
seed = None
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
shape = init_image.shape
|
| 69 |
|
| 70 |
new_h = shape[0] if shape[0] % 16 == 0 else shape[0] - shape[0] % 16
|
|
@@ -193,8 +207,12 @@ def create_demo(model_name: str, device: str = "cuda:0" if torch.cuda.is_availab
|
|
| 193 |
<h1 align="center">🔥FireFlow: Fast Inversion of Rectified Flow for Image Semantic Editing</h1>
|
| 194 |
"""
|
| 195 |
description = r"""
|
| 196 |
-
<
|
| 197 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
"""
|
| 199 |
article = r"""
|
| 200 |
If you find our work helpful, we would greatly appreciate it if you could ⭐ our <a href='https://github.com/HolmesShuan/FireFlow-Fast-Inversion-of-Rectified-Flow-for-Image-Semantic-Editing' target='_blank'>GitHub repository</a>. Thank you for your support!
|
|
|
|
| 65 |
torch.cuda.empty_cache()
|
| 66 |
seed = None
|
| 67 |
|
| 68 |
+
pil_img = Image.fromarray(init_image)
|
| 69 |
+
width, height = pil_img.size
|
| 70 |
+
if max(width, height) > 1024:
|
| 71 |
+
if height > width:
|
| 72 |
+
new_height = 1024
|
| 73 |
+
new_width = int((new_height / height) * width)
|
| 74 |
+
else:
|
| 75 |
+
new_width = 1024
|
| 76 |
+
new_height = int((new_width / width) * height)
|
| 77 |
+
|
| 78 |
+
pil_img = pil_img.resize((new_width, new_height))
|
| 79 |
+
init_image = np.array(pil_img)
|
| 80 |
+
print('[INFO] resize large image to [1024, X].')
|
| 81 |
+
|
| 82 |
shape = init_image.shape
|
| 83 |
|
| 84 |
new_h = shape[0] if shape[0] % 16 == 0 else shape[0] - shape[0] % 16
|
|
|
|
| 207 |
<h1 align="center">🔥FireFlow: Fast Inversion of Rectified Flow for Image Semantic Editing</h1>
|
| 208 |
"""
|
| 209 |
description = r"""
|
| 210 |
+
<h3>Tips 🔔:</h3>
|
| 211 |
+
<ol>
|
| 212 |
+
<li>We automatically resize images larger than 1024x1024 by scaling the longer edge to 1024 to prevent out-of-memory errors. Larger image is 🆗.</li>
|
| 213 |
+
<li>If the results are not satisfactory, consider slightly increasing the total number of timesteps 📈. </li>
|
| 214 |
+
<li>Each editing technique produces distinct effects, so feel free to experiment and explore their possibilities 🎨 !. </li>
|
| 215 |
+
</ol>
|
| 216 |
"""
|
| 217 |
article = r"""
|
| 218 |
If you find our work helpful, we would greatly appreciate it if you could ⭐ our <a href='https://github.com/HolmesShuan/FireFlow-Fast-Inversion-of-Rectified-Flow-for-Image-Semantic-Editing' target='_blank'>GitHub repository</a>. Thank you for your support!
|