I'm trying to train a yolov8 nano model with the following py script:
我正试图用以下py脚本训练一个yolov8纳米模型:
from ultralytics import YOLO
# Load the model.
model = YOLO('yolov8n.pt')
# Training.
results = model.train(
data='pothole.yaml',
imgsz=1280,
epochs=10,
batch=8,
name='yolov8n_v8_50e'
)
However, I run into the following error about 5 minutes into running the script:
然而,在运行脚本大约5分钟后,我遇到了以下错误:
Retrying (Retry(total=233, connect=233, read=240, redirect=240, status=240)) after connection broken by 'NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x2a093e6d0>: Failed to resolve 'api.clear.ml' ([Errno 8] nodename nor servname provided, or not known)")': /auth.login
Any suggestions? I've already tried updating urllib3 and ultralytics...
有什么建议吗?我已经尝试过更新urllib3和ultralytics。。。
更多回答
优秀答案推荐
Your error seems to be related to incorrect setup with ClearML. If you don't need it, just uninstall like this:
您的错误似乎与ClearML的错误设置有关。如果你不需要它,只需像这样卸载:
pip uninstall clearml
You can set it up again later, but you probably don't even need it.
你可以稍后重新设置,但你可能根本不需要它。
Try to disable the clearml logging by set to false the parameter shown in the following pic! You can find it in the ultralytics folder.
尝试通过将以下图片中显示的参数设置为false来禁用clearml日志记录!你可以在ultralytics文件夹中找到它。
This works for me (I used the pothole zipped dataset from here and the corresponding data.yaml
):
这对我来说很有效(我使用了这里的坑洞压缩数据集和相应的数据。yaml):
from ultralytics import YOLO
# Load a model
model = YOLO('yolov8n.yaml') # build a new model from scratch
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
# train the model (run on GPU, e.g., on colab)
results = model.train(data='data.yaml', epochs=3)
# Starting training for 3 epochs...
#
# Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
# 1/3 2.59G 1.667 2.68 1.544 7 640: 100%|██████████| 30/30 [00:14<00:00, 2.09it/s]
# Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 5/5 [00:03<00:00, 1.65it/s]
# all 133 330 0.885 0.0515 0.224 0.126
#
# Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
# 2/3 2.36G 1.507 1.927 1.375 2 640: 100%| ██████████| 30/30 [00:10<00:00, 2.99it/s]
# Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 5/5 [00:01<00:00, 3.53it/s]
# all 133 330 0.59 0.258 0.312 0.159
#
# Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
# 3/3 2.24G 1.453 1.75 1.347 2 640: 100%|██████████| 30/30 [00:10<00:00, 2.85it/s]
# Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 5/5 [00:01<00:00, 3.35it/s]
# all 133 330 0.682 0.561 0.606 0.332
Once the model is fine-tuned on the pothole images, we can use the model to predict the potholes in the following test image:
一旦模型在坑洞图像上进行了微调,我们就可以使用该模型来预测以下测试图像中的坑洞:
# predict on an image
results = model('test.jpg')
# plot the bounding boxes of potholes predicted
for r in results:
im_array = r.plot() # plot a BGR numpy array of predictions
im = Image.fromarray(im_array[..., ::-1]) # RGB PIL image
plt.imshow(im)
plt.axis('off')
plt.show()
更多回答
我是一名优秀的程序员,十分优秀!