Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -135,6 +135,11 @@ def infer_with_lora(input_image, prompt, selected_index, custom_lora, seed=42, r
|
|
135 |
"""Generate image with selected LoRA"""
|
136 |
global current_lora, pipe
|
137 |
|
|
|
|
|
|
|
|
|
|
|
138 |
if randomize_seed:
|
139 |
seed = random.randint(0, MAX_SEED)
|
140 |
|
@@ -167,8 +172,14 @@ def infer_with_lora(input_image, prompt, selected_index, custom_lora, seed=42, r
|
|
167 |
print(f"using already loaded lora: {lora_to_use}")
|
168 |
|
169 |
input_image = input_image.convert("RGB")
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
# Add trigger word to prompt
|
171 |
-
trigger_word = lora_to_use
|
172 |
if trigger_word == ", How2Draw":
|
173 |
prompt = f"create a How2Draw sketch of the person of the photo {prompt}, maintain the facial identity of the person and general features"
|
174 |
elif trigger_word == ", video game screenshot in the style of THSMS":
|
|
|
135 |
"""Generate image with selected LoRA"""
|
136 |
global current_lora, pipe
|
137 |
|
138 |
+
# Check if input image is provided
|
139 |
+
if input_image is None:
|
140 |
+
gr.Warning("Please upload an image first!")
|
141 |
+
return None, seed, gr.update(visible=False)
|
142 |
+
|
143 |
if randomize_seed:
|
144 |
seed = random.randint(0, MAX_SEED)
|
145 |
|
|
|
172 |
print(f"using already loaded lora: {lora_to_use}")
|
173 |
|
174 |
input_image = input_image.convert("RGB")
|
175 |
+
|
176 |
+
# Check if LoRA is selected
|
177 |
+
if lora_to_use is None:
|
178 |
+
gr.Warning("Please select a LoRA style from the gallery first!")
|
179 |
+
return None, seed, gr.update(visible=False)
|
180 |
+
|
181 |
# Add trigger word to prompt
|
182 |
+
trigger_word = lora_to_use.get("trigger_word", "")
|
183 |
if trigger_word == ", How2Draw":
|
184 |
prompt = f"create a How2Draw sketch of the person of the photo {prompt}, maintain the facial identity of the person and general features"
|
185 |
elif trigger_word == ", video game screenshot in the style of THSMS":
|