i wrote below command:
!pip install val
solved
now colab shows below error:
Traceback (most recent call last):
File “/content/train.py”, line 48, in
from models.experimental import attempt_load
ModuleNotFoundError: No module named ‘models’
hi i have below error:
Collecting models
Using cached models-0.9.3.tar.gz (16 kB)
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Preparing metadata (setup.py) … error
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
please help me
hi i solved above error. but unfortunately my images and labels files dont copy into below directories:
trainimagepath = '/content/yolov5/data/images/train'
trainlabelpath = '/content/yolov5/data/labels/train'
valimagepath = '/content/yolov5/data/images/val'
vallabelpath = '/content/yolov5/data/labels/val'
just one image and one label file(txt) have been copied into the Respective directories.
in below codes, shutil.copy dont work correctly and dont copy images and labels files into respective directories.
import os
import shutil
from random import choice
import pandas as pd
import pdb
imgs = []
xmls = []
train_path = '/content/yolov5/data/images/train'
val_path = '/content/yolov5/data/images/val'
source_path = '/content/drive/MyDrive/DOTADataset'
if not os.path.exists(train_path):
os.mkdir(train_path)
if not os.path.exists(val_path):
os.mkdir(val_path)
train_ratio = 0.8
val_ratio = 0.2
totalImgCount = len(os.listdir(source_path))/2
print(imgs)
for (dirname, dirs, files) in os.walk(source_path):
for filename in files:
if filename.endswith('.txt'):
xmls.append(filename)
else:
imgs.append(filename)
print(imgs)
# Total number of image files
countfortrain = int(len(imgs) * train_ratio)
countforval = int(len(imgs) * val_ratio)
print("Training images are:", countfortrain)
print("Validation images are:", countforval)
trainimagepath = '/content/yolov5/data/images/train'
trainlabelpath = '/content/yolov5/data/labels/train'
valimagepath = '/content/yolov5/data/images/val'
vallabelpath = '/content/yolov5/data/labels/val'
if not os.path.exists(trainimagepath):
os.mkdir(trainimagepath)
if not os.path.exists(trainlabelpath):
os.mkdir(trainlabelpath)
if not os.path.exists(valimagepath):
os.mkdir(valimagepath)
if not os.path.exists(vallabelpath):
os.mkdir(vallabelpath)
# imgs = os.listdir(trainimagepath)
for x in range(countfortrain):
print(imgs)
fileJpg = choice(imgs)
fileXml = fileJpg[:-4] +'.txt'
shutil.copy(os.path.join(source_path, fileJpg), os.path.join(trainimagepath,fileJpg))
shutil.copy(os.path.join(source_path, fileXml), os.path.join(trainlabelpath,fileXml))
print(imgs)
imgs.remove(fileJpg)
print(imgs)
xmls.remove(fileXml)
for x in range(countforval):
fileJpg = choice(imgs)
fileXml = fileJpg[:-4] +'.txt'
shutil.copy(os.path.join(source_path, fileJpg), os.path.join(valimagepath,fileJpg))
shutil.copy(os.path.join(source_path, fileXml), os.path.join(vallabelpath,fileXml))
imgs.remove(fileJpg)
xmls.remove(fileXml)
hi i have below error when i run this code: !python train.py --img 416 --batch 16 --epochs 10 --data dataset.yaml --weights yolov5s.pt
train: WARNING ⚠️ /content/yolov5/data/images/train/P0032.png: ignoring corrupt image/label: could not convert string to float: 'plane'
Traceback (most recent call last):
File "/content/yolov5/train.py", line 848, in <module>
main(opt)
File "/content/yolov5/train.py", line 623, in main
train(opt.hyp, opt, device, callbacks)
File "/content/yolov5/train.py", line 254, in train
train_loader, dataset = create_dataloader(
File "/content/yolov5/utils/dataloaders.py", line 181, in create_dataloader
dataset = LoadImagesAndLabels(
File "/content/yolov5/utils/dataloaders.py", line 608, in __init__
labels, shapes, self.segments = zip(*cache.values())
ValueError: not enough values to unpack (expected 3, got 0)