(self, properties)
| 656 | return text |
| 657 | |
| 658 | def __getitem__(self, properties): |
| 659 | |
| 660 | if len(properties) != 5: |
| 661 | img_id, w_r, h_r, zoom_time = properties |
| 662 | else: |
| 663 | img_id, w_r, h_r, zoom_time, resume_batch = properties |
| 664 | if resume_batch > 0: |
| 665 | return np.zeros((1, 3), dtype=np.float32) |
| 666 | key = str(w_r) + '_' + str(h_r) |
| 667 | if img_id > len(self.img_label_pair_list[key]) - 1: |
| 668 | data_info = self.img_label_pair_list_small[key][img_id] |
| 669 | else: |
| 670 | data_info = self.img_label_pair_list[key][img_id] |
| 671 | label = data_info['label'] |
| 672 | if isinstance(label, list): |
| 673 | label = '\n\n'.join(label) |
| 674 | if self.add_return: |
| 675 | rep_str = '<|sn|>' |
| 676 | else: |
| 677 | rep_str = '' |
| 678 | label = label.replace('<<<hyphen>>>', '') |
| 679 | label = label.replace('<<<change_line_token_wrap>>>', rep_str) |
| 680 | label = label.replace('<<<change_line_token_split>>>', rep_str) |
| 681 | label = label.replace('<<<null>>>', '') |
| 682 | label = self.remove_space_before_sn(label, rep_str) |
| 683 | label = self.clean_label(label) |
| 684 | if not self.add_return: |
| 685 | label = label.replace('<|sn|>', '') |
| 686 | try: |
| 687 | file_name = data_info['file_name'] |
| 688 | img_data = None |
| 689 | if self.test_data: |
| 690 | img_data = self.txn_test.get(file_name.encode('utf-8')) |
| 691 | image = Image.open(io.BytesIO(img_data)).convert('RGB') |
| 692 | line_data = True |
| 693 | else: |
| 694 | if self.use_linedata or self.custom_data: |
| 695 | for prefix, txn in self.txns.items(): |
| 696 | if file_name.startswith(prefix): |
| 697 | img_data = txn.get(file_name.encode('utf-8')) |
| 698 | break |
| 699 | if img_data is not None or 'bbox' not in data_info: |
| 700 | image = Image.open(io.BytesIO(img_data)).convert('RGB') |
| 701 | line_data = True |
| 702 | else: |
| 703 | image, line_data = self.crop_pdf_as_image( |
| 704 | data_info, |
| 705 | dpi=300, |
| 706 | is_math=self.math_pattern.search(label)) |
| 707 | if image is None or label is None: |
| 708 | if len(self.img_label_pair_list[key]) <= 8: |
| 709 | rnd_properties = [ |
| 710 | random.randint( |
| 711 | 0, |
| 712 | len(self.img_label_pair_list_small[key]) - 1), w_r, |
| 713 | h_r, zoom_time |
| 714 | ] |
| 715 | else: |
nothing calls this directly
no test coverage detected