Skip to content

Commit

Permalink
Add ability to use tfjs-node library
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldogsbody authored Jun 18, 2022
1 parent 6e0e941 commit 70a22f1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions similarity/tsne.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var path = require("path");
const glob = require('glob-promise');
const localPath = i => path.relative(process.cwd(), i)
const argv = require('minimist')(process.argv.slice(2));
const tf = require('@tensorflow/tfjs');
// const tf = require('@tensorflow/tfjs');
// const tsne = require('@tensorflow/tfjs-tsne');
const { createCanvas, loadImage } = require('canvas')
const tsnejs = require('./lib/tsne.js');
Expand All @@ -20,6 +20,20 @@ console.log('starting with', process.argv);

const inputPath = argv.i;
const inputFormat = argv.f || 'jpg';
const useTfjsnode = argv.t || false;

var tf
if(useTfjsnode) {
tf = require('@tensorflow/tfjs-node');
}
else {
tf = require('@tensorflow/tfjs');
}

const saveCsv = async (data, filename) => {
const csv = d3.csvFormat(data)
fs.writeFileSync(filename, csv);
}

const saveCsv = async (data, filename) => {
const csv = d3.csvFormat(data)
Expand Down Expand Up @@ -180,4 +194,4 @@ run()
// // the embedded data.
// const coordinates = tsneOpt.coordinates();
// coordinates.print();
// })
// })

0 comments on commit 70a22f1

Please sign in to comment.