Skip to content

imread_('/train/img/1728.bmp'): can't read header: OpenCV(4.5.1) /tmp/pip-req-build-7m_g9lbm/opencv/modules/imgcodecs/src/bitstrm.cpp:110: error: (-2:Unspecified error) Unexpected end of input stream in function 'readBlock' #767

@Lebesgue-zyker

Description

@Lebesgue-zyker

When running the program, cv2. imread() will report an error after running dozens of epochs successfully. The error content is as follows.
When I run dozens of epochs in the resume model, the same error will be reported on different images

imread_('/gemini/code/LUSTER/DATA/word_extract/real/datasets/detection/train/img/Front_0000000000000024709_13248_1728.bmp'):
 can't read header: OpenCV(4.5.1) /tmp/pip-req-build-7m_g9lbm/opencv/modules/imgcodecs/src/bitstrm.cpp:110: error: (-2:Unspecified error) Unexpected end of input stream in function 'readBlock'

Traceback (most recent call last):
  File "train.py", line 207, in <module>
    train_net(config)
  File "train.py", line 111, in train_net
    for batch_idx, (imgs, gts, gt_masks, thresh_maps, thresh_masks) in enumerate(train_loader):
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 681, in __next__
    data = self._next_data()
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1376, in _next_data
    return self._process_data(data)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1402, in _process_data
    data.reraise()
  File "/usr/local/lib/python3.7/dist-packages/torch/_utils.py", line 461, in reraise
    raise exception
AttributeError: Caught AttributeError in DataLoader worker process 11.
Original Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
    data = fetcher.fetch(index)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/gemini/code/LUSTER/Detection/DBnet-lite/dataloader/dataload.py", line 75, in __getitem__
    img, polys = self.ra.random_scale(img, polys, 640, gt_path)
  File "/gemini/code/LUSTER/Detection/DBnet-lite/dataloader/random_thansform.py", line 182, in random_scale
    h, w = img.shape[0:2]
AttributeError: 'NoneType' object has no attribute 'shape'

The specific code is

class DataLoader(data.Dataset):
    def __init__(self, config):
        self.config = config
        self.ra = Random_Augment()
        self.ms = MakeSegDetectionData()
        self.mb = MakeBorderMap()
        img_paths = glob.glob(os.path.join(config['train']['train_img_dir'], '*' + config['train']['train_img_format']))
        gt_paths = []

        for img_path in img_paths:
            im_name = img_path.split('/')[-1].split('.')[0]
            if (config['train']['is_icdar2015']):
                gt_file_name = 'gt_' + im_name + '.txt'
            else:
                gt_file_name = im_name + '.txt'
            gt_paths.append(os.path.join(config['train']['train_gt_dir'], gt_file_name))
        self.img_paths = img_paths
        self.gt_paths = gt_paths

    def __len__(self):
        return len(self.img_paths)

    img_path = self.img_paths[index]
    gt_path = self.gt_paths[index]

    def __getitem__(self, index):
        img_path = self.img_paths[index]
        gt_path = self.gt_paths[index]

        img = cv2.imread(img_path)
        h, w = img.shape[0:2]

version list:

absl-py                        1.0.0
addict                         2.4.0
antlr4-python3-runtime         4.8
anyconfig                      0.13.0
anyio                          3.5.0
appdirs                        1.4.4
argon2-cffi                    21.3.0
argon2-cffi-bindings           21.2.0
arrow                          1.2.2
asynctest                      0.13.0
attrs                          21.4.0
Babel                          2.10.3
backcall                       0.2.0
beautifulsoup4                 4.11.1
bleach                         5.0.1
cachetools                     4.2.4
certifi                        2021.10.8
cffi                           1.15.1
chardet                        3.0.4
charset-normalizer             2.0.7
click                          8.1.3
codecov                        2.1.12
colorama                       0.4.4
conda-pack                     0.6.0
coverage                       6.5.0
cycler                         0.10.0
debugpy                        1.6.2
decorator                      5.1.1
defusedxml                     0.7.1
dill                           0.3.5.1
distro                         1.8.0
dpcpp-cpp-rt                   2022.1.0
editdistance                   0.6.2
entrypoints                    0.4
exceptiongroup                 1.0.4
fastapi                        0.74.1
fastjsonschema                 2.16.1
flake8                         5.0.4
Flask                          2.2.2
flatbuffers                    2.0
fonttools                      4.28.1
future                         0.18.2
gevent                         22.10.2
gevent-websocket               0.10.1
google-auth                    2.3.3
google-auth-oauthlib           0.4.6
graphsurgeon                   0.4.5
greenlet                       2.0.1
grpcio                         1.42.0
h11                            0.14.0
h5py                           3.7.0
httpcore                       0.16.3
httpx                          0.23.1
idna                           3.3
imageio                        2.13.1
imgaug                         0.4.0
imgviz                         1.4.1
importlib-metadata             4.2.0
importlib-resources            5.8.0
iniconfig                      1.1.1
intel-cmplr-lib-rt             2022.1.0
intel-cmplr-lic-rt             2022.1.0
intel-opencl-rt                2022.1.0
intel-openmp                   2022.1.0
ipykernel                      6.15.1
ipython                        7.34.0
ipython-genutils               0.2.0
ipywidgets                     7.7.1
isort                          5.11.3
itsdangerous                   2.1.2
jedi                           0.18.1
Jinja2                         3.1.2
json5                          0.9.8
jsonschema                     4.7.2
jupyter-client                 7.3.4
jupyter-core                   4.11.1
jupyter-server                 1.18.1
jupyterlab                     3.4.3
jupyterlab-language-pack-zh-CN 3.4.post1
jupyterlab-pygments            0.2.2
jupyterlab-server              2.15.0
jupyterlab-widgets             1.1.1
kiwisolver                     1.3.1
kwarray                        0.6.5
labelme                        5.0.0
lanms-neo                      1.0.2
lmdb                           1.2.1
loguru                         0.6.0
lxml                           4.9.2
Mako                           1.2.0
Markdown                       3.3.6
MarkupSafe                     2.1.1
matplotlib                     3.2.2
matplotlib-inline              0.1.3
mccabe                         0.7.0
mistune                        0.8.4
mkl                            2022.1.0
mkl-fft                        1.3.0
mkl-random                     1.2.2
mkl-service                    2.3.0
mmcv-full                      1.4.0
mmdeploy                       0.2.0
multiprocess                   0.70.13
munch                          2.5.0
natsort                        8.1.0
nbclassic                      0.4.3
nbclient                       0.6.6
nbconvert                      6.5.0
nbformat                       5.4.0
nest-asyncio                   1.5.5
networkx                       2.6.3
notebook                       6.4.12
notebook-shim                  0.1.0
numpy                          1.21.4
oauthlib                       3.1.1
olefile                        0.46
onnx                           1.12.0
onnxruntime                    1.8.1
opencv-python                  4.6.0.66
packaging                      21.2
pandas                         1.3.4
pandocfilters                  1.5.0
parso                          0.8.3
pexpect                        4.8.0
pickleshare                    0.7.5
Pillow                         8.4.0
pip                            22.3.1
platformdirs                   2.5.2
pluggy                         1.0.0
polygon                        1.1.0
Polygon3                       3.0.9.1
prefetch-generator             1.0.1
prometheus-client              0.14.1
prompt-toolkit                 3.0.30
protobuf                       3.19.1
psutil                         5.8.0
ptyprocess                     0.7.0
pyasn1                         0.4.8
pyasn1-modules                 0.2.8
pyclipper                      1.3.0.post4
pycocotools                    2.0.4
pycodestyle                    2.9.1
pycparser                      2.21
pycryptodomex                  3.11.0
pycuda                         2022.1
pydantic                       1.9.0
pyflakes                       2.5.0
Pygments                       2.12.0
PyGObject                      3.26.1
pyparsing                      2.4.7
PyQt5                          5.15.6
PyQt5-Qt5                      5.15.2
PyQt5-sip                      12.9.1
pyrsistent                     0.18.1
pytest                         7.2.0
pytest-cov                     4.0.0
pytest-runner                  6.0.0
python-dateutil                2.8.2
pytils                         0.4.1
pytools                        2022.1.12
pytz                           2021.3
PyWavelets                     1.2.0
PyYAML                         6.0
pyzmq                          23.2.0
QtPy                           2.0.1
rapidfuzz                      2.13.6
regex                          2022.6.2
requests                       2.26.0
requests-oauthlib              1.3.0
rfc3986                        1.5.0
rsa                            4.7.2
scikit-build                   0.16.4
scikit-image                   0.18.3
scipy                          1.7.2
Send2Trash                     1.8.0
setuptools                     52.0.0
setuptools-scm                 6.3.2
shapely                        2.0.0
six                            1.16.0
sniffio                        1.2.0
sortedcontainers               2.4.0
soupsieve                      2.3.2.post1
SQLAlchemy                     1.4.31
ssh-import-id                  5.7
starlette                      0.17.1
tabulate                       0.9.0
tbb                            2021.6.0
tensorboard                    2.7.0
tensorboard-data-server        0.6.1
tensorboard-plugin-wit         1.8.0
tensorboardX                   2.5.1
tensorrt                       8.2.3.0
termcolor                      1.1.0
terminado                      0.15.0
terminaltables                 3.1.10
tifffile                       2021.11.2
tinycss2                       1.1.1
tomli                          1.2.2
tools                          0.1.9
torch                          1.12.1+cu113
torchaudio                     0.12.1+cu113
torchvision                    0.13.1+cu113
tornado                        6.2
tqdm                           4.31.1
traitlets                      5.3.0
typing_extensions              4.2.0
ubelt                          1.2.3
uff                            0.6.9
urllib3                        1.26.7
wcwidth                        0.2.5
webencodings                   0.5.1
websocket-client               1.3.3
websockets                     10.4
Werkzeug                       2.2.2
wheel                          0.37.0
widgetsnbextension             3.6.1
win32-setctime                 1.1.0
wincertstore                   0.2
xdoctest                       1.1.0
xmltodict                      0.13.0
yacs                           0.1.8
yapf                           0.32.0
zipp                           3.6.0
zope.event                     4.6
zope.interface                 5.5.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions