Installation and Environment Setup
Official installation guide: Installing conda - conda documentation
Download link: Download anaconda
You can download Miniconda and install environments as needed.
Create a runtime environment:
| |
Activate the environment:
| |
Installing PyTorch
For the CPU version, use this command directly:
| |
For the GPU version, you need to download it from the official site. Visit https://pytorch.org/get-started/locally/ to find the installation command.
Check your CUDA version with:
| |
Verify the installation once it’s finished:
| |
Annotating Images
For small local annotation tasks, you can use labelImg. Install it via pip:
| |
Then open the GUI using the command:
| |
Make sure to select the correct image path and save directory, and switch the current data format to YOLO.
Press W (uppercase) to create a new annotation.
Training the Model
YOLO26 Official Documentation: Ultralytics YOLO26
Install YOLO:
| |
Training code:
| |
Data definition file data.yaml:
| |
Training Outputs
Once training is complete, the outputs will be in runs/detect.
The weights/ folder contains the model files:
best.pt: The weights with the highest accuracy.last.pt: The weights from the final training epoch.
Charts:
results.png: Combines training loss and accuracy metrics (mAP).- If the curve is still rising, the model is still learning. If it plateaus, the model has converged.
confusion_matrix.png: Shows the probability of the model misidentifying objects as background or other classes.- The brighter the diagonal, the more accurate the recognition.
Box*_curve.png: Represents Precision, Recall, and their balance curve.labels.jpg: Statistics for all annotation boxes, showing size distribution and class ratios.
Image Visualizations:
train_batch*.jpg: Specific images used by the model during training.val_batch*_labels.jpg: Annotated images used for validation.val_batch*_pred.jpg: Prediction results from the model.
Other files:
args.yaml: All parameter settings used for this run, useful for reproduction.results.csv: Raw data table forresults.png.
Using the Model
| |