Skip to content

Commit

Permalink
Merge pull request WenmuZhou#61 from WenmuZhou/dev
Browse files Browse the repository at this point in the history
去掉DetDataSet里的trycatch
  • Loading branch information
WenmuZhou authored Jun 30, 2020
2 parents 1f61df8 + 7a2bc07 commit 222dc77
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions torchocr/datasets/DetDataSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,28 +93,28 @@ def apply_pre_processes(self, data):
return data

def __getitem__(self, index):
try:
data = copy.deepcopy(self.data_list[index])
im = cv2.imread(data['img_path'], 1 if self.img_mode != 'GRAY' else 0)
if self.img_mode == 'RGB':
im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
data['img'] = im
data['shape'] = [im.shape[0], im.shape[1]]
data = self.apply_pre_processes(data)

if self.transform:
data['img'] = self.transform(data['img'])
data['text_polys'] = data['text_polys'].tolist()
if len(self.filter_keys):
data_dict = {}
for k, v in data.items():
if k not in self.filter_keys:
data_dict[k] = v
return data_dict
else:
return data
except:
return self.__getitem__(np.random.randint(self.__len__()))
# try:
data = copy.deepcopy(self.data_list[index])
im = cv2.imread(data['img_path'], 1 if self.img_mode != 'GRAY' else 0)
if self.img_mode == 'RGB':
im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
data['img'] = im
data['shape'] = [im.shape[0], im.shape[1]]
data = self.apply_pre_processes(data)

if self.transform:
data['img'] = self.transform(data['img'])
data['text_polys'] = data['text_polys'].tolist()
if len(self.filter_keys):
data_dict = {}
for k, v in data.items():
if k not in self.filter_keys:
data_dict[k] = v
return data_dict
else:
return data
# except:
# return self.__getitem__(np.random.randint(self.__len__()))

def __len__(self):
return len(self.data_list)
Expand Down

0 comments on commit 222dc77

Please sign in to comment.