Spaces:
Running on Zero
Running on Zero
Upload 3 files
Browse files
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🖼🖼️📦
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 6.
|
| 8 |
python_version: "3.12"
|
| 9 |
app_file: app.py
|
| 10 |
license: mit
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.10.0
|
| 8 |
python_version: "3.12"
|
| 9 |
app_file: app.py
|
| 10 |
license: mit
|
dc.py
CHANGED
|
@@ -880,6 +880,13 @@ def get_gsd(repo_id, vae, task, controlnet_model):
|
|
| 880 |
return gsd
|
| 881 |
|
| 882 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 883 |
#@spaces.GPU
|
| 884 |
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps,
|
| 885 |
model_name=load_diffusers_format_model[0], lora1=None, lora1_wt=1.0, lora2=None, lora2_wt=1.0,
|
|
@@ -901,12 +908,15 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
| 901 |
gpu_duration=59, translate=False, recom_prompt=True, progress=gr.Progress(track_tqdm=True)):
|
| 902 |
MAX_SEED = np.iinfo(np.int32).max
|
| 903 |
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
|
|
|
|
|
|
|
|
|
|
| 910 |
style_prompt = None
|
| 911 |
style_json = None
|
| 912 |
hires_before_adetailer = False
|
|
|
|
| 880 |
return gsd
|
| 881 |
|
| 882 |
|
| 883 |
+
def _editor_first_layer(editor_value):
|
| 884 |
+
if not isinstance(editor_value, dict):
|
| 885 |
+
return None
|
| 886 |
+
layers = editor_value.get("layers") or []
|
| 887 |
+
return layers[0] if layers else None
|
| 888 |
+
|
| 889 |
+
|
| 890 |
#@spaces.GPU
|
| 891 |
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps,
|
| 892 |
model_name=load_diffusers_format_model[0], lora1=None, lora1_wt=1.0, lora2=None, lora2_wt=1.0,
|
|
|
|
| 908 |
gpu_duration=59, translate=False, recom_prompt=True, progress=gr.Progress(track_tqdm=True)):
|
| 909 |
MAX_SEED = np.iinfo(np.int32).max
|
| 910 |
|
| 911 |
+
if not image_mask:
|
| 912 |
+
image_mask = _editor_first_layer(image_control_dict)
|
| 913 |
+
image_control = image_control_dict.get('background') if isinstance(image_control_dict, dict) else None
|
| 914 |
+
if not mask_ip1:
|
| 915 |
+
mask_ip1 = _editor_first_layer(image_ip1_dict)
|
| 916 |
+
image_ip1 = image_ip1_dict.get('background') if isinstance(image_ip1_dict, dict) else None
|
| 917 |
+
if not mask_ip2:
|
| 918 |
+
mask_ip2 = _editor_first_layer(image_ip2_dict)
|
| 919 |
+
image_ip2 = image_ip2_dict.get('background') if isinstance(image_ip2_dict, dict) else None
|
| 920 |
style_prompt = None
|
| 921 |
style_json = None
|
| 922 |
hires_before_adetailer = False
|
utils.py
CHANGED
|
@@ -578,7 +578,12 @@ def create_mask_now(img, invert):
|
|
| 578 |
|
| 579 |
time.sleep(0.5)
|
| 580 |
|
| 581 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 582 |
|
| 583 |
# Extract the alpha channel
|
| 584 |
alpha_channel = np.array(transparent_image)[:, :, 3]
|
|
|
|
| 578 |
|
| 579 |
time.sleep(0.5)
|
| 580 |
|
| 581 |
+
layers = (img.get("layers") or []) if isinstance(img, dict) else []
|
| 582 |
+
if not layers:
|
| 583 |
+
background = img.get("background") if isinstance(img, dict) else None
|
| 584 |
+
return background, None
|
| 585 |
+
|
| 586 |
+
transparent_image = layers[0]
|
| 587 |
|
| 588 |
# Extract the alpha channel
|
| 589 |
alpha_channel = np.array(transparent_image)[:, :, 3]
|