Spaces:
Sleeping
Sleeping
Bobby
commited on
Commit
·
97a87f4
1
Parent(s):
19def46
nice
Browse files
app.py
CHANGED
|
@@ -441,6 +441,7 @@ def process_image(
|
|
| 441 |
prompt = str(get_prompt(prompt, a_prompt))
|
| 442 |
negative_prompt = str(n_prompt)
|
| 443 |
|
|
|
|
| 444 |
initial_result = pipe(
|
| 445 |
prompt=prompt,
|
| 446 |
negative_prompt=negative_prompt,
|
|
@@ -457,17 +458,10 @@ def process_image(
|
|
| 457 |
|
| 458 |
if furniture_type != "None":
|
| 459 |
furniture_mask = generate_furniture_mask(initial_result, furniture_type)
|
| 460 |
-
furniture_prompt = f"
|
| 461 |
|
| 462 |
-
#
|
| 463 |
-
|
| 464 |
-
image=initial_result,
|
| 465 |
-
image_resolution=image_resolution,
|
| 466 |
-
detect_resolution=preprocess_resolution,
|
| 467 |
-
)
|
| 468 |
-
|
| 469 |
-
# Use the regular inpainting pipeline with ControlNet guidance
|
| 470 |
-
inpainted_image = inpaint_pipe(
|
| 471 |
prompt=furniture_prompt,
|
| 472 |
image=initial_result,
|
| 473 |
mask_image=furniture_mask,
|
|
@@ -476,21 +470,10 @@ def process_image(
|
|
| 476 |
guidance_scale=guidance_scale,
|
| 477 |
generator=generator,
|
| 478 |
).images[0]
|
| 479 |
-
|
| 480 |
-
# Apply ControlNet guidance on the inpainted result
|
| 481 |
-
final_result = pipe(
|
| 482 |
-
prompt=furniture_prompt,
|
| 483 |
-
negative_prompt=negative_prompt,
|
| 484 |
-
guidance_scale=guidance_scale,
|
| 485 |
-
num_images_per_prompt=1,
|
| 486 |
-
num_inference_steps=num_steps,
|
| 487 |
-
generator=generator,
|
| 488 |
-
image=control_image_inpaint,
|
| 489 |
-
controlnet_conditioning_scale=0.5, # Adjust this value as needed
|
| 490 |
-
).images[0]
|
| 491 |
else:
|
| 492 |
final_result = initial_result
|
| 493 |
|
|
|
|
| 494 |
timestamp = int(time.time())
|
| 495 |
img_path = f"{timestamp}.jpg"
|
| 496 |
results_path = f"{timestamp}_out.jpg"
|
|
|
|
| 441 |
prompt = str(get_prompt(prompt, a_prompt))
|
| 442 |
negative_prompt = str(n_prompt)
|
| 443 |
|
| 444 |
+
# Generate the initial room image
|
| 445 |
initial_result = pipe(
|
| 446 |
prompt=prompt,
|
| 447 |
negative_prompt=negative_prompt,
|
|
|
|
| 458 |
|
| 459 |
if furniture_type != "None":
|
| 460 |
furniture_mask = generate_furniture_mask(initial_result, furniture_type)
|
| 461 |
+
furniture_prompt = f"{prompt}, with a {furniture_type} in the style of {style_selection}"
|
| 462 |
|
| 463 |
+
# Use the inpainting pipeline to add furniture
|
| 464 |
+
final_result = inpaint_pipe(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
prompt=furniture_prompt,
|
| 466 |
image=initial_result,
|
| 467 |
mask_image=furniture_mask,
|
|
|
|
| 470 |
guidance_scale=guidance_scale,
|
| 471 |
generator=generator,
|
| 472 |
).images[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 473 |
else:
|
| 474 |
final_result = initial_result
|
| 475 |
|
| 476 |
+
# Save and upload results
|
| 477 |
timestamp = int(time.time())
|
| 478 |
img_path = f"{timestamp}.jpg"
|
| 479 |
results_path = f"{timestamp}_out.jpg"
|