plutosss commited on
Commit
c0e34ca
·
verified ·
1 Parent(s): d34df05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -344,23 +344,21 @@ def process_images(input_folder='./output/merged_imgs'):
344
 
345
  def process_line(img, outdir='./output'):
346
  print(f"Received img type: {type(img)}")
347
- img_path = "./input"
348
 
349
  # 确保 img 是一个有效的 NumPy 数组
350
  if isinstance(img, np.ndarray):
351
- print(f"Image type: {type(img)}, shape: {img.shape}, dtype: {img.dtype}")
352
-
353
- # 确保图像是 uint8 类型
354
- img = img.astype(np.uint8)
355
 
 
 
356
  # 保存上传的图像
357
- cv2.imwrite(os.path.join(img_path, "input_image.png"), img)
358
  else:
359
  raise ValueError("Input img is not a valid NumPy array")
360
 
361
  # 继续处理
362
- depth_anything(img_path, os.path.join(outdir, "depth_anything"))
363
- teed_imgs(img_path, os.path.join(outdir, "teed_imgs"), [1, 7, 2])
364
  teed_imgs(os.path.join(outdir, "depth_anything"), os.path.join(outdir, "dp_teed_imgs"), [0, 7, 2])
365
  merge_images_in_2_folder(os.path.join(outdir, "teed_imgs"), os.path.join(outdir, "dp_teed_imgs"), os.path.join(outdir, "merged_imgs"), '_depth', 1, 'multiply', [[2, 0], [2, 1]], [1, 0])
366
 
@@ -370,6 +368,7 @@ def process_line(img, outdir='./output'):
370
 
371
 
372
 
 
373
  if __name__ == '__main__':
374
  # depth_anything()
375
  # teed_imgs('./input', './output/teed_imgs', [1,7,2])
@@ -393,7 +392,6 @@ if __name__ == '__main__':
393
  title="Image Processing",
394
  description="Upload an image to process it using depth-anything and TEED.")
395
 
396
-
397
-
398
  # 启动 Gradio 接口
399
  interface.launch()
 
 
344
 
345
  def process_line(img, outdir='./output'):
346
  print(f"Received img type: {type(img)}")
 
347
 
348
  # 确保 img 是一个有效的 NumPy 数组
349
  if isinstance(img, np.ndarray):
350
+ img = img.astype(np.uint8) # 转换为 uint8
 
 
 
351
 
352
+ # 创建输入目录
353
+ os.makedirs("./input", exist_ok=True)
354
  # 保存上传的图像
355
+ cv2.imwrite(os.path.join("./input", "input_image.png"), img)
356
  else:
357
  raise ValueError("Input img is not a valid NumPy array")
358
 
359
  # 继续处理
360
+ depth_anything("./input", os.path.join(outdir, "depth_anything"))
361
+ teed_imgs("./input", os.path.join(outdir, "teed_imgs"), [1, 7, 2])
362
  teed_imgs(os.path.join(outdir, "depth_anything"), os.path.join(outdir, "dp_teed_imgs"), [0, 7, 2])
363
  merge_images_in_2_folder(os.path.join(outdir, "teed_imgs"), os.path.join(outdir, "dp_teed_imgs"), os.path.join(outdir, "merged_imgs"), '_depth', 1, 'multiply', [[2, 0], [2, 1]], [1, 0])
364
 
 
368
 
369
 
370
 
371
+
372
  if __name__ == '__main__':
373
  # depth_anything()
374
  # teed_imgs('./input', './output/teed_imgs', [1,7,2])
 
392
  title="Image Processing",
393
  description="Upload an image to process it using depth-anything and TEED.")
394
 
 
 
395
  # 启动 Gradio 接口
396
  interface.launch()
397
+