Open ZhaoQs999 opened 1 year ago
My test image is placed in Pytorch-UNet-master/result/test/.
-i
and -o
expect input and output individual images, not folders.
You could just call this script in a bash or python loop over all your images.
Modify predict.py to read the image part
for i, filename in enumerate(in_files):
logging.info(f'Predicting image {filename} ...')
image_files = [f for f in os.listdir(filename) if f.endswith('.jpg') or f.endswith('.png')]
for file in image_files:
input_image_path = os.path.join(filename, file)
img = Image.open(input_image_path)
start_image_time = time.time()
mask = predict_img(net=net,
full_img=img,
scale_factor=args.scale,
out_threshold=args.mask_threshold,
device=device)
If I want to predict the pictures of a folder, how can I modify the code and run the code? I typed the following in the terminal and got that the test folder could not be found. 如果我想预测一个文件夹的图片,我该怎么修改代码和运行代码呢?我在终端输入如下,得到的是找不到该测试文件夹。