Save a tensorflow.js model in node - string

I am trying to save a tensorflow.js model I have as a json file but it's not working.
var exampleModel = {input:1,name:'model'}
fs.writeFileSync('model.json', JSON.stringify(model,null,2))
//=> '"{\"input\":1, \"name\": \"model\"}"'
It's not in json format. I wasted a lot of time trying to manually create a json but that didn't work either and I will have to redo it by copying it to a normal object or something.

Seems noone knows anything about this. The problem was that I was using node and I needed to require "#tensorflow/tfjs-node" underneath my tfjs require line. I had to search for this page specifically as there wasn't anything about it in their documentation: https://js.tensorflow.org/tutorials/model-save-load.html
Here's another helpful link: https://github.com/tensorflow/tfjs-node

Related

The spine plugin for Phaser gives an error

I'm trying to upload the plugin to my project, tried all the methods, but nothing works. Returns an error
Uncaught TypeError: Cannot read properties of undefined (reading 'createSkeleton')
at initialize.set Skeleton (<anonymous>:1:290667)
at new initialize (<anonymous>:1:289262)
at Game Object Factory.spine (<anonymous>:1:54310)
at MainWindow.create (MainWindow.js?21c4:53:27)
at SceneManager.create (phaser.js?d4ef:89720:1)
at SceneManager.loadComplete (phaser.js?d4ef:89632:1)
at Loader Plug in.emit (phaser.js?d4ef:1908:1)
at Leaderplugin.loadComplete (phaser.js?d4ef:192810:1)
at Loader Plug in.file Process Complete (phaser.js?d4ef:192776:1)
at t.on Process Complete (<anonymous>:1:25378)
I work on a local server. Here is a code example of how I connect everything
I think it's the same problem I had. My spine JSON data were saved in an old format. You probably used DragonBones, which exports only version 3.3 spine data.
Here are the details someone remarked what's wrong with the file. You have three options: (A) change the file manually each time you export it, (B) use the python file the dude provides there, or (C) make a function to change the data structure accordingly after they are loaded and before the skeleton is added to scene. (This is the way I went.)

How to write Postman tests to compare a response body with an external JSON/CSV file using Newman?

It is well documented how to use an external data file with the Collection Runner in Postman to run multiple iterations. However, what I'd like to do is write tests to compare the response body from a GET request to a JSON/CSV file.
From the research I've done it seems this isn't possible using just Postman. I wonder though if it'd be possible with Newman?
I have no experience with Newman but am curious if this might work. Could you create a Postman collection with an env variable called TestJsonFile and write tests comparing values from that to the response body. Then export said collection and using Newman set the TestJsonFile value to that of a JSON/CSV file (--env-var "TestJsonFile=<path_to_file>") and run the collection with that variable?
This seems plausible to me; maybe I could create a Node project to do it all in one place. I'd just like to ask if anyone has done something similar as it seems like it should be doable.
Any critiques or suggestions would be much appreciated, thank you for reading!

Webdriver IO How to store Excel file in cache and call from cache on Node JS

I have an excel file that I want to only call in once and make available to all of my tests, at the moment it's being called on each test, I have tried storing it in the cache using https://www.npmjs.com/package/node-cache but when I tried to get it from cache it's saying undefined, so then I tried using onPrepare hook with no luck. Can someone point me in the right direction thanks in advance.
Assuming that excel has data for test automation and it does not include any writing operations, I would suggest reading the content and store it in a constant. If you declare that variable globally, it will be available to all your tests. The complexity of this READ function depends on how diverse is your data. You can use libraries like https://www.npmjs.com/package/xlsx, https://www.npmjs.com/package/exceljs, etc..,

Automate PDF contents using nightwatch/Cucumber

I am using nightwatch/NodeJs using cucumber for Automation. I have a lot of areas where PDF's are generated and needs to be verified. Is there any way by which I can verify PDF contents which are downloaded including text/Images etc??
Thanks in advance.
You can use the pdfjs-dist package to read the contents of a PDF. In my experience it has worked most of the time. I have had a few instances where it returned no content even though I could visibly see that the file had text in it. I haven't tried to dig in to see why that was but the majority of the time it has worked for me without issue. Also, I have only used it to verify text. I haven't tried to use it for images so I'm not sure if it can do that. You can find more details here.
This will get you as far as getting all the text into an array. What you do with it from there is up to you.
pdfjs.getDocument('path/to/your/file.pdf').then(function(document) {
document.getPage(1).then(function(page) {
page.getTextContent().then(function(text) {
const allText = text.items.map(function(s) { return s.str }).concat('');
//console.log(allText);
});
});
});

Sphinx4 figuring out correct models

I am trying to use the Sphinx4 library for speech recognition, but I cannot seem to figure out the correct combination of acoustic model-dictionary-language model. I have tried out various combinations and I get a different error every time.
I am trying to follow the tutorial on http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4. I do not have a config.xml as I would if I was using ConfigurationManager instead of Configuration, because there is no perceivable way of passing the location of the config file to the Configuration itself (ConfigMgr takes it as an argument to the constructor); and that might be my problem right there. I just do not know how to point to one, and since the tutorial says "It is possible to configure low-level components of the application through XML file although you should do that ONLY IF you understand what is going on.", I assume having a config.xml file is not compulsory.
Combining the latest dictionary (7b - obtained from Sourceforge) with the latest acoustic model (cmusphinx-en-us-5.2.tar.gz - from SF again) and the language model (cmusphinx-5.0-en-us.lm.gz - from SF again) results in NullPointerException in startRecognition. The issue is similar to the problem here: sphinx-4 NullPointerException at startRecognition, but the link given in the answer no longer works. I obtained 0.7a from SF (since that is the dict the link seems to point at), but I am getting even earlier in the execution Error loading word: ;;; when I use that one. I tried downloading latest models and dict from the Github repo, that results in java.lang.IndexOutOfBoundsException: Index: 16128, Size: 16128.
Any help is much appreciated!
You need to use latest code from github
http://github.com/cmusphinx/sphinx4
as described by tutorial
http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4
Correct models (en-us) are already included, you should not replace anything. You should not configure any XML files, use samples as provided in the sources.

Resources