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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -344,18 +344,22 @@ 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
-
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])
 
344
 
345
  def process_line(img, outdir='./output'):
346
  print(f"Received img type: {type(img)}")
347
+
348
+ # 检查输入是否为字符串路径
349
+ if isinstance(img, str):
350
+ img = cv2.imread(img) # 读取图像文件
351
+ if img is None:
352
+ raise ValueError("Failed to read the image. Check the file path.")
353
+ elif isinstance(img, np.ndarray):
354
  img = img.astype(np.uint8) # 转换为 uint8
 
 
 
 
 
355
  else:
356
  raise ValueError("Input img is not a valid NumPy array")
357
 
358
+ # 创建输入目录
359
+ os.makedirs("./input", exist_ok=True)
360
+ # 保存上传的图像
361
+ cv2.imwrite(os.path.join("./input", "input_image.png"), img)
362
+
363
  # 继续处理
364
  depth_anything("./input", os.path.join(outdir, "depth_anything"))
365
  teed_imgs("./input", os.path.join(outdir, "teed_imgs"), [1, 7, 2])