4、picodet 小目标训练全流程( 五 )


processer=[]for i in range(len(out_size_ratio)):kwargs=dict(image_dir="dataset/pqdetection_voc/images/",dataset_json_path="dataset/pqdetection_coco/pddetection.json",output_dir=out_size_ratio[i][0],slice_size=out_size_ratio[i][1],overlap_ratio=out_size_ratio[i][2],ignore_negative_samples=True,min_area_ratio=0.1 )p = Process(target=slice_my,kwargs=kwargs)processer.append(p)p.start()for p in processer: #等待所有进程都结速p.join()
以上输出会比较乱,在中执行会有问题 , 要放到脚本中执行.最后生成的文件结构是:
pqdetection_sliced├── pq_160_75│├── pddetection_160_075.json│└── pddetection_images_160_075├── pq_192_75│├── pddetection_192_075.json│└── pddetection_images_192_075├── pq_224_75│├── pddetection_224_075.json│└── pddetection_images_224_075├── pq_256_75│├── pddetection_256_075.json│└── pddetection_images_256_075├── pq_288_75│├── pddetection_288_075.json│└── pddetection_images_288_075├── pq_320_75│├── pddetection_320_075.json│└── pddetection_images_320_075├── pq_352_75│├── pddetection_352_075.json│└── pddetection_images_352_075├── pq_384_75│├── pddetection_384_075.json│└── pddetection_images_384_075├── pq_416_75│├── pddetection_416_075.json│└── pddetection_images_416_075├── pq_448_75│├── pddetection_448_075.json│└── pddetection_images_448_075├── pq_480_75│├── pddetection_480_075.json│└── pddetection_images_480_075└── pq_512_75├── pddetection_512_075.json└── pddetection_images_512_07525 directories, 12 files
2.3 对各个数据集的状态进行查看
import osimport globfrom pprint import pprintfrom sahi.utils.coco import Cocofor i in out_size_ratio:jsonpath = glob.glob(os.path.join(i[0],'*.json'))[0]coco=Coco.from_coco_dict_or_path(jsonpath)pprint(f"{os.path.basename(i[0])}:")pprint(coco.stats)
indexing coco dataset annotations...Loading coco annotations: 100%|██████████| 60068/60068 [00:05<00:00, 10029.56it/s]'pq_160_75:'{'avg_annotation_area': 2752.9663472653942,'avg_num_annotations_in_image': 1.296097755876673,'max_annotation_area': 25600,'max_annotation_area_per_category': {'ball': 25600},'max_num_annotations_in_image': 9,'min_annotation_area': 6,'min_annotation_area_per_category': {'ball': 6},'min_num_annotations_in_image': 1,'num_annotations': 77854,'num_annotations_per_category': {'ball': 77854},'num_categories': 1,'num_images': 60068,'num_images_per_category': {'ball': 60068},'num_negative_images': 0}indexing coco dataset annotations...Loading coco annotations: 100%|██████████| 52959/52959 [00:05<00:00, 9287.43it/s] 'pq_192_75:'{'avg_annotation_area': 3227.159324899192,'avg_num_annotations_in_image': 1.3626956702354651,'max_annotation_area': 36864,'max_annotation_area_per_category': {'ball': 36864},'max_num_annotations_in_image': 10,'min_annotation_area': 7,'min_annotation_area_per_category': {'ball': 7},'min_num_annotations_in_image': 1,'num_annotations': 72167,'num_annotations_per_category': {'ball': 72167},'num_categories': 1,'num_images': 52959,'num_images_per_category': {'ball': 52959},'num_negative_images': 0}indexing coco dataset annotations...Loading coco annotations: 100%|██████████| 47829/47829 [00:05<00:00, 8223.08it/s] 'pq_224_75:'{'avg_annotation_area': 3784.9258265381764,'avg_num_annotations_in_image': 1.41023228585168,'max_annotation_area': 50176,'max_annotation_area_per_category': {'ball': 50176},'max_num_annotations_in_image': 10,'min_annotation_area': 6,'min_annotation_area_per_category': {'ball': 6},'min_num_annotations_in_image': 1,'num_annotations': 67450,'num_annotations_per_category': {'ball': 67450},'num_categories': 1,'num_images': 47829,'num_images_per_category': {'ball': 47829},'num_negative_images': 0}indexing coco dataset annotations...Loading coco annotations: 100%|██████████| 44695/44695 [00:05