Open pendex900x opened 4 years ago
I have met with the same problem!
Finally I could not solve it:/ please let me know if you find an alternative solution
Bro, I worked it out! The reason is that opencv cannot read the image file path when it contains Chinese characters
I rewrite a new function as def cv_imread(file_path): cv_img = cv2.imdecode(np.fromfile(file_path, dtype=np.uint8), -1) return cv_img You just need to paste it at the end of load_data.py
Then you substitute the original sentences as follows filename = self.img_paths[index] Image = cv_imread(filename)
It will be ok, you can try it
Wow, I spent hours watching how to fix it and you did it! haha, I got lost in the last part, could you upload the file? I have already created a new function in load_data.py
You can check the txt.
Thanks, When I try the file python test_LPRNet.py
The output is:
(LPRNet) C:\Users\X\Desktop\LPRNet_Pytorch-master1>python test_LPRNet.py
Successful to build network!
load pretrained model successful!
Traceback (most recent call last):
File "test_LPRNet.py", line 176, in <module>
test()
File "test_LPRNet.py", line 74, in test
Greedy_Decode_Eval(lprnet, test_dataset, args)
File "test_LPRNet.py", line 89, in Greedy_Decode_Eval
images, labels, lengths = next(batch_iterator)
File "C:\Users\X\Anaconda3\envs\LPRNet\lib\site-packages\torch\utils\data\dataloader.py", line 819, in __next__
return self._process_data(data)
File "C:\Users\X\Anaconda3\envs\LPRNet\lib\site-packages\torch\utils\data\dataloader.py", line 846, in _process_data
data.reraise()
File "C:\Users\X\Anaconda3\envs\LPRNet\lib\site-packages\torch\_utils.py", line 369, in reraise
raise self.exc_type(msg)
KeyError: Caught KeyError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "C:\Users\X\Anaconda3\envs\LPRNet\lib\site-packages\torch\utils\data\_utils\worker.py", line 178, in _worker_loop
data = fetcher.fetch(index)
File "C:\Users\X\Anaconda3\envs\LPRNet\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\X\Anaconda3\envs\LPRNet\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\X\Desktop\LPRNet_Pytorch-master1\data\load_data.py", line 53, in __getitem__
label.append(CHARS_DICT[c])
KeyError: '皖'
I think I'm doing something wrong or my computer doesn't have those Chinese character fonts
Bro, It can work on my computer. I can run the test. py successfully. Your guess maybe right. I think you need to chage the test dataset cause it's Chinese license. Wish you a good luck
---Original--- From: "pendex900x"<notifications@github.com> Date: Wed, May 27, 2020 23:36 PM To: "sirius-ai/LPRNet_Pytorch"<LPRNet_Pytorch@noreply.github.com>; Cc: "JKLinUESTC"<3369798078@qq.com>;"Comment"<comment@noreply.github.com>; Subject: Re: [sirius-ai/LPRNet_Pytorch] Problem testing data (#30)
I think I'm doing something wrong or my computer doesn't have those Chinese character fonts
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
My computer has Chinese fonts
---Original--- From: "pendex900x"<notifications@github.com> Date: Wed, May 27, 2020 23:36 PM To: "sirius-ai/LPRNet_Pytorch"<LPRNet_Pytorch@noreply.github.com>; Cc: "JKLinUESTC"<3369798078@qq.com>;"Comment"<comment@noreply.github.com>; Subject: Re: [sirius-ai/LPRNet_Pytorch] Problem testing data (#30)
I think I'm doing something wrong or my computer doesn't have those Chinese character fonts
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
an easy... use pil read the image and then use cv to convert the pil,finally you can fix it
thanks
When I use
python test_LPRNet.py
the output:Why it happends?