8000 fix both document and a bug for RandomCrop by Neutron3529 · Pull Request #1389 · dmlc/gluon-cv · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix both document and a bug for RandomCrop #1389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 10, 2020
Merged

Conversation

Neutron3529
Copy link
Contributor

RandomCrop pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default pad=None

>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment

This PR is intend to fix both the document and the BUG which caused pad cannot be optional.

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.
make pylint happy.
happy-2
@mli
Copy link
Member
mli commented Jul 28, 2020

Job PR-1389-3 is done.
Docs are uploaded to http://gluon-vision-staging.s3-website-us-west-2.amazonaws.com/PR-1389/3/index.html
Code coverage of this PR: pr.svg vs. Master: master.svg

@Neutron3529 Neutron3529 reopened this Jul 28, 2020
@mli
Copy link
Member
mli commented Jul 28, 2020

Job PR-1389-4 is done.
Docs are uploaded to http://gluon-vision-staging.s3-website-us-west-2.amazonaws.com/PR-1389/4/index.html
Code coverage of this PR: pr.svg vs. Master: master.svg

Copy link
Member
@zhreshold zhreshold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise fantastic!

return image.random_crop(nd.array(x_pad), *self._args)[0]

self.pad = ((pad, pad), (pad, pad), (0, 0)) if isinstance(pad, int) else pad
self.forward = self.forward_pad if self.pad else self.forward_nopad
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you avoid using monkey patch (self.forward_pad self.forward_nopad) but switch inside self.forward? it might be easier to catch error for single forward function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.
I just think using a monkey patch is better than using if since it should be faster.

@mli
Copy link
Member
mli commented Aug 7, 2020

Job PR-1389-5 is done.
Docs are uploaded to http://gluon-vision-staging.s3-website-us-west-2.amazonaws.com/PR-1389/5/index.html
Code coverage of this PR: pr.svg vs. Master: master.svg

I just think monkey patch may goes faster than the useless switch in the forward step
@mli
Copy link
Member
mli commented Aug 9, 2020

Job PR-1389-7 is done.
Docs are uploaded to http://gluon-vision-staging.s3-website-us-west-2.amazonaws.com/PR-1389/7/index.html
Code coverage of this PR: pr.svg vs. Master: master.svg

@zhreshold zhreshold merged commit 1e90f7e into dmlc:master Aug 10, 2020
@zhreshold
Copy link
Member

@Neutron3529 Thanks for the update! this is merged

zhreshold added a commit that referenced this pull request Aug 30, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Oct 20, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Oct 29, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Nov 6, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* Revert "sanity checks"

This reverts commit 116be00.

* cifarresnext for MXNet-master

* cifarwideresnet for MXNet-master

* sanity checks

* pylint

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Nov 6, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* mxnet master for cifarresnet

* Mxnet master for cifarwideresnet

* Mxnet-master for cifarwideresnet

* cifarresnext for MXNet master

* cifarresnext for MXNet-master

* miss a hybrid forward

* seresnet

* @use_np

* @use_np

* sanity

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Nov 6, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* mxnet master for cifarresnet

* Mxnet master for cifarwideresnet

* Mxnet-master for cifarwideresnet

* cifarresnext for MXNet master

* cifarresnext for MXNet-master

* miss a hybrid forward

* pylint

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Nov 6, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* mxnet master for cifarresnet

* Mxnet master for cifarwideresnet

* Mxnet-master for cifarwideresnet

* residual

* sanity

* sanity

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
jinboci added a commit to jinboci/gluon-cv that referenced this pull request Nov 7, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (dmlc#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (dmlc#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* Revert "sanity checks"

This reverts commit 116be00.

* cifarresnext for MXNet-master

* cifarwideresnet for MXNet-master

* sanity checks

* pylint

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
jinboci added a commit to jinboci/gluon-cv that referenced this pull request Nov 7, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (dmlc#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (dmlc#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* mxnet master for cifarresnet

* Mxnet master for cifarwideresnet

* Mxnet-master for cifarwideresnet

* cifarresnext for MXNet master

* cifarresnext for MXNet-master

* miss a hybrid forward

* seresnet

* @use_np

* @use_np

* sanity

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
jinboci added a commit to jinboci/gluon-cv that referenced this pull request Nov 7, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (dmlc#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (dmlc#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* mxnet master for cifarresnet

* Mxnet master for cifarwideresnet

* Mxnet-master for cifarwideresnet

* residual

* sanity

* sanity

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
jinboci added a commit to jinboci/gluon-cv that referenced this pull request Nov 7, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (dmlc#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (dmlc#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* Revert "sanity checks"

This reverts commit 116be00.

* cifarresnext for MXNet-master

* cifarwideresnet for MXNet-master

* sanity checks

* pylint

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
jinboci added a commit to jinboci/gluon-cv that referenced this pull request Nov 7, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (dmlc#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (dmlc#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* mxnet master for cifarresnet

* Mxnet master for cifarwideresnet

* Mxnet-master for cifarwideresnet

* cifarresnext for MXNet master

* cifarresnext for MXNet-master

* miss a hybrid forward

* seresnet

* @use_np

* @use_np

* sanity

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
jinboci added a commit to jinboci/gluon-cv that referenced this pull request Nov 7, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (dmlc#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (dmlc#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* mxnet master for cifarresnet

* Mxnet master for cifarwideresnet

* Mxnet-master for cifarwideresnet

* residual

* sanity

* sanity

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Nov 23, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* only modify resnet

* sanity checks for resnet.py

* make pull request to rerun CI

* py3.yml->mxnet master

* mxnet_cu100-2.0.0b

* mxnet_cu100-2.0.0b20200910-py2.py3-none-manylinux2014_x86_64.whl

* pip=20.2.4

* pip=20.1.1

* https://repo.mxnet.io/dist/python/cpu/mxnet-2.0.0b20200908-py2.py3-none-manylinux2014_x86_64.whl

* fix error caused by weakref

* disable import from mxnet.contrib.quantization

* mxnet master for cifarresnet

* sanity checks

* mxnet master for cifarresnet

* Mxnet master for cifarwideresnet

* Mxnet-master for cifarwideresnet

* groupnorm

* gn

* pylint

* confliction of np

* # pylint: disable=unused-import

* set beta and gamma to default

* fix gn

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Nov 23, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* Numpy API: cifar danet deeplab fcn pspnet...

* commit message

* resnest for mxnet-master

* resnest for mxnet master

* remove unrelated files

* remove unrelated files

* sanity

* sanity

* sanity

* fixing error

* fix resnest

* resnext for mxnet-master

* fix test_model_zoo

* gluoncv/model_zoo/resnext.py:201:86: W0613: Unused argument 'stage_index' (unused-argument)

* Unused argument 'stage_index' (unused-argument)

* senet for mxnet-master

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Nov 24, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* Numpy API: cifar danet deeplab fcn pspnet...

* commit message

* resnest for mxnet-master

* resnest for mxnet master

* remove unrelated files

* remove unrelated files

* sanity

* sanity

* sanity

* fixing error

* fix resnest

* resnext for mxnet-master

* fix test_model_zoo

* gluoncv/model_zoo/resnext.py:201:86: W0613: Unused argument 'stage_index' (unused-argument)

* Unused argument 'stage_index' (unused-argument)

* senet for mxnet-master

* mobilenet for mxnet-master

* sanity

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Dec 18, 2020
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* Numpy API: cifar danet deeplab fcn pspnet...

* commit message

* resnest for mxnet-master

* resnest for mxnet master

* remove unrelated files

* remove unrelated files

* sanity

* sanity

* sanity

* fixing error

* fix resnest

* resnext for mxnet-master

* fix test_model_zoo

* gluoncv/model_zoo/resnext.py:201:86: W0613: Unused argument 'stage_index' (unused-argument)

* Unused argument 'stage_index' (unused-argument)

* senet for mxnet-master

* squeezenet for mxnet master

* squeezenet for mxnet master

* model_store enable squeezenet pretrained

* squeeze params changes

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Jan 15, 2021
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* Numpy API: cifar danet deeplab fcn pspnet...

* commit message

* resnest for mxnet-master

* resnest for mxnet master

* remove unrelated files

* remove unrelated files

* sanity

* sanity

* sanity

* fixing error

* fix resnest

* resnext for mxnet-master

* fix test_model_zoo

* gluoncv/model_zoo/resnext.py:201:86: W0613: Unused argument 'stage_index' (unused-argument)

* Unused argument 'stage_index' (unused-argument)

* senet for mxnet-master

* mobilenet for mxnet-master

* sanity

* mobilenetv3 for mxnet master

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Jan 15, 2021
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* Numpy API: cifar danet deeplab fcn pspnet...

* commit message

* resnest for mxnet-master

* resnest for mxnet master

* remove unrelated files

* remove unrelated files

* sanity

* sanity

* sanity

* fixing error

* fix resnest

* resnext for mxnet-master

* fix test_model_zoo

* gluoncv/model_zoo/resnext.py:201:86: W0613: Unused argument 'stage_index' (unused-argument)

* Unused argument 'stage_index' (unused-argument)

* senet for mxnet-master

* mobilenet for mxnet-master

* sanity

* mobilenetv3 for mxnet master

* darknet only for mxnet master

* from .yolo import *

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Jan 15, 2021
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* Numpy API: cifar danet deeplab fcn pspnet...

* commit message

* resnest for mxnet-master

* resnest for mxnet master

* remove unrelated files

* remove unrelated files

* sanity

* sanity

* sanity

* fixing error

* fix resnest

* resnext for mxnet-master

* fix test_model_zoo

* gluoncv/model_zoo/resnext.py:201:86: W0613: Unused argument 'stage_index' (unused-argument)

* Unused argument 'stage_index' (unused-argument)

* senet for mxnet-master

* mobilenet for mxnet-master

* sanity

* mobilenetv3 for mxnet master

* darknet only for mxnet master

* from .yolo import *

* test nn

* alexnet for mxnet master

* alexnet for mxnet master

* make pull request

* fix gn errors

* model store update

* Update model_store.py

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Jan 15, 2021
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* Numpy API: cifar danet deeplab fcn pspnet...

* commit message

* resnest for mxnet-master

* resnest for mxnet master

* remove unrelated files

* remove unrelated files

* sanity

* sanity

* sanity

* fixing error

* fix resnest

* resnext for mxnet-master

* fix test_model_zoo

* gluoncv/model_zoo/resnext.py:201:86: W0613: Unused argument 'stage_index' (unused-argument)

* Unused argument 'stage_index' (unused-argument)

* senet for mxnet-master

* mobilenet for mxnet-master

* sanity

* mobilenetv3 for mxnet master

* darknet only for mxnet master

* from .yolo import *

* test nn

* alexnet for mxnet master

* alexnet googlenet for mxnet master

* fix test nn

* googlenet for mxnet master

* use_np

* model_store

* Update model_store.py

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Jan 15, 2021
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* Numpy API: cifar danet deeplab fcn pspnet...

* commit message

* resnest for mxnet-master

* resnest for mxnet master

* remove unrelated files

* remove unrelated files

* sanity

* sanity

* sanity

* fixing error

* fix resnest

* resnext for mxnet-master

* fix test_model_zoo

* gluoncv/model_zoo/resnext.py:201:86: W0613: Unused argument 'stage_index' (unused-argument)

* Unused argument 'stage_index' (unused-argument)

* senet for mxnet-master

* mobilenet for mxnet-master

* sanity

* mobilenetv3 for mxnet master

* densenet for mxnet master

* darknet only for mxnet master

* from .yolo import *

* test nn

* alexnet for mxnet master

* alexnet googlenet for mxnet master

* fix test nn

* vgg for mxnet master

* change model store

* update pretrained models

* update model_store

* Trigger Build

* Trigger Build

* Trigger Build

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Jan 15, 2021
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* Numpy API: cifar danet deeplab fcn pspnet...

* commit message

* resnest for mxnet-master

* resnest for mxnet master

* remove unrelated files

* remove unrelated files

* sanity

* sanity

* sanity

* fixing error

* fix resnest

* resnext for mxnet-master

* fix test_model_zoo

* gluoncv/model_zoo/resnext.py:201:86: W0613: Unused argument 'stage_index' (unused-argument)

* Unused argument 'stage_index' (unused-argument)

* senet for mxnet-master

* mobilenet for mxnet-master

* sanity

* mobilenetv3 for mxnet master

* darknet only for mxnet master

* from .yolo import *

* test nn

* alexnet for mxnet master

* alexnet googlenet for mxnet master

* fix test nn

* vgg for mxnet master

* change model store

* vgg model_store

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
zhreshold added a commit that referenced this pull request Jan 15, 2021
* resnet.py numpy

* fix both document and a bug for RandomCrop (#1389)

* fix both document and a bug for RandomCrop

`RandomCrop` pad first and then crop, not what is said in the document or even CIFAR tutorials.

further, an error occurs with the default `pad=None`
```
>>> for i in train_data:break
... 
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in _worker_fn
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 450, in <listcomp>
    batch = batchify_fn([_worker_dataset[i] for i in samples])
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 219, in __getitem__
    return self._fn(*item)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataset.py", line 230, in __call__
    return (self._fn(x),) + args
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/nn/basic_layers.py", line 55, in forward
    x = block(x)
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 693, in __call__
    out = self.forward(*args)
  File "/home/neutron/.local/lib/python3.8/site-packages/gluoncv/data/transforms/block.py", line 75, in forward
    return image.random_crop(nd.array(x_pad), *self._args)[0]
UnboundLocalError: local variable 'x_pad' referenced before assignment
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neutron/.local/lib/python3.8/site-packages/mxnet/gluon/data/dataloader.py", line 505, in __next__
    batch = pickle.loads(ret.get(self._timeout))
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
UnboundLocalError: local variable 'x_pad' referenced before assignment
```



This PR is intend to fix both the document and the BUG which caused `pad` cannot be optional.

* make pylint happy.

make pylint happy.

* happy-2

happy-2

* remove monkey patch

I just think monkey patch may goes faster than the useless switch in the forward step

* make checkers happy

* fix CI checks

* Update resnet.py

* Update resnet.py

* Update resnet.py

* bump up to 0.9 pre (#1412)

* bump up to 0.9 pre

* fix nightly build mxnet

* Update resnet.py

* fixing ci

* Revert "fixing ci"

This reverts commit d2daaa3.

* Update resnet.py

* fix ci checks err

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci check errors

* fix ci sanity check errors

* fix ci check errors

* fix ci check errors

* fix type errors add as_nd_ndarray

* fix ci check errors

* modifying ssd.py resnet.py anchor.py

* fix sanity check errors

* fix sanity check warnings

* modifying batchify,py rcnn.py anchor.py rpn_target

* fix rpn_target.py sanity

* modify batchify.py sanity checks

* revert gluoncv/data/batchify.py to 1d84cae

* modifying batchify.py

* ssd.py nd.concat with as_np_ndarray

* ssd.py nd.concat with as_np_ndarray

* errors still exist

* fix ci check errors

* fix sanity check errors

* fix sanity check, modify matcher.py

* disable unittest of ssd

* fix test_data_transforms.py

* disable all unnecessary

* disable unnecessay tests for resnet.py

* import unittest test_nn utils_bbox metric parallel

* disable uncessary tests for resnet

* skip test_get_all_models

* disable unnecessary tests

* disable more test cases

* disable resnet_v1b tests

* fix tests bugs in test_model_zoo.py

* disable tests for resnest

* disable tests for se_resnet

* disable nasnet tests

* disable other tests

* disable more tests

* fix carelessness

* disable tests

* import unittest

* unuse as_np_ndarray()

* convert inputs to numpy ndarray

* revert all changes except resnet.py

* modifying image.py

* Numpy API: cifar danet deeplab fcn pspnet...

* commit message

* resnest for mxnet-master

* resnest for mxnet master

* remove unrelated files

* remove unrelated files

* sanity

* sanity

* sanity

* fixing error

* fix resnest

* resnext for mxnet-master

* fix test_model_zoo

* gluoncv/model_zoo/resnext.py:201:86: W0613: Unused argument 'stage_index' (unused-argument)

* Unused argument 'stage_index' (unused-argument)

* senet for mxnet-master

* mobilenet for mxnet-master

* sanity

* mobilenetv3 for mxnet master

* densenet for mxnet master

* squeezenet

* darknet only for mxnet master

* from .yolo import *

* test nn

* alexnet for mxnet master

* alexnet googlenet for mxnet master

* fix test nn

* vgg for mxnet master

* change model store

* update pretrained models

* update model_store

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* fix ci issues

* fix bugs

* with np_shape(False):

* sanity

* with np_shape(False):

* sanity

* mx.np_shape

* Update resnetv1b_pruned.py

* Update resnetv1b_pruned.py

* fixing

* try fixing

* try fixing

* sanity

* sanity

* revert changes for pruned

* Trigger Build

Co-authored-by: jinboci <cijinbo@outlook.com>
Co-authored-by: Neutron3529 <qweytr_1@163.com>
Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-29-176.ap-northeast-1.compute.internal>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0