-- coding: utf-8 --
"""
Created on Tue Feb 11 16:00:54 2020
@author: mn_j
"""
import numpy as np
txt文件路径,可变
with open("./data/dataset/trainship.txt", 'r') as f:
txt = f.readlines()
annotations = [line.strip()+'\n' for line in txt if len(line.strip().split()[1:]) != 0]
np.random.shuffle(annotations)
total=len(annotations)
train_num=int(total*0.9)
train_ship_an=annotations[:train_num]
test_ship_an=annotations[train_num:]
with open("./data/dataset/train_ship_random.txt", 'w') as f:
f.writelines(train_ship_an)
with open("./data/dataset/test_ship_random.txt", 'w') as f:
f.writelines(test_ship_an)
网友评论