```python
classes, y = unique(array, return_inverse=True)
counts = np.bincount(y)
return dict((class, count) for class, count in zip(classes, counts))
```
obviously the last line is only necessary if you want to keep working with dicts. I didn't look to much at the rest of the code to know if this is necessary.