YOLOv8
New in version 1.1
Overviews
YOLO stands for You Only Look Once
APIs
Model
Bases: BaseModel
build_model(model_path=None)
Load Yolo model for retraining Args: model_path(str): Custom path for loading weight. Default: model_path="model/yolov8{version}.pt"
Returns:
Name | Type | Description |
---|---|---|
model |
YOLO
|
created YOLO model |
fit()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data(str) |
input data.yaml |
required | |
epochs(int) |
number of epochs |
required | |
imgsz(int) |
Image size (640) |
required | |
device |
0,1,2,3 for GPU or device:cpu |
required | |
batch_size |
a number of samples processed before the model is updated |
required |
Returns:
Name | Type | Description |
---|---|---|
model_path |
str
|
default "runs/detect/train/weights/best.pt" |
get_transform()
Get image data transform function for preprocessing
Returns:
Name | Type | Description |
---|---|---|
transform |
func
|
transform function. This function will take input as image path and output - raw_image: image numpy mat - image_transform: image tensor (pytorch) Example: torchvision.transforms.transforms: data transforms function |
predict(source=None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source(str) |
file or folder for testing |
required |
Returns: folder_path(str): runs/detect/predict
process_predictions(net_output, raw_image_path, raw_image_mat, image_transform, save_image_path)
post process the output of the net
Parameters:
Name | Type | Description | Default |
---|---|---|---|
net_output |
_type_
|
output of detection net |
required |
raw_image_path |
str
|
raw image path |
required |
Returns:
Type | Description |
---|---|
save_image_path inform that the annotation image has been written successfully in the same directory contain the annotation image, the annotation text file will be named "annotated_image.txt" each line format (yolo): class, x, y, w, h, confidence, class_name |
validate()
Returns: metrics(list): Validated results