SiamFC-PyTorch icon indicating copy to clipboard operation
SiamFC-PyTorch copied to clipboard

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

Open cymisyourdad opened this issue 5 years ago • 4 comments

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'

cymisyourdad avatar Aug 01 '19 02:08 cymisyourdad

I also meet the problem, have you issued?

DavidZhangdw avatar Sep 16 '19 01:09 DavidZhangdw

sorry, I didn't solve it, I print the value img_buffer and it was null, I guess the problem maybe is that the decode of the dataset is not mapping, and I don't know how to do

------------------ 原始邮件 ------------------ 发件人: "DavidZhangdw"[email protected]; 发送时间: 2019年9月16日(星期一) 上午9:24 收件人: "StrangerZhang/SiamFC-PyTorch"[email protected]; 抄送: "C10"[email protected]; "Author"[email protected]; 主题: Re: [StrangerZhang/SiamFC-PyTorch] TypeError: a bytes-like object isrequired, not 'NoneType' (#29)

I also meet the problem, have you issued?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

cymisyourdad avatar Sep 16 '19 01:09 cymisyourdad

@StrangerZhang

Emanuel-c avatar Sep 16 '19 01:09 Emanuel-c

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())

FadedFate avatar Jul 06 '20 01:07 FadedFate