Spaces:
Running
on
Zero
Running
on
Zero
Update app_v4.py
Browse files
app_v4.py
CHANGED
@@ -149,46 +149,40 @@ def generate_image(prompt, scale, steps, control_image, controlnet_conditioning_
|
|
149 |
|
150 |
def process_image(control_image, user_prompt, system_prompt, scale, steps,
|
151 |
controlnet_conditioning_scale, guidance_scale, seed,
|
152 |
-
guidance_end, temperature, top_p, max_new_tokens, log_prompt
|
153 |
# Initialize with empty caption
|
154 |
final_prompt = user_prompt.strip()
|
155 |
# If no user prompt provided, generate a caption first
|
156 |
if not final_prompt:
|
157 |
# Generate a detailed caption
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
with progress:
|
167 |
-
progress(0.3, "Generating with prompt...")
|
168 |
-
yield f"Generating with: {final_prompt}", None, final_prompt
|
169 |
-
|
170 |
# Generate the image
|
171 |
try:
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
guidance_end=guidance_end
|
183 |
-
)
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
except Exception as e:
|
193 |
print("Error: " + str(e))
|
194 |
yield f"Error: {str(e)}", None, None
|
@@ -285,7 +279,7 @@ with gr.Blocks(title="FLUX Turbo Upscaler", fill_height=True) as demo:
|
|
285 |
inputs=[
|
286 |
control_image, prompt, system_prompt, scale, steps,
|
287 |
controlnet_conditioning_scale, guidance_scale, seed,
|
288 |
-
guidance_end, temperature_slider, top_p_slider, max_tokens_slider, log_prompt
|
289 |
],
|
290 |
outputs=[log_state, generated_image, prompt]
|
291 |
)
|
|
|
149 |
|
150 |
def process_image(control_image, user_prompt, system_prompt, scale, steps,
|
151 |
controlnet_conditioning_scale, guidance_scale, seed,
|
152 |
+
guidance_end, temperature, top_p, max_new_tokens, log_prompt):
|
153 |
# Initialize with empty caption
|
154 |
final_prompt = user_prompt.strip()
|
155 |
# If no user prompt provided, generate a caption first
|
156 |
if not final_prompt:
|
157 |
# Generate a detailed caption
|
158 |
+
|
159 |
+
mcaption = model.caption(control_image, length="normal")
|
160 |
+
detailed_caption = mcaption["caption"]
|
161 |
+
final_prompt = detailed_caption
|
162 |
+
yield f"Using caption: {final_prompt}", None, final_prompt
|
163 |
+
|
164 |
+
yield f"Generating with: {final_prompt}", None, final_prompt
|
165 |
+
|
|
|
|
|
|
|
|
|
166 |
# Generate the image
|
167 |
try:
|
168 |
+
image = generate_image(
|
169 |
+
prompt=final_prompt,
|
170 |
+
scale=scale,
|
171 |
+
steps=steps,
|
172 |
+
control_image=control_image,
|
173 |
+
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
174 |
+
guidance_scale=guidance_scale,
|
175 |
+
seed=seed,
|
176 |
+
guidance_end=guidance_end
|
177 |
+
)
|
|
|
|
|
178 |
|
179 |
+
try:
|
180 |
+
debug_img = Image.open(image.save("/tmp/" + str(seed) + "output.png"))
|
181 |
+
save_image("/tmp/" + str(seed) + "output.png", debug_img)
|
182 |
+
except Exception as e:
|
183 |
+
print("Error 160: " + str(e))
|
184 |
+
log_params(final_prompt, scale, steps, controlnet_conditioning_scale, guidance_scale, seed, guidance_end, control_image, image)
|
185 |
+
yield f"Completed! Used prompt: {final_prompt}", image, final_prompt
|
186 |
except Exception as e:
|
187 |
print("Error: " + str(e))
|
188 |
yield f"Error: {str(e)}", None, None
|
|
|
279 |
inputs=[
|
280 |
control_image, prompt, system_prompt, scale, steps,
|
281 |
controlnet_conditioning_scale, guidance_scale, seed,
|
282 |
+
guidance_end, temperature_slider, top_p_slider, max_tokens_slider, log_prompt
|
283 |
],
|
284 |
outputs=[log_state, generated_image, prompt]
|
285 |
)
|