zw_sd
April 13, 2021, 2:10am
1
I am using jetson-inference/python/training/classification/train.py to train my model.
In the training images, there are .png and .jpg images.
I just found that the .jpg images was not trained.
Is there a quick way to make the .jpg be train with .png images?
Thank you.
Hi,
jetson-inference uses torchvision for loading image data.
print("Use GPU: {} for training".format(args.gpu))
if args.distributed:
if args.dist_url == "env://" and args.rank == -1:
args.rank = int(os.environ["RANK"])
if args.multiprocessing_distributed:
# For multiprocessing distributed training, rank needs to be the
# global rank among all the processes
args.rank = args.rank * ngpus_per_node + gpu
dist.init_process_group(backend=args.dist_backend, init_method=args.dist_url,
world_size=args.world_size, rank=args.rank)
# data loading code
traindir = os.path.join(args.data, 'train')
valdir = os.path.join(args.data, 'val')
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
train_dataset = datasets.ImageFolder(
traindir,
transforms.Compose([
Based on the document below, torchvision should support both .jpg
and .png
file extension:
https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py#L234
IMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif', '.tiff', '.webp')
Could you validate if the data is stored in the recommended placement first:
https://pytorch.org/vision/stable/datasets.html
root/dog/xxx.png
root/dog/xxy.png
root/dog/[...]/xxz.png
root/cat/123.png
root/cat/nsdf3.png
root/cat/[...]/asd932_.png
Thanks.
zw_sd
April 13, 2021, 8:08am
4
thank you @AastaLLL for your quickly response.
for now I converted .jpg files to .png.
I just found that maybe just because I made a mistake when detecting the images. :P
Let me check further. :)
Sure. Thanks for the update !