sirius-ai / LPRNet_Pytorch

Pytorch Implementation For LPRNet, A High Performance And Lightweight License Plate Recognition Framework.
Apache License 2.0
937 stars 235 forks source link

Problem testing data #30

Open pendex900x opened 4 years ago

pendex900x commented 4 years ago

When I use python test_LPRNet.py the output:

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)
AttributeError: Caught AttributeError 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-master\data\load_data.py", line 40, in __getitem__
    height, width, _ = Image.shape
AttributeError: 'NoneType' object has no attribute 'shape'

Why it happends?

JKLove21 commented 4 years ago

I have met with the same problem!

pendex900x commented 4 years ago

Finally I could not solve it:/ please let me know if you find an alternative solution

JKLove21 commented 4 years ago

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

pendex900x commented 4 years ago

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

JKLove21 commented 4 years ago

load_data.txt

JKLove21 commented 4 years ago

You can check the txt.

pendex900x commented 4 years ago

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: '皖'

Image

pendex900x commented 4 years ago

I think I'm doing something wrong or my computer doesn't have those Chinese character fonts

JKLove21 commented 4 years ago

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.

JKLove21 commented 4 years ago

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.

luotianhang commented 3 years ago

an easy... use pil read the image and then use cv to convert the pil,finally you can fix it

Moneylijin commented 2 years ago

加载数据.txt

thanks