pytorch opencv pil图像预处理比较

x33g5p2x  于2022-07-26 转载在 其他  
字(0.6k)|赞(0)|评价(0)|浏览(396)

opencv的:

img = cv2.imdecode(np.fromfile(label_file.replace("label.csv","")+img_path, dtype=np.uint8), 1)
                print(label_file.replace("label.csv","")+img_path)
                if img is None:
                    print('file is none',label_file.replace("label.csv","")+img_path)
                    df_train.drop(df_train[df_train.img_path == img_path].index, inplace=True)
                    df_result.drop(df_train[df_train.img_path == img_path].index, inplace=True)
                    df_train.to_csv(label_file, index=False)
                    continue
                img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
                t_h, t_w = img.shape[:2]
                a_w = max(t_w, t_h)
                img_b = np.zeros((a_w, a_w, 3), dtype=np.uint8)
                if t_h > t_

相关文章