Spaces:
Running on Zero
Running on Zero
mfn commited on
Commit ·
21ab6b2
1
Parent(s): c2ca5fe
Fix Moebius input sizing
Browse files
app.py
CHANGED
|
@@ -31,6 +31,14 @@ CHECKPOINTS = {
|
|
| 31 |
}
|
| 32 |
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
def _ensure_weights() -> None:
|
| 35 |
moebius_path = Path(
|
| 36 |
snapshot_download(
|
|
@@ -126,6 +134,7 @@ def inpaint(
|
|
| 126 |
noise_offset,
|
| 127 |
):
|
| 128 |
image, mask = _editor_to_image_and_mask(editor_value)
|
|
|
|
| 129 |
pipe = PIPELINES[checkpoint_label]
|
| 130 |
result = pipe(
|
| 131 |
[image],
|
|
@@ -146,12 +155,7 @@ def inpaint(
|
|
| 146 |
return output.name
|
| 147 |
|
| 148 |
|
| 149 |
-
|
| 150 |
-
.footer-link { text-align: center; margin-top: 1.5rem; }
|
| 151 |
-
"""
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
with gr.Blocks(title="Moebius Inpainting", css=CSS) as demo:
|
| 155 |
gr.Markdown("# Moebius Inpainting")
|
| 156 |
gr.Markdown(f"[Model on Hugging Face](https://huggingface.co/{MODEL_ID})")
|
| 157 |
|
|
@@ -201,9 +205,7 @@ with gr.Blocks(title="Moebius Inpainting", css=CSS) as demo:
|
|
| 201 |
outputs=output,
|
| 202 |
)
|
| 203 |
|
| 204 |
-
gr.Markdown(
|
| 205 |
-
'<div class="footer-link"><a href="https://x.com/realmrfakename">Twitter / X</a></div>'
|
| 206 |
-
)
|
| 207 |
|
| 208 |
|
| 209 |
if __name__ == "__main__":
|
|
|
|
| 31 |
}
|
| 32 |
|
| 33 |
|
| 34 |
+
def _resize_for_model(image: Image.Image, mask: Image.Image, image_size: int):
|
| 35 |
+
target_size = (int(image_size), int(image_size))
|
| 36 |
+
return (
|
| 37 |
+
image.resize(target_size, Image.Resampling.LANCZOS),
|
| 38 |
+
mask.resize(target_size, Image.Resampling.NEAREST),
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
def _ensure_weights() -> None:
|
| 43 |
moebius_path = Path(
|
| 44 |
snapshot_download(
|
|
|
|
| 134 |
noise_offset,
|
| 135 |
):
|
| 136 |
image, mask = _editor_to_image_and_mask(editor_value)
|
| 137 |
+
image, mask = _resize_for_model(image, mask, int(image_size))
|
| 138 |
pipe = PIPELINES[checkpoint_label]
|
| 139 |
result = pipe(
|
| 140 |
[image],
|
|
|
|
| 155 |
return output.name
|
| 156 |
|
| 157 |
|
| 158 |
+
with gr.Blocks(title="Moebius Inpainting") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
gr.Markdown("# Moebius Inpainting")
|
| 160 |
gr.Markdown(f"[Model on Hugging Face](https://huggingface.co/{MODEL_ID})")
|
| 161 |
|
|
|
|
| 205 |
outputs=output,
|
| 206 |
)
|
| 207 |
|
| 208 |
+
gr.Markdown("[Twitter / X](https://x.com/realmrfakename)")
|
|
|
|
|
|
|
| 209 |
|
| 210 |
|
| 211 |
if __name__ == "__main__":
|