LPRNet_Pytorch icon indicating copy to clipboard operation
LPRNet_Pytorch copied to clipboard

Problem testing data

Open pendex900x opened this issue 4 years ago • 12 comments

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?

pendex900x avatar May 22 '20 02:05 pendex900x

I have met with the same problem!

JKLove21 avatar May 27 '20 13:05 JKLove21

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

pendex900x avatar May 27 '20 13:05 pendex900x

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

JKLove21 avatar May 27 '20 14:05 JKLove21

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

pendex900x avatar May 27 '20 15:05 pendex900x

load_data.txt

JKLove21 avatar May 27 '20 15:05 JKLove21

You can check the txt.

JKLove21 avatar May 27 '20 15:05 JKLove21

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 avatar May 27 '20 15:05 pendex900x

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

pendex900x avatar May 27 '20 15:05 pendex900x

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"<[email protected]> Date: Wed, May 27, 2020 23:36 PM To: "sirius-ai/LPRNet_Pytorch"<[email protected]>; Cc: "JKLinUESTC"<[email protected]>;"Comment"<[email protected]>; 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 avatar May 27 '20 15:05 JKLove21

My computer has Chinese fonts

---Original--- From: "pendex900x"<[email protected]> Date: Wed, May 27, 2020 23:36 PM To: "sirius-ai/LPRNet_Pytorch"<[email protected]>; Cc: "JKLinUESTC"<[email protected]>;"Comment"<[email protected]>; 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 avatar May 27 '20 15:05 JKLove21

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

luotianhang avatar Feb 05 '21 07:02 luotianhang

加载数据.txt

thanks

Moneylijin avatar Dec 07 '21 14:12 Moneylijin