Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,10 @@ florence_model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-larg
|
|
| 20 |
florence_processor = AutoProcessor.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True)
|
| 21 |
|
| 22 |
# Load a quick, highly accurate MiDaS model pipeline via torch hub
|
| 23 |
-
midas = torch.hub.load("intel-isl/MiDaS", "MiDaS_small").to(device)
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# 1. Load the specific ControlNet adapter from Hugging Face
|
| 26 |
controlnet_ids= ["lllyasviel/sd-controlnet-canny","lllyasviel/sd-controlnet-seg","lllyasviel/sd-controlnet-depth"]
|
|
@@ -123,9 +126,6 @@ def extract_depth_map(image_path):
|
|
| 123 |
"""
|
| 124 |
Utilizes a lightweight MiDaS pipeline to extract depth estimation layouts.
|
| 125 |
"""
|
| 126 |
-
transform_depth = midas_transforms.flag_transform if hasattr(midas_transforms, 'flag_transform') else midas_transforms.dpt_transform
|
| 127 |
-
midas_transforms = torch.hub.load("intel-isl/MiDaS", "transforms")
|
| 128 |
-
|
| 129 |
pil_image = Image.open(image_path).convert("RGB")
|
| 130 |
cv_img = np.array(pil_image)
|
| 131 |
img_tensor = transform_depth(cv_img).to(device)
|
|
|
|
| 20 |
florence_processor = AutoProcessor.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True)
|
| 21 |
|
| 22 |
# Load a quick, highly accurate MiDaS model pipeline via torch hub
|
| 23 |
+
midas = torch.hub.load("intel-isl/MiDaS", "MiDaS_small",trust_repo=True).to(device).eval()
|
| 24 |
+
midas_transforms = torch.hub.load("intel-isl/MiDaS", "transforms")
|
| 25 |
+
transform_depth = midas_transforms.flag_transform if hasattr(midas_transforms, 'flag_transform') else midas_transforms.dpt_transform
|
| 26 |
+
|
| 27 |
|
| 28 |
# 1. Load the specific ControlNet adapter from Hugging Face
|
| 29 |
controlnet_ids= ["lllyasviel/sd-controlnet-canny","lllyasviel/sd-controlnet-seg","lllyasviel/sd-controlnet-depth"]
|
|
|
|
| 126 |
"""
|
| 127 |
Utilizes a lightweight MiDaS pipeline to extract depth estimation layouts.
|
| 128 |
"""
|
|
|
|
|
|
|
|
|
|
| 129 |
pil_image = Image.open(image_path).convert("RGB")
|
| 130 |
cv_img = np.array(pil_image)
|
| 131 |
img_tensor = transform_depth(cv_img).to(device)
|