# -*- coding: utf-8 -*- # @Time : 2020/3/20 20:33 # @Author : zhoujun """ 用于检查生成的json文件有没有问题 """ from PIL import Image from tqdm import tqdm from matplotlib import pyplot as plt from convert.utils import show_bbox_on_image, load_gt if __name__ == '__main__': json_path = r'D:\dataset\自然场景文字检测挑战赛初赛数据\验证集\validation_new.json' data = load_gt(json_path) for img_path, gt in tqdm(data.items()): # print(gt['illegibility_list']) # print(gt['texts']) img = Image.open(img_path) img = show_bbox_on_image(img, gt['polygons'], gt['texts']) plt.imshow(img) plt.show()
return item_dict['img'] if __name__ == '__main__': from tqdm import tqdm from torchvision import transforms from matplotlib import pyplot as plt # 支持中文 plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签 plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 json_path = r'D:\dataset\icdar2017rctw\detection\train.json' dataset = DetDataSet(json_path, transform=transforms.ToTensor()) train_loader = DataLoader(dataset=dataset, batch_size=1, shuffle=True, num_workers=0) pbar = tqdm(total=len(train_loader)) for i, data in enumerate(train_loader): img = data['img'][0].numpy().transpose(1, 2, 0) * 255 label = [x[0] for x in data['label']] img = show_bbox_on_image(Image.fromarray(img.astype(np.uint8)), data['polygons'], label) plt.imshow(img) plt.show() pbar.update(1) pbar.close()