pytorch opencv pil图像预处理比较

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_

猜你喜欢

转载自blog.csdn.net/jacke121/article/details/125942704
今日推荐