Open YuhaoYeSteve opened 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
@YuhaoYeSteve img[..., ::-1] # BGR2RGB
They are the same. Different order, but the results are the same.
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]