Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -237,15 +237,28 @@ class RetroArtConverter:
|
|
| 237 |
def get_depth_map(self, image):
|
| 238 |
"""Generate depth map using Zoe Depth"""
|
| 239 |
if self.zoe_depth is not None:
|
| 240 |
-
#
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
return depth_image
|
| 243 |
else:
|
| 244 |
# Fallback to simple grayscale
|
| 245 |
gray = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2GRAY)
|
| 246 |
depth_colored = cv2.cvtColor(gray, cv2.COLOR_GRAY2RGB)
|
| 247 |
return Image.fromarray(depth_colored)
|
| 248 |
-
|
| 249 |
def calculate_optimal_size(self, original_width, original_height):
|
| 250 |
"""Calculate optimal size from recommended resolutions"""
|
| 251 |
aspect_ratio = original_width / original_height
|
|
|
|
| 237 |
def get_depth_map(self, image):
|
| 238 |
"""Generate depth map using Zoe Depth"""
|
| 239 |
if self.zoe_depth is not None:
|
| 240 |
+
# --- FIX ---
|
| 241 |
+
# Get the size from the PIL image
|
| 242 |
+
w, h = image.size
|
| 243 |
+
|
| 244 |
+
# Ensure they are standard Python ints, not numpy.int64
|
| 245 |
+
w_int, h_int = int(w), int(h)
|
| 246 |
+
|
| 247 |
+
# Pass the image's own size as tuples to prevent
|
| 248 |
+
# controlnet_aux from resizing to a square.
|
| 249 |
+
depth_image = self.zoe_depth(
|
| 250 |
+
image,
|
| 251 |
+
detect_resolution=(w_int, h_int),
|
| 252 |
+
image_resolution=(w_int, h_int)
|
| 253 |
+
)
|
| 254 |
+
# --- END FIX ---
|
| 255 |
return depth_image
|
| 256 |
else:
|
| 257 |
# Fallback to simple grayscale
|
| 258 |
gray = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2GRAY)
|
| 259 |
depth_colored = cv2.cvtColor(gray, cv2.COLOR_GRAY2RGB)
|
| 260 |
return Image.fromarray(depth_colored)
|
| 261 |
+
|
| 262 |
def calculate_optimal_size(self, original_width, original_height):
|
| 263 |
"""Calculate optimal size from recommended resolutions"""
|
| 264 |
aspect_ratio = original_width / original_height
|