This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from torch.utils.data import Dataset | |
class EfficientDetDataset(Dataset): | |
def __init__( | |
self, dataset_adaptor, transforms=get_valid_transforms() | |
): | |
self.ds = dataset_adaptor | |
self.transforms = transforms | |
def __getitem__(self, index): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import albumentations as A | |
from albumentations.pytorch.transforms import ToTensorV2 | |
def get_train_transforms(target_img_size=512): | |
return A.Compose( | |
[ | |
A.HorizontalFlip(p=0.5), | |
A.Resize(height=target_img_size, width=target_img_size, p=1), | |
A.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from effdet.config.model_config import efficientdet_model_param_dict | |
from effdet import get_efficientdet_config, EfficientDet, DetBenchTrain | |
from effdet.efficientdet import HeadNet | |
from effdet.config.model_config import efficientdet_model_param_dict | |
def create_model(num_classes=1, image_size=512, architecture="tf_efficientnetv2_l"): | |
efficientdet_model_param_dict['tf_efficientnetv2_l'] = dict( | |
name='tf_efficientnetv2_l', | |
backbone_name='tf_efficientnetv2_l', | |
backbone_args=dict(drop_path_rate=0.2), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import PIL | |
import numpy as np | |
class CarsDatasetAdaptor: | |
def __init__(self, images_dir_path, annotations_dataframe): | |
self.images_dir_path = Path(images_dir_path) | |
self.annotations_df = annotations_dataframe |
NewerOlder