Shortcuts

imagenet_64 源代码

# Copyright (c) OpenMMLab. All rights reserved.
from mmengine.dataset.sampler import DefaultSampler

from mmagic.datasets.imagenet_dataset import ImageNet
from mmagic.datasets.transforms.aug_shape import Flip, Resize
from mmagic.datasets.transforms.crop import (CenterCropLongEdge,
                                             RandomCropLongEdge)
from mmagic.datasets.transforms.formatting import PackInputs
from mmagic.datasets.transforms.loading import LoadImageFromFile

# dataset settings
[文档]dataset_type = ImageNet
# different from mmcls, we adopt the setting used in BigGAN. # We use `RandomCropLongEdge` in training and `CenterCropLongEdge` in testing.
[文档]train_pipeline = [ dict(type=LoadImageFromFile, key='gt'), dict(type=RandomCropLongEdge, keys='gt'), dict(type=Resize, scale=(64, 64), keys='gt', backend='pillow'), dict(type=Flip, keys='gt', flip_ratio=0.5, direction='horizontal'), dict(type=PackInputs)
]
[文档]test_pipeline = [ dict(type=LoadImageFromFile, key='gt'), dict(type=CenterCropLongEdge, keys='gt'), dict(type=Resize, scale=(64, 64), keys='gt', backend='pillow'), dict(type=PackInputs)
]
[文档]train_dataloader = dict( batch_size=None, num_workers=5, dataset=dict( type=dataset_type, data_root='./data/imagenet/', ann_file='meta/train.txt', data_prefix='train', pipeline=train_pipeline), sampler=dict(type=DefaultSampler, shuffle=True), persistent_workers=True)
[文档]val_dataloader = dict( batch_size=64, num_workers=5, dataset=dict( type=dataset_type, data_root='./data/imagenet/', ann_file='meta/train.txt', data_prefix='train', pipeline=test_pipeline), sampler=dict(type=DefaultSampler, shuffle=False), persistent_workers=True)
[文档]test_dataloader = val_dataloader
Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.