diff --git a/classification/main_train.py b/classification/main_train.py index afcd784..0fc0e19 100644 --- a/classification/main_train.py +++ b/classification/main_train.py @@ -307,6 +307,8 @@ def main(): model = DenseNet169(n_inputs, numCls) elif args.model == 'DenseNet201': model = DenseNet201(n_inputs, numCls) + elif args.model == 'DenseNet201': + model = DenseNet201(n_inputs, numCls) # finetune moco pre-trained model elif args.model.startswith("Moco"): pt_path = os.path.join(args.pt_dir, f"{args.pt_name}_{args.pt_type}_converted.pth") diff --git a/classification/models/ResNet.py b/classification/models/ResNet.py index 5547661..f39598d 100644 --- a/classification/models/ResNet.py +++ b/classification/models/ResNet.py @@ -310,8 +310,23 @@ def __init__(self, mocoModel, n_inputs = 12, numCls = 17): resnet.conv1 = nn.Conv2d(n_inputs, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False) resnet.load_state_dict(mocoModel["state_dict"]) +<<<<<<< HEAD + # (testing) -- match the layer adding from moco's conv1 layer in ResNet + self.Conv1x1Block = nn.Sequential( + nn.Conv2d(n_inputs, 3, kernel_size=1, stride=1, bias=False), + nn.BatchNorm2d(3), + nn.ReLU(inplace=True) + ) + + # self.conv1 = nn.Conv2d(n_inputs, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False) + self.conv1 = nn.Conv2d(3, 64, kernel_size=(256, 256), stride=(2, 2), padding=(3, 3), bias=False) + self.encoder = nn.Sequential( + self.Conv1x1Block, + self.conv1, +======= self.encoder = nn.Sequential( resnet.conv1, +>>>>>>> origin/master resnet.bn1, resnet.relu, resnet.maxpool, diff --git a/classification/test.py b/classification/test.py index d38fa7e..e2b109b 100644 --- a/classification/test.py +++ b/classification/test.py @@ -13,7 +13,7 @@ from dataset import SEN12MS, ToTensor, Normalize from models.VGG import VGG16, VGG19 -from models.ResNet import ResNet50, ResNet101, ResNet152 +from models.ResNet import ResNet50, ResNet101, ResNet152, Moco from models.DenseNet import DenseNet121, DenseNet161, DenseNet169, DenseNet201 from metrics import MetricTracker, Precision_score, Recall_score, F1_score, \ F2_score, Hamming_loss, Subset_accuracy, Accuracy_score, One_error, \ @@ -25,6 +25,7 @@ model_choices = ['VGG16', 'VGG19', 'ResNet50','ResNet101','ResNet152', 'DenseNet121','DenseNet161','DenseNet169','DenseNet201', 'Moco'] + label_choices = ['multi_label', 'single_label'] # ------------------------ define and parse arguments ------------------------- @@ -158,7 +159,12 @@ def main(): elif config['model'] == 'DenseNet169': model = DenseNet169(n_inputs, numCls) elif config['model'] == 'DenseNet201': - model = DenseNet201(n_inputs, numCls) + model = DenseNet201(n_inputs, numCls) + + # add moco adjusted model - conv1 layer part + elif config['model'] == 'Moco': + model = Moco(n_inputs, numCls) + else: raise NameError("no model") diff --git a/evaluation_assessment.md b/evaluation_assessment.md new file mode 100644 index 0000000..1ada0f8 --- /dev/null +++ b/evaluation_assessment.md @@ -0,0 +1,19 @@ +1. The difference evaluation options: +> - a. Land cover classification -- image classificaiton. +> - b. Semantic Segmentation -- assigning a class label to every pixel of the input image. + +2. + +3. tmp +> a. SEN12MS - Supervised Learning Benchmark - Classification + +| Backbone | Land Type | Modalitities | Bactch size | Epochs | Accuracy (%) | Macro-F1 (%) | Micro-F1 (%) | +|---|---|---|---|---|---|---|---| +|DenseNet|single-label|_s1s2|64|100|51.16|50.78|62.90| +|DenseNet|single-label|_s2|64|100|54.41|52.32|64.74| +|ResNet50|single-label|_RGB|64|100|45.11|45.16|58.98| +|ResNet50|single-label|_s1s2|64|100|45.52|53.21|64.66| +|ResNet50|single-label|_s2|64|100|57.33|53.39|66.35| +|ResNet50|multi-label|_RGB|64|100|89.86|47.57|66.51| +|ResNet50|multi-label|_s1s2|64|100|91.22|57.46|71.40| +|ResNet50|multi-label|_s2|64|100|90.62|56.14|69.88|