Automated detection and counting of maize tassels are important to enhance yield efficiency. This paper introduces a maize tassel detection and counting technique based on the modified YOLOv5n network. The modifications include using the GELU activation function instead of SiLU, applying attention block to the last C3 structure of the backbone, utilizing depth-wise convolution in the neck part, and employing a spatial-dropout layer in the head part. They make the model learn more complex features, detect tassels better, control overfitting, and reduce inference time. This model is trained and evaluated by Maize Tassel Detection and Counting (MTDC) dataset, and a 6.67% improvement in average precision (AP) as a result of modifications is observed. To investigate the performance of the model in terms of accuracy and inference time, the results of the proposed model are compared with the ones obtained by Faster R-CNN, SSD, RetinaNet, and TasselNetv2+ algorithms. These methods achieve 88.25%, 68.31%, 75.32%, and 78.68% of R-2. Also, 52.94%, 68.46%, and 70.99% of AP are obtained by Faster R-CNN, SSD, and RetinaNet algorithms, respectively. These values are reported as 95.72% and 86.69% for the modified YOLOv5n model. The results verify the advantage of the modified YOLOv5n model in detecting and counting the highest number of maize tassels in the least time.