JialeCao001 / SipMask

SipMask: Spatial Information Preservation for Fast Image and Video Instance Segmentation (ECCV2020)
https://arxiv.org/pdf/2007.14772.pdf
MIT License
334 stars 54 forks source link

Test on the trained model #43

Open aniketzz opened 3 years ago

aniketzz commented 3 years ago

I have trained a model with 1 class in SipMask-benchmark. I want to run the inference script using my model. when I tried to execute demo/fcos_demo.py. I have changed the path to the weight file and changed the class values inside demo/fcos_demo.py and predictor.py.

I have renamed the model as FCOS_imprv_R_50_FPN_1x.pth

I got the below error image

JialeCao001 commented 3 years ago

@aniketzz Thanks for interest. I donot use fcos_demo.py to show the result. But from the information you provided, it seems that there is a parameter about the number of the classes that needs to be changed to 1.

aniketzz commented 3 years ago

@JialeCao001 I agree but I have made the changes in all the config files as well as the files that are been used. I do not understand where I am missing. Is there any way to test the model on a video or image?

JialeCao001 commented 3 years ago

@aniketzz Are you sure that the output channel of training model is 1? it seems 80.

aniketzz commented 3 years ago

@JialeCao001 Yes I have. Here is the config:

Versions of relevant libraries: [pip3] numpy==1.19.2 [pip3] torch==1.4.0 [pip3] torchvision==0.5.0 [conda] blas 1.0 mkl
[conda] mkl 2020.2 256
[conda] mkl-service 2.3.0 py37he8ac12f_0
[conda] mkl_fft 1.3.0 py37h54f3939_0
[conda] mkl_random 1.1.1 py37h0573a6f_0
[conda] pytorch 1.4.0 py3.7_cuda10.0.130_cudnn7.6.3_0 pytorch [conda] torchvision 0.5.0 py37_cu100 pytorch Pillow (6.2.2) 2021-03-25 07:27:28,085 fcos_core INFO: Loaded configuration file configs/sipmask/sipmask_R_50_FPN_1x.yaml 2021-03-25 07:27:28,085 fcos_core INFO:

FCOS with improvements

MODEL: META_ARCHITECTURE: "GeneralizedRCNN" WEIGHT: "catalog://ImageNetPretrained/MSRA/R-50" RPN_ONLY: True SIPMASK_ON: True BACKBONE: CONV_BODY: "R-50-FPN-RETINANET" RESNETS: BACKBONE_OUT_CHANNELS: 256 RETINANET: USE_C5: False # FCOS uses P5 instead of C5 SIPMASK:

normalizing the regression targets with FPN strides

NORM_REG_TARGETS: True
# positioning centerness on the regress branch.
# Please refer to https://github.com/tianzhi0549/FCOS/issues/89#issuecomment-516877042
CENTERNESS_ON_REG: True
# using center sampling and GIoU.
# Please refer to https://github.com/yqyao/FCOS_PLUS
CENTER_SAMPLING_RADIUS: 1.5
IOU_LOSS_TYPE: "giou"

DATASETS: TRAIN: ("coco_2017_train",) TEST: ("coco_2017_val",) INPUT: MIN_SIZE_TRAIN: (800,) MAX_SIZE_TRAIN: 1333 MIN_SIZE_TEST: 800 MAX_SIZE_TEST: 1333 DATALOADER: SIZE_DIVISIBILITY: 32 SOLVER: BASE_LR: 0.01 WEIGHT_DECAY: 0.0001 STEPS: (60000, 80000) MAX_ITER: 90000 IMS_PER_BATCH: 8 WARMUP_METHOD: "constant"

2021-03-25 07:27:28,086 fcos_core INFO: Running with config: DATALOADER: ASPECT_RATIO_GROUPING: True NUM_WORKERS: 2 SIZE_DIVISIBILITY: 32 DATASETS: TEST: ('coco_2017_val',) TRAIN: ('coco_2017_train',) INPUT: MAX_SIZE_TEST: 1333 MAX_SIZE_TRAIN: 1333 MIN_SIZE_RANGE_TRAIN: (-1, -1) MIN_SIZE_TEST: 800 MIN_SIZE_TRAIN: (800,) PIXEL_MEAN: [102.9801, 115.9465, 122.7717] PIXEL_STD: [1.0, 1.0, 1.0] TO_BGR255: True MODEL: BACKBONE: CONV_BODY: R-50-FPN-RETINANET FREEZE_CONV_BODY_AT: 2 USE_GN: False CLS_AGNOSTIC_BBOX_REG: False DEVICE: cuda FBNET: ARCH: default ARCH_DEF: BN_TYPE: bn DET_HEAD_BLOCKS: [] DET_HEAD_LAST_SCALE: 1.0 DET_HEAD_STRIDE: 0 DW_CONV_SKIP_BN: True DW_CONV_SKIP_RELU: True KPTS_HEAD_BLOCKS: [] KPTS_HEAD_LAST_SCALE: 0.0 KPTS_HEAD_STRIDE: 0 MASK_HEAD_BLOCKS: [] MASK_HEAD_LAST_SCALE: 0.0 MASK_HEAD_STRIDE: 0 RPN_BN_TYPE: RPN_HEAD_BLOCKS: 0 SCALE_FACTOR: 1.0 WIDTH_DIVISOR: 1 FCOS: CENTERNESS_ON_REG: False CENTER_SAMPLING_RADIUS: 0.0 FPN_STRIDES: [8, 16, 32, 64, 128] INFERENCE_TH: 0.05 IOU_LOSS_TYPE: iou LOSS_ALPHA: 0.25 LOSS_GAMMA: 2.0 NMS_TH: 0.6 NORM_REG_TARGETS: False NUM_CLASSES: 2 NUM_CONVS: 4 PRE_NMS_TOP_N: 1000 PRIOR_PROB: 0.01 USE_DCN_IN_TOWER: False FCOS_ON: False FPN: USE_GN: False USE_RELU: False GROUP_NORM: DIM_PER_GP: -1 EPSILON: 1e-05 NUM_GROUPS: 32 KEYPOINT_ON: False MASK_ON: False META_ARCHITECTURE: GeneralizedRCNN RESNETS: BACKBONE_OUT_CHANNELS: 256 DEFORMABLE_GROUPS: 1 NUM_GROUPS: 1 RES2_OUT_CHANNELS: 256 RES5_DILATION: 1 STAGE_WITH_DCN: (False, False, False, False) STEM_FUNC: StemWithFixedBatchNorm STEM_OUT_CHANNELS: 64 STRIDE_IN_1X1: True TRANS_FUNC: BottleneckWithFixedBatchNorm WIDTH_PER_GROUP: 64 WITH_MODULATED_DCN: False RETINANET: ANCHOR_SIZES: (32, 64, 128, 256, 512) ANCHOR_STRIDES: (8, 16, 32, 64, 128) ASPECT_RATIOS: (0.5, 1.0, 2.0) BBOX_REG_BETA: 0.11 BBOX_REG_WEIGHT: 4.0 BG_IOU_THRESHOLD: 0.4 FG_IOU_THRESHOLD: 0.5 INFERENCE_TH: 0.05 LOSS_ALPHA: 0.25 LOSS_GAMMA: 2.0 NMS_TH: 0.4 NUM_CLASSES: 2 NUM_CONVS: 4 OCTAVE: 2.0 PRE_NMS_TOP_N: 1000 PRIOR_PROB: 0.01 SCALES_PER_OCTAVE: 3 STRADDLE_THRESH: 0 USE_C5: False RETINANET_ON: False ROI_BOX_HEAD: CONV_HEAD_DIM: 256 DILATION: 1 FEATURE_EXTRACTOR: ResNet50Conv5ROIFeatureExtractor MLP_HEAD_DIM: 1024 NUM_CLASSES: 2 NUM_STACKED_CONVS: 4 POOLER_RESOLUTION: 14 POOLER_SAMPLING_RATIO: 0 POOLER_SCALES: (0.0625,) PREDICTOR: FastRCNNPredictor USE_GN: False ROI_HEADS: BATCH_SIZE_PER_IMAGE: 512 BBOX_REG_WEIGHTS: (10.0, 10.0, 5.0, 5.0) BG_IOU_THRESHOLD: 0.5 DETECTIONS_PER_IMG: 100 FG_IOU_THRESHOLD: 0.5 NMS: 0.5 POSITIVE_FRACTION: 0.25 SCORE_THRESH: 0.05 USE_FPN: False ROI_KEYPOINT_HEAD: CONV_LAYERS: (512, 512, 512, 512, 512, 512, 512, 512) FEATURE_EXTRACTOR: KeypointRCNNFeatureExtractor MLP_HEAD_DIM: 1024 NUM_CLASSES: 17 POOLER_RESOLUTION: 14 POOLER_SAMPLING_RATIO: 0 POOLER_SCALES: (0.0625,) PREDICTOR: KeypointRCNNPredictor RESOLUTION: 14 SHARE_BOX_FEATURE_EXTRACTOR: True ROI_MASK_HEAD: CONV_LAYERS: (256, 256, 256, 256) DILATION: 1 FEATURE_EXTRACTOR: ResNet50Conv5ROIFeatureExtractor MLP_HEAD_DIM: 1024 POOLER_RESOLUTION: 14 POOLER_SAMPLING_RATIO: 0 POOLER_SCALES: (0.0625,) POSTPROCESS_MASKS: False POSTPROCESS_MASKS_THRESHOLD: 0.5 PREDICTOR: MaskRCNNC4Predictor RESOLUTION: 14 SHARE_BOX_FEATURE_EXTRACTOR: True USE_GN: False RPN: ANCHOR_SIZES: (32, 64, 128, 256, 512) ANCHOR_STRIDE: (16,) ASPECT_RATIOS: (0.5, 1.0, 2.0) BATCH_SIZE_PER_IMAGE: 256 BG_IOU_THRESHOLD: 0.3 FG_IOU_THRESHOLD: 0.7 FPN_POST_NMS_TOP_N_TEST: 1000 FPN_POST_NMS_TOP_N_TRAIN: 1000 MIN_SIZE: 0 NMS_THRESH: 0.7 POSITIVE_FRACTION: 0.5 POST_NMS_TOP_N_TEST: 500 POST_NMS_TOP_N_TRAIN: 1000 PRE_NMS_TOP_N_TEST: 3000 PRE_NMS_TOP_N_TRAIN: 6000 RPN_HEAD: SingleConvRPNHead STRADDLE_THRESH: 0 USE_FPN: False RPN_ONLY: True SIPMASK: CENTERNESS_ON_REG: True CENTER_SAMPLING_RADIUS: 1.5 FPN_STRIDES: [8, 16, 32, 64, 128] INFERENCE_TH: 0.05 IOU_LOSS_TYPE: giou LOSS_ALPHA: 0.25 LOSS_GAMMA: 2.0 NMS_TH: 0.6 NORM_REG_TARGETS: True NUM_CLASSES: 2 NUM_CONVS: 4 PRE_NMS_TOP_N: 1000 PRIOR_PROB: 0.01 USE_DCN_IN_TOWER: False SIPMASK_ON: True USE_SYNCBN: False WEIGHT: catalog://ImageNetPretrained/MSRA/R-50 OUTPUT_DIR: training_dir/sipmask_R_50_FPN_1x PATHS_CATALOG: /home/ubuntu/SipMask/SipMask-benchmark/fcos_core/config/paths_catalog.py SOLVER: BASE_LR: 0.01 BIAS_LR_FACTOR: 2 CHECKPOINT_PERIOD: 2500 DCONV_OFFSETS_LR_FACTOR: 1.0 GAMMA: 0.1 IMS_PER_BATCH: 8 MAX_ITER: 90000 MOMENTUM: 0.9 STEPS: (60000, 80000) WARMUP_FACTOR: 0.3333333333333333 WARMUP_ITERS: 500 WARMUP_METHOD: constant WEIGHT_DECAY: 0.0001 WEIGHT_DECAY_BIAS: 0 TEST: BBOX_AUG: ENABLED: False H_FLIP: False MAX_SIZE: 4000 SCALES: () SCALE_H_FLIP: False DETECTIONS_PER_IMG: 100 EXPECTED_RESULTS: [] EXPECTED_RESULTS_SIGMA_TOL: 4 IMS_PER_BATCH: 8

JialeCao001 commented 3 years ago

@aniketzz It seems no problem. I am not sure about the problem. Maybe you check the whole things again:)

aniketzz commented 3 years ago

@JialeCao001 Can You please help me with the inference code to test the trained model on custom data?

JialeCao001 commented 3 years ago

@aniketzz Hi aniketzz. I am sorry that I am not sure about the problem. I suggest you go through the inference step by step and check the paramter about classes carefully.

aniketzz commented 3 years ago

@JialeCao001, recompiling the code fixed the issue. I am able to test the custom model but I do not see any bounding box or mask while executing "demo/fcos_demo.py". I am not sure what mistake I am doing here. image