plutosss commited on
Commit
560eba9
·
verified ·
1 Parent(s): a2a31a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -17
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, os.path.join(output_folder, "depth_anything"))
380
- teed_imgs(img_path, os.path.join(output_folder, "teed_imgs"), [1, 7, 2])
381
- teed_imgs(os.path.join(output_folder, "depth_anything"), os.path.join(output_folder, "dp_teed_imgs"), [0, 7, 2])
382
- merge_images_in_2_folder(os.path.join(output_folder, "teed_imgs"),
383
- os.path.join(output_folder, "dp_teed_imgs"),
384
- os.path.join(output_folder, "merged_imgs"),
385
- '_depth', 1, 'multiply', [[2, 0], [2, 1]], [1, 0])
386
- process_images(os.path.join(output_folder, "merged_imgs"))
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 = os.path.join(output_folder, "processed_images.zip")
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))