-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Reading/ignoring corrupt images with Gluon data loader (imdecode error cannot be captured) #12280
Comments
@anirudhacharya Can you have a look at the error catching problem? |
@mxnet-label-bot : [Gluon, Bug] |
@mqtlam Seems like the PR for the fix got merged recently. |
@mqtlam A PR was merged fixing this issue, requesting a verification of resolution. |
@mxnet-label-bot add [Pending Requester Info] |
@mqtlam Hi since the issue, has been resolved in a PR, I am requesting committers to close this issue, Feel free to reopen it if the error persists on your side @sandeep-krishnamurthy Requesting to close this issue since it has been resolved in a PR |
Is this issue in open mode? |
@Tigerwander this issue should be fixed. Please open a new issue |
Hey, have you solved this problem, I am now in same problem, and does not find satisfactory answer |
是的这个问题让我觉得mxnet有点繁琐,就像一个套套一样。无法直达目标。 |
Description
Short Version
mxnet.image.imdecode
crashes and hangs when loading certain corrupt images using Gluon data loader. One possible workaround is to wrap a try/except block aroundimdecode
, but Python try/except cannot captureMXNetError
.Long Version
I am working with a very large dataset that it is impractical to clean all images beforehand. Currently, when using Gluon data loader, loading a corrupt image crashes in
imdecode
with anMXNetError
exception (see Error Message below) and then hangs. Ultimately, I would like the Gluon data loader to ignore corrupt images instead of crashing.My idea to work around this issue is as follows: wrap the
imdecode
with a try/catch block and whenever an exception occurs, simply return a dummy image (and label). Given the dummy image/label during training, I can ignore backpropagating that sample. I've tried that (see What have you tried to solve it? below) but it does not work because Python try/catch cannot captureMXNetError
.I think there should be a mechanism to capture an error from
imdecode
orimread
(both frommxnet.image
) rather than crashing, unless I am missing something.Environment info (Required)
Package used (Python/R/Scala/Julia): Python
Build info (Required if built from source)
Compiler (gcc/clang/mingw/visual studio): gcc
MXNet commit hash: a6ecb59
Build config:
Error Message:
Minimum reproducible example
Run
train_imagenet.py
from GluonCV (/~https://github.com/dmlc/gluon-cv/blob/master/scripts/classification/imagenet/train_imagenet.py with commit hash 863f19bc86cda0f785b97c39a360fbd8cbd1b0e1) on a training dataset with corrupted images (e.g., an image with 0 bytes).What have you tried to solve it?
ImageFolderDataset
below so that it could handle corrupt images in theory. The try/catch does not captureMXNetError
.image.imread
withcv2.imread
(directly using OpenCV) in the above code. It seemed to work on some images but still crashes eventually, which may meanmxnet.image.imdecode
is running somewhere else too? I have not explored this yet.The text was updated successfully, but these errors were encountered: