You should use another architecture, an object detector. It’s nothing but a CNN which generates a bounding box around learned objects.
This way you can count the amount of bb, thus, amount of items of each class.