zylo117 / Yet-Another-EfficientDet-Pytorch

The pytorch re-implement of the official efficientdet with SOTA performance in real time and pretrained weights.
GNU Lesser General Public License v3.0
5.2k stars 1.27k forks source link

Difference between train and inference of preprocess code of image #261

Open YuhaoYeSteve opened 4 years ago

YuhaoYeSteve commented 4 years ago

Train: img = cv2.imread(path) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) img = img.astype(np.float32) / 255. Normalizer& Augmenter &Resizer Inference: def preprocess(*image_path, max_size=512, mean=(0.406, 0.456, 0.485), std=(0.225, 0.224, 0.229)): ori_imgs = [cv2.imread(img_path) for img_path in image_path] normalized_imgs = [(img / 255 - mean) / std for img in ori_imgs] imgs_meta = [aspectaware_resize_padding(img[..., ::-1], max_size, max_size, means=None) for img in normalized_imgs] framed_imgs = [img_meta[0] for img_meta in imgs_meta] framed_metas = [img_meta[1:] for img_meta in imgs_meta]

return ori_imgs, framed_imgs, framed_metas
YuhaoYeSteve commented 4 years ago

Why train and inference are different? And I found in train code, use RGB format, but in inference do not convert BGR to RGB

Deeplayer commented 4 years ago

@YuhaoYeSteve img[..., ::-1] # BGR2RGB

zylo117 commented 4 years ago

They are the same. Different order, but the results are the same.