在mmyolo-main下的tools文件下的misc下的coco_split.py运行的话只会出现trainval.json不会出现test.json,如何出现test.json #904
Wjason5201314
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Copyright (c) OpenMMLab. All rights reserved.
import argparse
import json
import random
from pathlib import Path
import numpy as np
from pycocotools.coco import COCO
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
'--json', type=str, default=r"D:\pycharmxiangmu\mmyolo\mmyolo-main\data\tanke\annotations\annotations_all.json",help='COCO json label path')
parser.add_argument(
'--out-dir', type=str,default=r"D:\pycharmxiangmu\mmyolo\mmyolo-main\data\tanke\annotations", help='output path')
parser.add_argument(
'--ratios',
default=[0.8 , 0.2],
nargs='+',
type=float,
help='ratio for sub dataset, if set 2 number then will generate '
'trainval + test (eg. "0.8 0.1 0.1" or "2 1 1"), if set 3 number '
'then will generate train + val + test (eg. "0.85 0.15" or "2 1")')
parser.add_argument(
'--shuffle',
action='store_true',
help='Whether to display in disorder')
parser.add_argument('--seed', default=-1, type=int, help='seed')
args = parser.parse_args()
return args
def split_coco_dataset(coco_json_path: str, save_dir: str, ratios: list,
shuffle: bool, seed: int):
if not Path(coco_json_path).exists():
raise FileNotFoundError(f'Can not not found {coco_json_path}')
def main():
args = parse_args()
split_coco_dataset(args.json, args.out_dir, args.ratios, args.shuffle,
args.seed)
if name == 'main':
main()
运行出现trainval.json和test.json
Beta Was this translation helpful? Give feedback.
All reactions