Files
MPKFNet/crow_data_generate.py
2022-04-28 22:02:20 +08:00

37 lines
1.1 KiB
Python
Executable File

import numpy as np
import os
import json
import argparse
dataset_name = "birdCounting6"
#root_path ="../data_MPKFNet/data/BirdCounting"
root_path ="/data1/zwq/Upload/tiaozini/"
parser = argparse.ArgumentParser(description="DensityVideodemo.")
parser.add_argument("--dataset_name", default='birdCounting6', type=str,
help='Video name.')
parser.add_argument(
"opts",
help="Modify config options using the command-line",
default=None,
nargs=argparse.REMAINDER,
)
args = parser.parse_args()
print(args)
dataset_name = args.dataset_name
datasetjsonpath = os.path.join(root_path ,dataset_name)
train = os.path.join(root_path,dataset_name,'train_data','images')
test = os.path.join(root_path,dataset_name,'test_data','images')
trainfile = os.listdir(train)
train_json = [os.path.join(train,file) for file in trainfile]
with open(datasetjsonpath + "/train_data.json",'w') as f:
json.dump(train_json,f)
testfile = os.listdir(test)
test_json = [os.path.join(test,file) for file in testfile]
with open(datasetjsonpath + "/test_data.json",'w') as f:
json.dump(test_json,f)
print("data is ok")