MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / fetchOnceAndSaveToDiskWithBuffer

Function fetchOnceAndSaveToDiskWithBuffer

mnist-acgan/data.js:47–64  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

45
46// Downloads MNIST data files.
47function fetchOnceAndSaveToDiskWithBuffer(filename) {
48 return new Promise(resolve => {
49 const url = `${BASE_URL}${filename}.gz`;
50 if (fs.existsSync(filename)) {
51 resolve(readFile(filename));
52 return;
53 }
54 const file = fs.createWriteStream(filename);
55 console.log(` * Downloading from: ${url}`);
56 https.get(url, (response) => {
57 const unzip = zlib.createGunzip();
58 response.pipe(unzip).pipe(file);
59 unzip.on('end', () => {
60 resolve(readFile(filename));
61 });
62 });
63 });
64}
65
66function loadHeaderValues(buffer, headerLength) {
67 const headerValues = [];

Callers 2

loadImagesFunction · 0.70
loadLabelsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected