You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/11/21 00:33:14 UTC
[GitHub] piiswrong opened a new pull request #8736: Fix python code.
piiswrong opened a new pull request #8736: Fix python code.
URL: https://github.com/apache/incubator-mxnet/pull/8736
Gets 4000 fps with this.
```
import os
os.environ['MXNET_CPU_WORKER_NTHREADS'] = '1'
os.environ['OMP_NUM_THREADS'] = '1'
import time
import numpy as np
import multiprocessing as mp
import mxnet as mx
from mxnet import gluon as gl
from mxnet.gluon.data.vision import transforms
if __name__ == '__main__':
M = 24
BS = 100
dataset = gl.data.vision.ImageFolderDataset('../256_ObjectCategories')
transform = transforms.Compose([transforms.ToTensor(),
transforms.RandomBrightness(1.0),
transforms.RandomContrast(1.0),
transforms.RandomSaturation(1.0),
transforms.Normalize([0, 0, 0], [1, 1, 1])])
dataset = dataset.transform_first(lambda x: transform(mx.image.center_crop(x, (224, 224))[0]))
data_loader = gl.data.DataLoader(dataset, BS, shuffle=True, num_workers=M)
N = len(dataset)
iterator = iter(data_loader)
tic = time.time()
for data, label in iterator:
data.wait_to_read()
print(data.shape)
print(N/(time.time() - tic))
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services