From 8b8544c214700c65312d98e135d76a9cf0c85d48 Mon Sep 17 00:00:00 2001 From: naelsondouglas Date: Tue, 2 Nov 2021 04:45:05 -0300 Subject: [PATCH] Removed a case of the manual indexer pitfall --- u2net_portrait_demo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/u2net_portrait_demo.py b/u2net_portrait_demo.py index 516272a6..2c01f661 100644 --- a/u2net_portrait_demo.py +++ b/u2net_portrait_demo.py @@ -157,19 +157,19 @@ def main(): net.eval() # do the inference one-by-one - for i in range(0,len(im_list)): + for i, im in enumerate(im_list): print("--------------------------") - print("inferencing ", i, "/", len(im_list), im_list[i]) + print("inferencing ", i, "/", len(im_list), im) # load each image - img = cv2.imread(im_list[i]) + img = cv2.imread(im) height,width = img.shape[0:2] face = detect_single_face(face_cascade,img) im_face = crop_face(img, face) im_portrait = inference(net,im_face) # save the output - cv2.imwrite(out_dir+"/"+im_list[i].split('/')[-1][0:-4]+'.png',(im_portrait*255).astype(np.uint8)) + cv2.imwrite(out_dir+"/"+im.split('/')[-1][0:-4]+'.png',(im_portrait*255).astype(np.uint8)) if __name__ == '__main__': main()