Answers.Body: <p>If you want to count the number of objects using a neural network, you can use pretrained YOLO with the bottom prediction layer removed, and feed the features to a classification feed forward layer of let's say 1000 class representing 0-999 objects in the image. You can then train it and propagate the gradients through it. For example, in the pytorch code for YOLO,(source:<a href="https://github.com/eriklindernoren/PyTorch-YOLOv3" rel="nofollow noreferrer">https://github.com/eriklindernoren/PyTorch-YOLOv3</a>)
  You can add a <code>nn.Linear</code> and use cross entropy loss to classify the number of images. You can also change the architecture completely. Maybe you can try adding layers to reset or other classifying network to count the number of objects. Hope this can help you and have a nice day!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-28T05:58:21.553Z
Answers.Text: May I know why such architecture changes are required? In a normal YOLO, if it detects all the balls, isn't it just a matter of using a for loop to count the output? Why should the neural network count it?
Answers.UserDisplayName: Julian
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-03T06:57:41.307Z
Answers.LastActivityDate: 2019-11-03T06:57:41.307Z
Answers.UserDisplayName: Clement
Body: <p>I'm looking for a neural network architecture that excels in counting objects. For example, CNN that can output the number of balls (or any other object) in a given image.</p>
  <p>I already found articles about crowd counting. I'm looking for articles about different types of objects.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-10T18:30:42.397Z
Comments.Text: You can run YOLO, then count the number of occurrences.
Comments.UserDisplayName: drerD
Tags: <deep-learning><convolutional-neural-networks><object-detection><model-request>
Title: Which neural network can count the number of objects in an image?
UserDisplayName: ron653
ThreadText: # Which neural network can count the number of objects in an image?
  
  (Asked by: username_0 on 2019-03-10)
  
  I'm looking for a neural network architecture that excels in counting objects. For example, CNN that can output the number of balls (or any other object) in a given image.
  
  I already found articles about crowd counting. I'm looking for articles about different types of objects.
  
  **Tags:** deep-learning, convolutional-neural-networks, object-detection, model-request
  
  > **Comments:**
  > **username_1**: You can run YOLO, then count the number of occurrences.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-11-03. Score: 3 | Accepted answer
  
  If you want to count the number of objects using a neural network, you can use pretrained YOLO with the bottom prediction layer removed, and feed the features to a classification feed forward layer of let's say 1000 class representing 0-999 objects in the image. You can then train it and propagate the gradients through it. For example, in the pytorch code for YOLO,(source:<https://github.com/eriklindernoren/PyTorch-YOLOv3>)
  You can add a `nn.Linear` and use cross entropy loss to classify the number of images. You can also change the architecture completely. Maybe you can try adding layers to reset or other classifying network to count the number of objects. Hope this can help you and have a nice day!
  
  > **Comments:**
  > **username_3**: May I know why such architecture changes are required? In a normal YOLO, if it detects all the balls, isn't it just a matter of using a for loop to count the output? Why should the neural network count it?  
  
  ---
  
  