Issue
I use this code to prepare model for optimization:
# load Faster RCNN pre-trained model
Faster_RCNN_tuned_model = torchvision.models.detection.fasterrcnn_resnet50_fpn(weights="DEFAULT")
# Get the number of input features
in_features = Faster_RCNN_tuned_model.roi_heads.box_predictor.cls_score.in_features
# Define a new head for the detector with 2 classes (cell or fone)
Faster_RCNN_tuned_model.roi_heads.box_predictor = FastRCNNPredictor(in_features, 2)
Faster_RCNN_tuned_model = Faster_RCNN_tuned_model.to(DEVICE)
and this code to load tuned model:
# Create Faster RCNN default model
best_Faster_RCNN_tuned_model = torchvision.models.detection.fasterrcnn_resnet50_fpn(weights="DEFAULT")
# Get the number of input features
in_features = best_Faster_RCNN_tuned_model.roi_heads.box_predictor.cls_score.in_features
# Define a new head for the detector with 2 classes (cell or fone)
best_Faster_RCNN_tuned_model.roi_heads.box_predictor = FastRCNNPredictor(in_features, 2)
# Load and setup parameters from saved best model
checkpoint = torch.load('C:\\temp\\datasets\\mediag\\models\\best_model.pth', map_location=DEVICE)
best_Faster_RCNN_tuned_model.load_state_dict(checkpoint['model_state_dict'])
best_Faster_RCNN_tuned_model = best_Faster_RCNN_tuned_model.to(DEVICE).eval()
There is 300+ objects on the images, but model detects only 100 objects: Show objects count for first 5 images
How can I increase maximum objects count up to 3000 ?
May be I should manually setup this parameter ?
in_features = best_Faster_RCNN_tuned_model.roi_heads.box_predictor.cls_score.in_features
# Define a new head for the detector with 2 classes (cell or fone)
best_Faster_RCNN_tuned_model.roi_heads.box_predictor = FastRCNNPredictor(in_features, 2)
Please help me to increase detected objects count.
Solution
I think it might help you to set the box_detections_per_img=300 when creating the model. This might be helpful: https://discuss.pytorch.org/t/faster-rcnn-yields-hundred-maches-every-time/100279/3
Also see the following parameters for better detections: https://github.com/pytorch/vision/blob/6e639d3e49371a509235201cb3f335b1c5cac0e3/torchvision/models/detection/faster_rcnn.py#L67-L88
Answered By - Nazmican Çalık
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.