File size: 2,644 Bytes
356473a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
license: ecl-2.0
---

# YOLOv5 Cattle Counter

This repository contains a YOLOv5 model trained to detect and count cattle in images. The model is designed to facilitate the monitoring and management of cattle in agricultural settings.

## Model Information

- **Model:** YOLOv5
- **Task:** Object Detection
- **Classes:** Cattle
- **File:** `bestyolo5.pt`

## How to Use

To use the YOLOv5 Cattle Counter model, follow these steps:

### 1. Loading the Model

You can load the model using the `torch` library and the `ultralytics/yolov5` repository. Here's an example in Python:

```python
import torch

# Load the model
model = torch.hub.load('ultralytics/yolov5', 'custom', path='bestyolo5.pt')

# Load an image
img = 'path/to/your/image.jpg'

# Perform inference
results = model(img)

# Display results
results.show()
```

### 2. Running Inference

After loading the model, you can perform inference on your images to detect and count cattle. The model will output the image with bounding boxes around detected cattle and the total count of detected cattle.

### 3. Example Usage

Here's an example of how to use the model to detect cattle in an image:

```python
import torch
from PIL import Image

# Load the model
model = torch.hub.load('ultralytics/yolov5', 'custom', path='bestyolo5.pt')

# Load an image
img = Image.open('path/to/your/cattle_image.jpg')

# Perform inference
results = model(img)

# Print results
results.print()  # Print results to console
results.show()   # Display results

# Save results
results.save('path/to/save/results/')  # Save results to a directory
```

## Model Training

The model was trained using a custom dataset of cattle images. The dataset was annotated with bounding boxes around cattle using MakeSense, and the YOLOv5 model was trained using these annotations. The training process involved:

1. Collecting and annotating the data.
2. Training the YOLOv5 model with the annotated data.
3. Fine-tuning the model to improve accuracy.

### Training Configuration

Soon

## Acknowledgements

Special thanks to the contributors and the open-source community for providing resources and support.

## License

This project is licensed under the Eclipse Public License 2.0.

## Contact

For more information or questions about the model, please contact Ramon Mayor Martins:

- Email: [[email protected]](mailto:[email protected])
- Homepage: [https://rmayormartins.github.io/](https://rmayormartins.github.io/)
- Twitter: [@rmayormartins](https://twitter.com/rmayormartins)
- GitHub: [https://github.com/rmayormartins](https://github.com/rmayormartins)
- My Radio Callsign (PU4MAY) Brazil