You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
so it seems correctly training from scratch. When I exported an inference model afterwards and tried it I keep getting more classes out of the model than the ones in my dict.txt which causes index out of range errors as seen here
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[4], line 29
26 image = Image.open(image_path).convert("RGB")
27 img_width, img_height = image.size # Get image dimensions
---> 29 ocr_results = ocr.ocr(image_path, cls=True)
31 words = []
32 word_boxes = []
File ~/miniconda3/envs/MinerU/lib/python3.10/site-packages/paddleocr/paddleocr.py:668, in PaddleOCR.ocr(self, img, det, rec, cls, bin, inv, alpha_color)
666 for idx, img in enumerate(imgs):
667 img = preprocess_image(img)
--> 668 dt_boxes, rec_res, _ = self.__call__(img, cls)
669 if not dt_boxes and not rec_res:
670 ocr_res.append(None)
File ~/miniconda3/envs/MinerU/lib/python3.10/site-packages/paddleocr/tools/infer/predict_system.py:105, in TextSystem.__call__(self, img, cls)
101 time_dict['cls'] = elapse
102 logger.debug("cls num : {}, elapsed : {}".format(
103 len(img_crop_list), elapse))
--> 105 rec_res, elapse = self.text_recognizer(img_crop_list)
106 time_dict['rec'] = elapse
107 logger.debug("rec_res num : {}, elapsed : {}".format(
108 len(rec_res), elapse))
File ~/miniconda3/envs/MinerU/lib/python3.10/site-packages/paddleocr/tools/infer/predict_rec.py:628, in TextRecognizer.__call__(self, img_list)
626 preds = outputs[0]
627 self.predictor.try_shrink_memory()
--> 628 rec_result = self.postprocess_op(preds)
629 for rno in range(len(rec_result)):
630 rec_res[indices[beg_img_no + rno]] = rec_result[rno]
File ~/miniconda3/envs/MinerU/lib/python3.10/site-packages/paddleocr/ppocr/postprocess/rec_postprocess.py:124, in CTCLabelDecode.__call__(self, preds, label, *args, **kwargs)
122 preds_idx = preds.argmax(axis=2)
123 preds_prob = preds.max(axis=2)
--> 124 text = self.decode(preds_idx, preds_prob, is_remove_duplicate=True)
125 if label is None:
126 return text
File ~/miniconda3/envs/MinerU/lib/python3.10/site-packages/paddleocr/ppocr/postprocess/rec_postprocess.py:84, in BaseRecLabelDecode.decode(self, text_index, text_prob, is_remove_duplicate)
82 print("Max text_id in this batch:", text_index[batch_idx][selection].max())
83 print("self.character size:", len(self.character))
---> 84 char_list = [
85 self.character[text_id]
86 for text_id in text_index[batch_idx][selection]
87 ]
88 if text_prob is not None:
89 conf_list = text_prob[batch_idx][selection]
File ~/miniconda3/envs/MinerU/lib/python3.10/site-packages/paddleocr/ppocr/postprocess/rec_postprocess.py:85, in <listcomp>(.0)
82 print("Max text_id in this batch:", text_index[batch_idx][selection].max())
83 print("self.character size:", len(self.character))
84 char_list = [
---> 85 self.character[text_id]
86 for text_id in text_index[batch_idx][selection]
87 ]
88 if text_prob is not None:
89 conf_list = text_prob[batch_idx][selection]
IndexError: list index out of range
by checking my inference.yml it seems to have the correct number of classes 110
PreProcess:
transform_ops:
- DecodeImage:
channel_first: false
img_mode: BGR
- CTCLabelEncode: null
- RecResizeImg:
image_shape:
- 3
- 32
- 320
- KeepKeys:
keep_keys:
- image
- label
- length
PostProcess:
name: CTCLabelDecode
character_dict:
- '!'
- '"'
- '#'
- $
- '%'
- '&'
- ''''
- (
- )
- '*'
- +
- ','
- '-'
- .
- /
- '0'
- '1'
- '2'
- '3'
- '4'
- '5'
- '6'
- '7'
- '8'
- '9'
- ':'
- ;
- <
- '='
- '>'
- '?'
- '@'
- A
- B
- C
- D
- E
- F
- G
- H
- I
- J
- K
- L
- M
- N
- O
- P
- Q
- R
- S
- T
- U
- V
- W
- X
- Y
- Z
- '['
- ']'
- _
- '`'
- a
- b
- c
- d
- e
- f
- g
- h
- i
- j
- k
- l
- m
- n
- o
- p
- q
- r
- s
- t
- u
- v
- w
- x
- y
- z
- '{'
- '}'
- £
- §
- «
- °
- ´
- ·
- »
- Ä
- Ö
- Ü
- ß
- ä
- é
- ö
- ø
- ü
- “
- „
- †
- €
while the model seems to output 187 classes as this is the logits shape : (6, 120, 187). Am I doing anything wrong ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I tried training a CRNN model on my font and dict from scratch. This is my config file
and this is how my training logs look like in the beginning
so it seems correctly training from scratch. When I exported an inference model afterwards and tried it I keep getting more classes out of the model than the ones in my dict.txt which causes index out of range errors as seen here
by checking my inference.yml it seems to have the correct number of classes 110
while the model seems to output 187 classes as this is the logits shape : (6, 120, 187). Am I doing anything wrong ?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions