Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -408,14 +408,14 @@ def main(device, segment_type):
|
|
408 |
canny_image = Image.fromarray(image)
|
409 |
return canny_image
|
410 |
|
411 |
-
def get_depth(image):
|
412 |
image = feature_extractor(images=image, return_tensors="pt").pixel_values.to("cuda")
|
413 |
with torch.no_grad(), torch.autocast("cuda"):
|
414 |
depth_map = depth_estimator(image).predicted_depth
|
415 |
|
416 |
depth_map = torch.nn.functional.interpolate(
|
417 |
depth_map.unsqueeze(1),
|
418 |
-
size=(
|
419 |
mode="bicubic",
|
420 |
align_corners=False,
|
421 |
)
|
@@ -472,7 +472,7 @@ def main(device, segment_type):
|
|
472 |
kwargs['height'] = height
|
473 |
kwargs['width'] = width
|
474 |
condition_img = resize_and_center_crop(Image.fromarray(condition_img), (width, height))
|
475 |
-
spatial_condition = get_depth(condition_img)
|
476 |
else:
|
477 |
spatial_condition = None
|
478 |
|
|
|
408 |
canny_image = Image.fromarray(image)
|
409 |
return canny_image
|
410 |
|
411 |
+
def get_depth(image, height, weight):
|
412 |
image = feature_extractor(images=image, return_tensors="pt").pixel_values.to("cuda")
|
413 |
with torch.no_grad(), torch.autocast("cuda"):
|
414 |
depth_map = depth_estimator(image).predicted_depth
|
415 |
|
416 |
depth_map = torch.nn.functional.interpolate(
|
417 |
depth_map.unsqueeze(1),
|
418 |
+
size=(height, weight),
|
419 |
mode="bicubic",
|
420 |
align_corners=False,
|
421 |
)
|
|
|
472 |
kwargs['height'] = height
|
473 |
kwargs['width'] = width
|
474 |
condition_img = resize_and_center_crop(Image.fromarray(condition_img), (width, height))
|
475 |
+
spatial_condition = get_depth(condition_img, height, width)
|
476 |
else:
|
477 |
spatial_condition = None
|
478 |
|