Load the YOLOv5 PyTorch model file. This results in a Python dict in which the actual YOLOv5 model is stored in the model field.
import torch
model_dict = torch.load("/path/to/model.pt")
model = model_dict["model"]
Change the names. The model.names field is a Python list that contains the names. Make sure you do not change the ordering of the names list. For example:
Requirements
pip install torch
model.pt
Steps
model
field.model.names
field is a Python list that contains the names. Make sure you do not change the ordering of the names list. For example:grep
: