diff --git a/README.md b/README.md index 2f752e6..96801f7 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ I did almost no changes to the original code, except for: * `VALIDATION_STEPS` and `STEPS_PER_EPOCH` are now forced to depend on the dataset size, hardcoded. * `multiprocessing=False`, hardcoded. * [@John1231983]'s changed from [this PR](https://github.com/killthekitten/kaggle-ds-bowl-2018-baseline/pull/1). +* Added `RESNET_ARCHITECTURE` variable to the config (`resnet50` or `resnet101` while 101 comes with a default config). ## Quick Start @@ -42,7 +43,7 @@ CUDA_VISIBLE_DEVICES="0" python inference.py This will create `submission.csv` in the repo and overwrite the old one (you're welcome to fix this with a PR). -6. Submit! You should get around 0.342 score on LB after 100 epochs. +6. Submit! You should get around 0.4 score on LB after 100 epochs. ## What's else inside? diff --git a/bowl_config.py b/bowl_config.py index 22c53ac..cfbb8d4 100644 --- a/bowl_config.py +++ b/bowl_config.py @@ -32,8 +32,15 @@ class BowlConfig(Config): # use small validation steps since the epoch is small VALIDATION_STEPS = 5 - + USE_MINI_MASK = True - + + MAX_GT_INSTANCES = 256 + + DETECTION_MAX_INSTANCES = 512 + + RESNET_ARCHITECTURE = "resnet50" + + bowl_config = BowlConfig() bowl_config.display() diff --git a/config.py b/config.py index 9f84f55..592c8ce 100644 --- a/config.py +++ b/config.py @@ -41,7 +41,7 @@ class Config(object): # Validation stats are also calculated at each epoch end and they # might take a while, so don't set this too small to avoid spending # a lot of time on validation stats. - STEPS_PER_EPOCH = 670 + STEPS_PER_EPOCH = 1000 # Number of validation steps to run at the end of every training epoch. # A bigger number improves accuracy of validation stats, but slows @@ -87,8 +87,8 @@ class Config(object): # Images are resized such that the smallest side is >= IMAGE_MIN_DIM and # the longest side is <= IMAGE_MAX_DIM. In case both conditions can't # be satisfied together the IMAGE_MAX_DIM is enforced. - IMAGE_MIN_DIM = 512 - IMAGE_MAX_DIM = 512 + IMAGE_MIN_DIM = 800 + IMAGE_MAX_DIM = 1024 # If True, pad images with zeros such that they're (max_dim by max_dim) IMAGE_PADDING = True # currently, the False option is not supported @@ -111,14 +111,14 @@ class Config(object): MASK_SHAPE = [28, 28] # Maximum number of ground truth instances to use in one image - MAX_GT_INSTANCES = 256 + MAX_GT_INSTANCES = 100 # Bounding box refinement standard deviation for RPN and final detections. RPN_BBOX_STD_DEV = np.array([0.1, 0.1, 0.2, 0.2]) BBOX_STD_DEV = np.array([0.1, 0.1, 0.2, 0.2]) # Max number of final detections - DETECTION_MAX_INSTANCES = 512 + DETECTION_MAX_INSTANCES = 100 # Minimum probability value to accept a detected instance # ROIs below this threshold are skipped @@ -144,6 +144,8 @@ class Config(object): # train the RPN. USE_RPN_ROIS = True + RESNET_ARCHITECTURE = "resnet101" + def __init__(self): """Set values of computed attributes.""" # Effective batch size diff --git a/model.py b/model.py index 5ce54f6..433719c 100644 --- a/model.py +++ b/model.py @@ -1816,7 +1816,7 @@ def build(self, mode, config): # Bottom-up Layers # Returns a list of the last layers of each stage, 5 in total. # Don't create the thead (stage 5), so we pick the 4th item in the list. - _, C2, C3, C4, C5 = resnet_graph(input_image, "resnet50", stage5=True) + _, C2, C3, C4, C5 = resnet_graph(input_image, config.RESNET_ARCHITECTURE, stage5=True) # Top-down Layers # TODO: add assert to varify feature map sizes match what's in config P5 = KL.Conv2D(256, (1, 1), name='fpn_c5p5')(C5) @@ -2224,10 +2224,10 @@ def train(self, train_dataset, val_dataset, learning_rate, epochs, layers): workers = 0 else: workers = max(self.config.BATCH_SIZE // 2, 2) - + steps_per_epoch = np.ceil(len(train_dataset.image_ids) / self.config.BATCH_SIZE) validation_steps = np.ceil(len(train_dataset.image_ids) / self.config.BATCH_SIZE) - + self.keras_model.fit_generator( train_generator, initial_epoch=self.epoch,