Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -33,6 +33,7 @@ def load_tags(active_tab):
|
|
33 |
|
34 |
return tags_module
|
35 |
|
|
|
36 |
@spaces.GPU
|
37 |
def infer(
|
38 |
prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps,
|
@@ -61,25 +62,44 @@ def infer(
|
|
61 |
camera_tags = tags_module.camera_tags
|
62 |
atmosphere_tags = tags_module.atmosphere_tags
|
63 |
|
64 |
-
#
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
[body_type_tags[tag] for tag in selected_body_type_tags] +
|
71 |
-
[tattoo_tags[tag] for tag in selected_tattoo_tags] +
|
72 |
-
[piercing_tags[tag] for tag in selected_piercing_tags] +
|
73 |
-
[expression_tags[tag] for tag in selected_expression_tags] +
|
74 |
-
[eye_tags[tag] for tag in selected_eye_tags] +
|
75 |
-
[hair_style_tags[tag] for tag in selected_hair_style_tags] +
|
76 |
-
[position_tags[tag] for tag in selected_position_tags] +
|
77 |
-
[fetish_tags[tag] for tag in selected_fetish_tags] +
|
78 |
-
[location_tags[tag] for tag in selected_location_tags] +
|
79 |
-
[camera_tags[tag] for tag in selected_camera_tags] +
|
80 |
-
[atmosphere_tags[tag] for tag in selected_atmosphere_tags]
|
81 |
-
)
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
final_prompt = f"score_9, score_8_up, score_7_up, source_anime, {', '.join(tag_list)}"
|
84 |
|
85 |
# Concatenate additional negative prompts
|
@@ -90,6 +110,9 @@ def infer(
|
|
90 |
seed = random.randint(0, MAX_SEED)
|
91 |
generator = torch.Generator(device=device).manual_seed(seed)
|
92 |
|
|
|
|
|
|
|
93 |
image = pipe(
|
94 |
prompt=final_prompt,
|
95 |
negative_prompt=full_negative_prompt,
|
@@ -100,8 +123,12 @@ def infer(
|
|
100 |
generator=generator
|
101 |
).images[0]
|
102 |
|
|
|
|
|
|
|
103 |
return image, seed, f"Prompt: {final_prompt}\nNegative Prompt: {full_negative_prompt}"
|
104 |
|
|
|
105 |
# CSS for the layout
|
106 |
css = """
|
107 |
#col-container {
|
|
|
33 |
|
34 |
return tags_module
|
35 |
|
36 |
+
@spaces.GPU
|
37 |
@spaces.GPU
|
38 |
def infer(
|
39 |
prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps,
|
|
|
62 |
camera_tags = tags_module.camera_tags
|
63 |
atmosphere_tags = tags_module.atmosphere_tags
|
64 |
|
65 |
+
# Debug: Check if the tag modules are loaded correctly
|
66 |
+
print(f"Loaded tags for {active_tab}:")
|
67 |
+
print(f"participant_tags: {list(participant_tags.keys())}")
|
68 |
+
print(f"tribe_tags: {list(tribe_tags.keys())}")
|
69 |
+
print(f"role_tags: {list(role_tags.keys())}")
|
70 |
+
print(f"skin_tone_tags: {list(skin_tone_tags.keys())}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
+
# Handle the active tab and generate the prompt accordingly
|
73 |
+
tag_list = []
|
74 |
+
|
75 |
+
# Dynamically build tag list based on selected checkboxes
|
76 |
+
for tag_list_group, selected_tags in [
|
77 |
+
(participant_tags, selected_participant_tags),
|
78 |
+
(tribe_tags, selected_tribe_tags),
|
79 |
+
(role_tags, selected_role_tags),
|
80 |
+
(skin_tone_tags, selected_skin_tone_tags),
|
81 |
+
(body_type_tags, selected_body_type_tags),
|
82 |
+
(tattoo_tags, selected_tattoo_tags),
|
83 |
+
(piercing_tags, selected_piercing_tags),
|
84 |
+
(expression_tags, selected_expression_tags),
|
85 |
+
(eye_tags, selected_eye_tags),
|
86 |
+
(hair_style_tags, selected_hair_style_tags),
|
87 |
+
(position_tags, selected_position_tags),
|
88 |
+
(fetish_tags, selected_fetish_tags),
|
89 |
+
(location_tags, selected_location_tags),
|
90 |
+
(camera_tags, selected_camera_tags),
|
91 |
+
(atmosphere_tags, selected_atmosphere_tags)
|
92 |
+
]:
|
93 |
+
# Add the selected tags for this category
|
94 |
+
for tag in selected_tags:
|
95 |
+
if tag in tag_list_group:
|
96 |
+
tag_list.append(tag_list_group[tag])
|
97 |
+
else:
|
98 |
+
print(f"Tag '{tag}' not found in {tag_list_group}")
|
99 |
+
|
100 |
+
# Debug: Print the final prompt that is being generated
|
101 |
+
print(f"Final Prompt: {final_prompt}")
|
102 |
+
|
103 |
final_prompt = f"score_9, score_8_up, score_7_up, source_anime, {', '.join(tag_list)}"
|
104 |
|
105 |
# Concatenate additional negative prompts
|
|
|
110 |
seed = random.randint(0, MAX_SEED)
|
111 |
generator = torch.Generator(device=device).manual_seed(seed)
|
112 |
|
113 |
+
# Debug: Ensure the final negative prompt is correct
|
114 |
+
print(f"Negative Prompt: {full_negative_prompt}")
|
115 |
+
|
116 |
image = pipe(
|
117 |
prompt=final_prompt,
|
118 |
negative_prompt=full_negative_prompt,
|
|
|
123 |
generator=generator
|
124 |
).images[0]
|
125 |
|
126 |
+
# Debug: Confirm the seed and image generation
|
127 |
+
print(f"Seed used for generation: {seed}")
|
128 |
+
|
129 |
return image, seed, f"Prompt: {final_prompt}\nNegative Prompt: {full_negative_prompt}"
|
130 |
|
131 |
+
|
132 |
# CSS for the layout
|
133 |
css = """
|
134 |
#col-container {
|