Spaces:
Runtime error
Runtime error
pablo
commited on
Commit
·
2e08ffe
1
Parent(s):
ede7254
mask fix
Browse files
app.py
CHANGED
|
@@ -13,11 +13,11 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
| 13 |
|
| 14 |
# Inpainting pipeline
|
| 15 |
|
| 16 |
-
|
| 17 |
unet = UNet2DConditionModel.from_pretrained("pablodawson/ldm3d-inpainting", cache_dir="cache", subfolder="unet", in_channels=9, low_cpu_mem_usage=False, ignore_mismatched_sizes=True)
|
| 18 |
pipe = StableDiffusionLDM3DInpaintPipeline.from_pretrained("Intel/ldm3d-4c", cache_dir="cache" ).to(device)
|
| 19 |
|
| 20 |
-
|
| 21 |
# Depth estimation
|
| 22 |
model_type = "DPT_Large" # MiDaS v3 - Large (highest accuracy, slowest inference speed)
|
| 23 |
#model_type = "DPT_Hybrid" # MiDaS v3 - Hybrid (medium accuracy, medium inference speed)
|
|
@@ -71,7 +71,8 @@ def predict(dict, depth, prompt="", negative_prompt="", guidance_scale=7.5, step
|
|
| 71 |
scheduler_class_name = scheduler.split("-")[0]
|
| 72 |
|
| 73 |
init_image = cv2.resize(dict["image"], (512, 512))
|
| 74 |
-
|
|
|
|
| 75 |
if (depth is None):
|
| 76 |
depth_image = estimate_depth(init_image)
|
| 77 |
else:
|
|
@@ -81,7 +82,7 @@ def predict(dict, depth, prompt="", negative_prompt="", guidance_scale=7.5, step
|
|
| 81 |
scheduler = getattr(diffusers, scheduler_class_name)
|
| 82 |
pipe.scheduler = scheduler.from_pretrained("Intel/ldm3d-4c", subfolder="scheduler")
|
| 83 |
|
| 84 |
-
|
| 85 |
depth_image = depth_image.resize((512, 512))
|
| 86 |
|
| 87 |
output = pipe(prompt = prompt, negative_prompt=negative_prompt, image=init_image, mask_image=mask, depth_image=depth_image, guidance_scale=guidance_scale, num_inference_steps=int(steps), strength=strength)
|
|
|
|
| 13 |
|
| 14 |
# Inpainting pipeline
|
| 15 |
|
| 16 |
+
'''
|
| 17 |
unet = UNet2DConditionModel.from_pretrained("pablodawson/ldm3d-inpainting", cache_dir="cache", subfolder="unet", in_channels=9, low_cpu_mem_usage=False, ignore_mismatched_sizes=True)
|
| 18 |
pipe = StableDiffusionLDM3DInpaintPipeline.from_pretrained("Intel/ldm3d-4c", cache_dir="cache" ).to(device)
|
| 19 |
|
| 20 |
+
'''
|
| 21 |
# Depth estimation
|
| 22 |
model_type = "DPT_Large" # MiDaS v3 - Large (highest accuracy, slowest inference speed)
|
| 23 |
#model_type = "DPT_Hybrid" # MiDaS v3 - Hybrid (medium accuracy, medium inference speed)
|
|
|
|
| 71 |
scheduler_class_name = scheduler.split("-")[0]
|
| 72 |
|
| 73 |
init_image = cv2.resize(dict["image"], (512, 512))
|
| 74 |
+
mask = Image.fromarray(cv2.resize(dict["mask"], (512, 512))[:,:,0])
|
| 75 |
+
|
| 76 |
if (depth is None):
|
| 77 |
depth_image = estimate_depth(init_image)
|
| 78 |
else:
|
|
|
|
| 82 |
scheduler = getattr(diffusers, scheduler_class_name)
|
| 83 |
pipe.scheduler = scheduler.from_pretrained("Intel/ldm3d-4c", subfolder="scheduler")
|
| 84 |
|
| 85 |
+
|
| 86 |
depth_image = depth_image.resize((512, 512))
|
| 87 |
|
| 88 |
output = pipe(prompt = prompt, negative_prompt=negative_prompt, image=init_image, mask_image=mask, depth_image=depth_image, guidance_scale=guidance_scale, num_inference_steps=int(steps), strength=strength)
|