Skip to content
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

TypeError: a bytes-like object is required, not 'NoneType' #29

Open
cymisyourdad opened this issue Aug 1, 2019 · 4 comments
Open

TypeError: a bytes-like object is required, not 'NoneType' #29

cymisyourdad opened this issue Aug 1, 2019 · 4 comments

Comments

@cymisyourdad
Copy link

Traceback (most recent call last):
File "bin/train_siamfc.py", line 9, in
Fire(train)
File "/home/lab/anaconda3/envs/siamfc/lib/python3.6/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/home/lab/anaconda3/envs/siamfc/lib/python3.6/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/home/lab/anaconda3/envs/siamfc/lib/python3.6/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, **kwargs)
File "/home/lab/cym/siamfc/SiamFC-PyTorch/siamfc/train.py", line 94, in train
for i, data in enumerate(tqdm(trainloader)):
File "/home/lab/anaconda3/envs/siamfc/lib/python3.6/site-packages/tqdm/_tqdm.py", line 1017, in iter
for obj in iterable:
File "/home/lab/anaconda3/envs/siamfc/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 582, in next
return self._process_next_batch(batch)
File "/home/lab/anaconda3/envs/siamfc/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
TypeError: Traceback (most recent call last):
File "/home/lab/anaconda3/envs/siamfc/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/lab/anaconda3/envs/siamfc/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/lab/cym/siamfc/SiamFC-PyTorch/siamfc/dataset.py", line 62, in getitem
exemplar_img = self.imread(exemplar_name)
File "/home/lab/cym/siamfc/SiamFC-PyTorch/siamfc/dataset.py", line 35, in imread
img_buffer = np.frombuffer(img_buffer, np.uint8)
TypeError: a bytes-like object is required, not 'NoneType'

@DavidZhangdw
Copy link

I also meet the problem, have you issued?

@cymisyourdad
Copy link
Author

cymisyourdad commented Sep 16, 2019 via email

@Emanuel-c
Copy link

@StrangerZhang

@FadedFate
Copy link

FadedFate commented Jul 6, 2020

I guess that it may be caused by the change of the filefolder path.

Plz note that when you create the lmdb you need to send the path md5 as the key. So if you change the ".lmdb" path, you need to change the generated key for further query. (Or you will get nothing for the false key you get.)

Also note that :

    def imread(self, path):
        key = hashlib.md5(path.encode()).digest()
        img_buffer = self.txn.get(key)
        img_buffer = np.frombuffer(img_buffer, np.uint8)
        img = cv2.imdecode(img_buffer, cv2.IMREAD_COLOR)
        return img

If you change the .lmdb filefolder path, you should change the path to the original path when you use a different filedir. ( Before key = hashlib.md5(path.encode()).digest())

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

No branches or pull requests

4 participants