tensorflow.js

Error loading TensorflowJS in Electron App (Nodejs)

情到浓时终转凉″ 提交于 2021-02-11 17:25:20
问题 I am trying to get tensorflow working in my electron app using tensorflow js. Here are the details of the various versions: Nodejs: v14.4.0 @tensorflow/tfjs - 2.0.0 @tensorflow/tfjs-node - 2.0.0 electron - 1.8.8 When I try to load the tfjs module using: const tf = require('@tensorflow/tfjs'); I get the following error: I have looked everywhere but can't seem to find anything relevant for this error. Any help would be much appreciated. 回答1: SOLUTION The issue seems to be one of competing

Tensorflow.js Dataset to Tensor?

ⅰ亾dé卋堺 提交于 2021-02-11 14:55:45
问题 Is there a recommended/efficient way to convert a tf.data.Dataset to a Tensor when the underlying 'data examples' in the Dataset are flat arrays? I am using tf.data.csv to read and parse a CSV but then want to use the Tensorflow.js Core API to process the data as tf.Tensors . 回答1: tf.data.Dataset.iterator() returns a promise of an iterator. const it = await flattenedDataset.iterator() const t = [] // read only the data for the first 5 rows // all the data need not to be read once // since it

Keras Deploy for Tensorflow.js Usage

帅比萌擦擦* 提交于 2021-02-11 12:05:04
问题 I need to be able to deploy a keras model for Tensorflow.js prediction, but the Firebase docs only seem to support a TFLite object, which tf.js cannot accept. Tf.js appears to accept JSON files for loading (loadGraphModel() / loadLayersModel() ), but not a keras SavedModel (.pb + /assets + /variables). How can I attain this goal? Note for the Tensorflow.js portion: There are a lot of pointers to the tfjs_converter, but the closest API function offered to what I'm looking for is the

I'm having trouble with the transition of Tensorflow Python to Tensorflow.js in regards to image preprocessing. What am I missing?

二次信任 提交于 2021-02-11 06:24:47
问题 I'm having trouble with the transition of Tensorflow Python to Tensorflow.js in regards to image preprocessing in Python single_coin = r"C:\temp\coins\20Saint-03o.jpg" img = image.load_img(single_coin, target_size = (100, 100)) array = image.img_to_array(img) x = np.expand_dims(array, axis=0) vimage = np.vstack([x]) prediction =model.predict(vimage) print(prediction[0]) I get the correct result [2.8914417e-05 3.5085387e-03 1.9252902e-03 6.2635467e-05 3.7389682e-03 1.2983804e-03 7.4157811e-04

Save TensorFlowJS MobileNet + KNN to TFLite

风流意气都作罢 提交于 2021-02-10 14:31:12
问题 I have trained a KNN on top of MobileNet logits results using TensorFlowJS. And I want to know how can I export the result of the MobileNet + KNN to a TFLite model. const knn = knnClassifier.create() const net = await mobilenet.load() const handleTrain = (imgEl, label) => { const image = tf.browser.fromPixels(imgEl); const activation = net.infer(image, true); knn.addExample(activation, label) } 回答1: 1. Save the model Save the model this example saves the file to the native file system or if

Requested texture size [0x0] is invalid. error when i am loading image in browser

我的未来我决定 提交于 2021-02-10 11:56:00
问题 Tensorflow.js error in browser while calling predict function I'm using Node.js to run the webapp. This is my scripts I have included and I'm running Node.js in Chrome and not able to solve the error. This project has 7 classes as output that is dense layer in output of shape 1x7. https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js https://code.jquery.com/jquery-3.3.1.slim.min.js This is my JavaScript

Requested texture size [0x0] is invalid. error when i am loading image in browser

会有一股神秘感。 提交于 2021-02-10 11:54:15
问题 Tensorflow.js error in browser while calling predict function I'm using Node.js to run the webapp. This is my scripts I have included and I'm running Node.js in Chrome and not able to solve the error. This project has 7 classes as output that is dense layer in output of shape 1x7. https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js https://code.jquery.com/jquery-3.3.1.slim.min.js This is my JavaScript

Requested texture size [0x0] is invalid. error when i am loading image in browser

北城以北 提交于 2021-02-10 11:53:33
问题 Tensorflow.js error in browser while calling predict function I'm using Node.js to run the webapp. This is my scripts I have included and I'm running Node.js in Chrome and not able to solve the error. This project has 7 classes as output that is dense layer in output of shape 1x7. https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js https://code.jquery.com/jquery-3.3.1.slim.min.js This is my JavaScript

How to get/set weights for a supervised model in tensorflow.js?

混江龙づ霸主 提交于 2021-02-10 07:53:15
问题 I'd like to change the weights of a supervised model but I get the same exact result after changing the weights. What am I doing wrong? const model = tf.sequential(); model.add(tf.layers.dense({...})); model.add(tf.layers.dense({...})); model.add(tf.layers.dense({...})); model.compile({...}); model.fit({}); const result1 = model.predict(tf.tensor2d(...)).dataSync(); const newWeights = []; model.layers.map((layer, i) => { newWeights[i] = [] const weights = layer.getWeights(); newWeights[i][0]

Problem measuring the time elapsed executing my code in Tensorflow.js

点点圈 提交于 2021-02-08 11:54:38
问题 I am having a problem measuring the time elapsed executing my code in Tensorflow.js . I was building a super resolution model in tfjs , and I wanted to know the latency. currently I am using the following method, as described below. But I don't think this is the right way to it. Any kind of suggestion would be appreciated. var w = new Date(); var r = w.getTime(); for (var q = 0; q<29; q++){ var x = tf.concat([new_I[q++],new_I[q++], new_I[q++],new_I[q]]); var hr_image = await pretrainedModel