Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -365,9 +365,6 @@ def process_images(input_folder='./output/merged_imgs'):
|
|
| 365 |
print(f"Error processing file {image_file}: {e}")
|
| 366 |
|
| 367 |
def process_line(input_files):
|
| 368 |
-
output_folder = "/app/output" # 默认输出路径
|
| 369 |
-
os.makedirs(output_folder, exist_ok=True)
|
| 370 |
-
|
| 371 |
processed_images = []
|
| 372 |
errors = []
|
| 373 |
|
|
@@ -376,22 +373,17 @@ def process_line(input_files):
|
|
| 376 |
img_path = img_path.name # 获取文件路径
|
| 377 |
|
| 378 |
# 调用处理函数
|
| 379 |
-
depth_anything(img_path,
|
| 380 |
-
teed_imgs(img_path,
|
| 381 |
-
teed_imgs(
|
| 382 |
-
merge_images_in_2_folder(
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
# 获取 merged_imgs 中的图片路径
|
| 389 |
-
processed_images = [os.path.join(output_folder, "merged_imgs", f)
|
| 390 |
-
for f in os.listdir(os.path.join(output_folder, "merged_imgs"))
|
| 391 |
-
if f.lower().endswith(('.jpg', '.jpeg', '.png'))]
|
| 392 |
|
| 393 |
# 将处理后的图片压缩成 ZIP
|
| 394 |
-
zip_file_path =
|
| 395 |
with zipfile.ZipFile(zip_file_path, 'w') as zipf:
|
| 396 |
for image in processed_images:
|
| 397 |
zipf.write(image, os.path.basename(image))
|
|
|
|
| 365 |
print(f"Error processing file {image_file}: {e}")
|
| 366 |
|
| 367 |
def process_line(input_files):
|
|
|
|
|
|
|
|
|
|
| 368 |
processed_images = []
|
| 369 |
errors = []
|
| 370 |
|
|
|
|
| 373 |
img_path = img_path.name # 获取文件路径
|
| 374 |
|
| 375 |
# 调用处理函数
|
| 376 |
+
depth_anything(img_path, "depth_anything_output.jpg") # 直接指定输出文件名
|
| 377 |
+
teed_imgs(img_path, "teed_imgs_output.jpg", [1, 7, 2])
|
| 378 |
+
teed_imgs("depth_anything_output.jpg", "dp_teed_imgs_output.jpg", [0, 7, 2])
|
| 379 |
+
merge_images_in_2_folder("teed_imgs_output.jpg", "dp_teed_imgs_output.jpg", "merged_imgs_output.jpg", '_depth', 1, 'multiply', [[2, 0], [2, 1]], [1, 0])
|
| 380 |
+
process_images("merged_imgs_output.jpg")
|
| 381 |
+
|
| 382 |
+
# 假设 merged_imgs_output.jpg 是处理后的输出文件
|
| 383 |
+
processed_images.append("merged_imgs_output.jpg")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
|
| 385 |
# 将处理后的图片压缩成 ZIP
|
| 386 |
+
zip_file_path = "processed_images.zip"
|
| 387 |
with zipfile.ZipFile(zip_file_path, 'w') as zipf:
|
| 388 |
for image in processed_images:
|
| 389 |
zipf.write(image, os.path.basename(image))
|