StrangerZhang / SiamFC-PyTorch

SiamFC PyTorch
MIT License
232 stars 63 forks source link

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

Open cymisyourdad opened 5 years ago

cymisyourdad commented 5 years ago

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 commented 5 years ago

I also meet the problem, have you issued?

cymisyourdad commented 5 years ago

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"notifications@github.com; 发送时间: 2019年9月16日(星期一) 上午9:24 收件人: "StrangerZhang/SiamFC-PyTorch"SiamFC-PyTorch@noreply.github.com; 抄送: "C10"369807314@qq.com; "Author"author@noreply.github.com; 主题: 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.

Emanuel-c commented 5 years ago

@StrangerZhang

FadedFate commented 4 years ago

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