Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const dataSample = data[i];
const {trainDataPath, validationDataPath, testDataPath} = dataSample;
const trainFileNames: string[] = await glob(path.join(trainDataPath, '*.xml'));
await concatenateDataFlows(trainFileNames, imgSize, oneHotMap, trainDataFlows, 'train data');
if (validationDataPath) {
const validationFileNames: string[] = await glob(path.join(validationDataPath, '*.xml'));
await concatenateDataFlows(validationFileNames, imgSize, oneHotMap, validationDataFlows, 'validation data');
}
if (testDataPath) {
const testFileNames: string[] = await glob(path.join(testDataPath, '*.xml'));
await concatenateDataFlows(testFileNames, imgSize, oneHotMap, testDataFlows, 'test data');
}
}
const result: UniformTfSampleData = {
trainData: tf.data.array(trainDataFlows),
metaData: {
feature:
{
name: 'xs',
type: 'float32',
shape: [imgSize[0], imgSize[1], 3]
},
label: {
name: 'ys',
type: 'int32',
shape: [1,Object.keys(oneHotMap).length],
valueMap: oneHotMap
},
}
};
if (validationDataFlows.length > 0) {
feature:
{
name: 'xs',
type: 'float32',
shape: [imgSize[0], imgSize[1], 3]
},
label: {
name: 'ys',
type: 'int32',
shape: [1,Object.keys(oneHotMap).length],
valueMap: oneHotMap
},
}
};
if (validationDataFlows.length > 0) {
result.validationData = tf.data.array(validationDataFlows);
}
if (testDataFlows.length > 0) {
result.testData = tf.data.array(testDataFlows);
}
return result;
}
type: 'float32',
shape: [imgSize[0], imgSize[1], 3]
},
label: {
name: 'ys',
type: 'int32',
shape: [1,Object.keys(oneHotMap).length],
valueMap: oneHotMap
},
}
};
if (validationDataFlows.length > 0) {
result.validationData = tf.data.array(validationDataFlows);
}
if (testDataFlows.length > 0) {
result.testData = tf.data.array(testDataFlows);
}
return result;
}
const {trainDataPath, validationDataPath, testDataPath} = dataSample;
const imagePath = path.join(trainDataPath, '..', '..', 'images')
const trainFileNames: string[] = await glob(path.join(trainDataPath, '*.xml'));
await concatenateDataFlows(trainFileNames, imgSize, oneHotMap, trainDataFlows, 'train data', imagePath);
if (validationDataPath) {
const validationFileNames: string[] = await glob(path.join(validationDataPath, '*.xml'));
await concatenateDataFlows(validationFileNames, imgSize, oneHotMap, validationDataFlows, 'validation data', imagePath);
}
if (testDataPath) {
const testFileNames: string[] = await glob(path.join(testDataPath, '*.xml'));
await concatenateDataFlows(testFileNames, imgSize, oneHotMap, testDataFlows, 'test data', imagePath);
}
}
const result: UniformTfSampleData = {
trainData: tf.data.array(trainDataFlows),
metaData: {
feature:
{
name: 'xs',
type: 'float32',
shape: [imgSize[0], imgSize[1], 3]
},
label: {
name: 'ys',
type: 'int32',
shape: [1,Object.keys(oneHotMap).length],
valueMap: oneHotMap
},
}
};
if (validationDataFlows.length > 0) {