Spaces:
Running
on
Zero
Running
on
Zero
Alexander Bagus
commited on
Commit
Β·
0556062
1
Parent(s):
0486e7b
22
Browse files- README.md +1 -1
- app.py +14 -5
- static/header.html +3 -3
README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
---
|
| 2 |
title: Z-Image Turbo (ZIT) - Inpaint
|
| 3 |
emoji: π
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.1.0
|
|
|
|
| 1 |
---
|
| 2 |
title: Z-Image Turbo (ZIT) - Inpaint
|
| 3 |
emoji: π
|
| 4 |
+
colorFrom: red
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.1.0
|
app.py
CHANGED
|
@@ -16,6 +16,7 @@ repo_utils.move_folder("repos/VideoX-Fun/config", "config")
|
|
| 16 |
from videox_fun.pipeline import ZImageControlPipeline
|
| 17 |
from videox_fun.models import ZImageControlTransformer2DModel
|
| 18 |
from videox_fun.utils.utils import get_image_latent
|
|
|
|
| 19 |
|
| 20 |
#clone models
|
| 21 |
repo_utils.clone_repo_if_not_exists("https://huggingface.co/Tongyi-MAI/Z-Image-Turbo", "models")
|
|
@@ -122,13 +123,13 @@ def inference(
|
|
| 122 |
return None
|
| 123 |
|
| 124 |
# rescale to prevent OOM
|
| 125 |
-
|
| 126 |
-
|
| 127 |
sample_size = [height, width]
|
| 128 |
|
| 129 |
print("DEBUG: control_image_torch")
|
| 130 |
-
if
|
| 131 |
-
inpaint_image = get_image_latent(
|
| 132 |
else:
|
| 133 |
inpaint_image = torch.zeros([1, 3, sample_size[0], sample_size[1]])
|
| 134 |
|
|
@@ -138,6 +139,14 @@ def inference(
|
|
| 138 |
else:
|
| 139 |
mask_image = torch.ones([1, 1, sample_size[0], sample_size[1]]) * 255
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
# generation
|
| 142 |
if randomize_seed: seed = random.randint(0, MAX_SEED)
|
| 143 |
generator = torch.Generator().manual_seed(seed)
|
|
@@ -151,7 +160,7 @@ def inference(
|
|
| 151 |
guidance_scale=guidance_scale,
|
| 152 |
image = inpaint_image,
|
| 153 |
mask_image = mask_image,
|
| 154 |
-
|
| 155 |
num_inference_steps=num_inference_steps,
|
| 156 |
control_context_scale=control_context_scale,
|
| 157 |
).images[0]
|
|
|
|
| 16 |
from videox_fun.pipeline import ZImageControlPipeline
|
| 17 |
from videox_fun.models import ZImageControlTransformer2DModel
|
| 18 |
from videox_fun.utils.utils import get_image_latent
|
| 19 |
+
from controlnet_aux.processor import Processor
|
| 20 |
|
| 21 |
#clone models
|
| 22 |
repo_utils.clone_repo_if_not_exists("https://huggingface.co/Tongyi-MAI/Z-Image-Turbo", "models")
|
|
|
|
| 123 |
return None
|
| 124 |
|
| 125 |
# rescale to prevent OOM
|
| 126 |
+
input_image = edit_dict['background']
|
| 127 |
+
input_image, width, height = image_utils.rescale_image(inpaint_image, 1, 8, max_size=1280)
|
| 128 |
sample_size = [height, width]
|
| 129 |
|
| 130 |
print("DEBUG: control_image_torch")
|
| 131 |
+
if input_image is not None:
|
| 132 |
+
inpaint_image = get_image_latent(input_image, sample_size=sample_size)[:, :, 0]
|
| 133 |
else:
|
| 134 |
inpaint_image = torch.zeros([1, 3, sample_size[0], sample_size[1]])
|
| 135 |
|
|
|
|
| 139 |
else:
|
| 140 |
mask_image = torch.ones([1, 1, sample_size[0], sample_size[1]]) * 255
|
| 141 |
|
| 142 |
+
print("DEBUG: control_image_torch")
|
| 143 |
+
processor = Processor('canny')
|
| 144 |
+
control_image, w, h = image_utils.rescale_image(input_image, 1, 8, max_size=1280)
|
| 145 |
+
control_image = control_image.resize((1024, 1024))
|
| 146 |
+
control_image = processor(control_image, to_pil=True)
|
| 147 |
+
control_image = control_image.resize((width, height))
|
| 148 |
+
control_image_torch = get_image_latent(control_image, sample_size=sample_size)[:, :, 0]
|
| 149 |
+
|
| 150 |
# generation
|
| 151 |
if randomize_seed: seed = random.randint(0, MAX_SEED)
|
| 152 |
generator = torch.Generator().manual_seed(seed)
|
|
|
|
| 160 |
guidance_scale=guidance_scale,
|
| 161 |
image = inpaint_image,
|
| 162 |
mask_image = mask_image,
|
| 163 |
+
control_image=control_image_torch,
|
| 164 |
num_inference_steps=num_inference_steps,
|
| 165 |
control_context_scale=control_context_scale,
|
| 166 |
).images[0]
|
static/header.html
CHANGED
|
@@ -4,9 +4,9 @@
|
|
| 4 |
</h1>
|
| 5 |
<div class="grid-container" >
|
| 6 |
<p>
|
| 7 |
-
This space still in development, there will be some errors. Please be patient and check again later π
|
| 8 |
-
<br>
|
| 9 |
-
|
| 10 |
<br>
|
| 11 |
If you like my work, please support me by visiting <a href="https://aisudo.com/" target="_blank">AiSudo</a> π
|
| 12 |
</div>
|
|
|
|
| 4 |
</h1>
|
| 5 |
<div class="grid-container" >
|
| 6 |
<p>
|
| 7 |
+
<!-- This space still in development, there will be some errors. Please be patient and check again later π
|
| 8 |
+
<br> -->
|
| 9 |
+
Transform your pictures by simply applying a mask and providing a text prompt.
|
| 10 |
<br>
|
| 11 |
If you like my work, please support me by visiting <a href="https://aisudo.com/" target="_blank">AiSudo</a> π
|
| 12 |
</div>
|