TensorflowJS TFJS error: The dtype of dict - machine-learning

Had tried to run https://glitch.com/~tar-understood-exoplanet
and the model would fail to load and I wouldn't be able to use enable the webcam.
Anyone had the same issue?
While the program is running, in the console I get the following:
tfjs:2 Uncaught (in promise) Error: The dtype of dict['image_tensor'] provided in model.execute(dict) must be int32, but was float32
at Object.b [as assert] (tfjs:2)
at tfjs:2
at Array.forEach (<anonymous>)
at t.checkInputShapeAndType (tfjs:2)
at t.<anonymous> (tfjs:2)
at tfjs:2
at Object.next (tfjs:2)
at tfjs:2
at new Promise (<anonymous>)
at Zv (tfjs:2)
I have a Macbook Pro and some other people on their Windows also had some issues running the model. We also tried it on different browsers, Safari and Chrome.
SUCCESS! after switching to coco-ssd 2.0.2:
I added the version 2.0.2 in line 62 as follows:
<script src="https://cdn.jsdelivr.net/npm/#tensorflow-models/coco-ssd#2.0.2"></script>

This is caused by the warmup run of coco-ssd that uses tf.zeros tensor. The default dtype for tf.zeros is 'float' in the recent release of TFJS.
I have put out a new version with fixes. It should work if you use the latest version of coco-ssd (2.0.2) in the glitch example (index.html) as following.
<!-- Load the coco-ssd model to use to recognize things in images -->
<script src="https://cdn.jsdelivr.net/npm/#tensorflow-models/coco-ssd#2.0.2"></script>

Same error here, just occured since Friday night (04/03/2020)
TFModel works well in past few weeks.

I got the same error.
My Scenerio:
I trained a pre-trained model from tensorflow model zoo using transfer learning using tensorflow api as saved model (model.pb file) and converted it into tfjs format (model.json and shared .bin files).
When I tried running this model.json on the javascript(web), it gives the below error:
Uncaught (in promise) Error: The dtype of dict['input_tensor'] provided in model.execute(dict) must be int32, but was float32
When I tried someone else's working converted model (model.json and shared .bin files) on my javascript(web), it worked.
Conclusion:
There is something wrong with my converted model. I converted it using tensorflowjs_converter. My original model in (model.pb) works accurately in python too.
I'm still trying out to convert my model.pb file with different tensorflowjs_converters as it seems to be the converters versioning issue.

Related

opencv_annotation (-204:Requested object was not found)

root#debian:bin#./opencv_annotation --images=/pos/ --annotations=/pos/annotations.txt
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(3.4.8) /home/harry/haardev/opencv/modules/core/src/glob.cpp:267: error: (-204:Requested object was not found) could not open directory: /pos in function 'glob_rec'
Aborted
Upon getting the above error, I chmod 4777 the director pos/ and its images. I am still getting this error. Any ideas?
I am running Debian 10, Buster.
Also, how important is this feature? Thank you!
opencv requires absolute paths, verify that the pos directory is in the root directory or modify the given path accordingly.
Call the application on your data opencv_annotation -images /data/image_folder/ -annotations /data/annotations.txt. Keep in mind
that the tool loves absolute paths, since relative paths can screw up
the processing.
Also updated version require this syntax (you have used):
opencv_annotation --images=/data/image_folder/ --annotations=/data/annotations.txt
Please check the version you are using to identify what the correct syntax is.

Xamarin.Android binding generation giving "Type X was not found" errors for classes new in JDK 1.8

I'm trying to get Xamarin.Android to generate bindings for a library supplied as an AAR. JAR2XML is giving me a lot of "can't find type" errors, so I thought I'd try class-parse, but in addition to some library references I'm trying to track down, I'm getting a couple of these:
1> Error while processing '[Method] java.time.temporal.Temporal adjustInto(java.time.temporal.Temporal temporal, long newValue)' in '[Class] java.time.temporal.ChronoField': Type 'java.time.temporal.Temporal' was not found. (TaskId:69)
1> Error while processing '[Method] java.time.temporal.Temporal addTo(java.time.temporal.Temporal temporal, long amount)' in '[Class] java.time.temporal.ChronoUnit': Type 'java.time.temporal.Temporal' was not found. (TaskId:69)
Now, java.time.temporal.Temporal is a new type in JDK 1.8, so I'm wondering if maybe that's part of my problem here (ie. maybe the types that can't load are using other new-in-1.8 types). Running bin\javac -version in the path specified in Options-Xamarin-Android Settings says I'm using "1.8.0_172". My project is targeting "Android 8.1 (Oreo)" - ie. api level 27. Is there some other option I need to set to make sure I'm using 1.8?

H2O POJO causing javac java.lang.IllegalArgumentException

I have a distributed random forest POJO model using the default model setting except for:
ntrees = 150
max_depth = 50
min_rows = 5
Here are the full settings:
buildModel 'drf', {"model_id":"drf-335270ee-8970-4855-b521-c4fb4ca184f5","training_frame":"frame_0.750","validation_frame":"frame_0.250","nfolds":0,"response_column":"DENIAL","ignored_columns":["tx_match_date"],"ignore_const_cols":true,"ntrees":"150","max_depth":"50","min_rows":"5","nbins":20,"seed":-1,"mtries":-1,"sample_rate":0.6320000290870667,"score_each_iteration":true,"score_tree_interval":0,"balance_classes":false,"nbins_top_level":1024,"nbins_cats":1024,"r2_stopping":1.7976931348623157e+308,"stopping_rounds":0,"stopping_metric":"AUTO","stopping_tolerance":0.001,"max_runtime_secs":0,"checkpoint":"","col_sample_rate_per_tree":1,"min_split_improvement":0.00001,"histogram_type":"AUTO","categorical_encoding":"AUTO","build_tree_one_node":false,"sample_rate_per_class":[],"binomial_double_trees":true,"col_sample_rate_change_per_level":1,"calibrate_model":false}
When I try to compile the pojo with:
$javac -cp "h2o-genmodel.jar" -J-Xmx2g -J-XX:MaxPermSize=128m drf_335270ee_8970_4855_b521_c4fb4ca184f5.java
I get the following error.
An exception has occurred in the compiler (1.8.0_131). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.IllegalArgumentException
at java.nio.ByteBuffer.allocate(ByteBuffer.java:334)
at com.sun.tools.javac.util.BaseFileManager$ByteBufferCache.get(BaseFileManager.java:325)
at com.sun.tools.javac.util.BaseFileManager.makeByteBuffer(BaseFileManager.java:294)
at com.sun.tools.javac.file.RegularFileObject.getCharContent(RegularFileObject.java:114)
at com.sun.tools.javac.file.RegularFileObject.getCharContent(RegularFileObject.java:53)
at com.sun.tools.javac.main.JavaCompiler.readSource(JavaCompiler.java:602)
at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:665)
at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:950)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.main.Main.compile(Main.java:381)
at com.sun.tools.javac.main.Main.compile(Main.java:370)
at com.sun.tools.javac.main.Main.compile(Main.java:361)
at com.sun.tools.javac.Main.compile(Main.java:56)
at com.sun.tools.javac.Main.main(Main.java:42)
I don't get this error when replacing the DRF model with a deep learning pojo that I have also downloaded from h2o's Flow UI, so I'm thinking it is likely related to the drf_335270ee_8970_4855_b521_c4fb4ca184f5.java file (note that the POJO was too big to preview in H2O's Flow UI). What could be going on here?
Thanks
Instead of trying to compile an H2O random forest POJO, you can download and use a MOJO instead in almost exactly the same way without needing the compile step.
See:
http://docs.h2o.ai/h2o/latest-stable/h2o-genmodel/javadoc/index.html

Read a list from stream using Yap-Prolog

I want to run a (python3) process from my (yap) prolog script and read its output formatted as a list of integers, e.g. [1,2,3,4,5,6].
This is what I do:
process_create(path(python3),
['my_script.py', MyParam],
[stdout(pipe(Out))]),
read(Out, OutputList),
close(Out).
However, it fails at read/2 predicate with the error:
PL_unify_term: PL_int64 not supported
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
I am sure that I can run the process correctly because with [stdout(std)] parameter given to process_create the program outputs [1,2,3,4,5,6] as expected.
Weird thing is that when I change the process to output some constant term (as constant_term) it still gives the same PL_int64 error. Appending a dot to the process' output ([1,2,3,4,5,6].) doesn't solve the error. Using read_term/3 gives the same error. read_string/3 is undefined in YAP-Prolog.
How can I solve this problem?
After asking at the yap-users mailing list I got the solution.
Re-compiled YAP Prolog 6.2.2 with libGMP option and now it works. It may also occur in 32-bit YAP.

Code from dart2js is throwing NoSuchMethodErrors for get$functions

My Polymer.dart web app, that works fine in Dartium, is giving the following error (it repeats seven times) when compiled with dart2js using pub build --mode=debug and loaded in Chrome.
Resource interpreted as Script but transferred with MIME type text/plain: "http://confab.dev/index.html_bootstrap.dart". confab.dev/:10
warning: file:///home/dan/projects/confabulous/webatara/web/index.html.0.dart library not found index.html_bootstrap.dart.js:17188
Uncaught Error: NoSuchMethodError: Cannot call "get$functions" on "#<JsLibraryMirror>" (Object #<JsLibraryMirror> has no method 'get$functions') index.html_bootstrap.dart.js:17188
Stack Trace:
TypeError: Object #<JsLibraryMirror> has no method 'get$functions'
at dart._loadLibrary (http://confab.dev/index.html_bootstrap.dart.js:20000:19)
at dart._loadLibraries (http://confab.dev/index.html_bootstrap.dart.js:19917:11)
at dart._initPolymerOptimized (http://confab.dev/index.html_bootstrap.dart.js:19908:7)
at dart.initPolymer (http://confab.dev/index.html_bootstrap.dart.js:19902:7)
at main (http://confab.dev/index.html_bootstrap.dart.js:4112:7)
at _IsolateContext.eval$1 (http://confab.dev/index.html_bootstrap.dart.js:1369:23)
at dart.startRootIsolate (http://confab.dev/index.html_bootstrap.dart.js:1145:21)
at http://confab.dev/index.html_bootstrap.dart.js:26514:7
at init.currentScript (http://confab.dev/index.html_bootstrap.dart.js:26494:5)
at http://confab.dev/index.html_bootstrap.dart.js:26508:3
index.html_bootstrap.dart.js:17188
Uncaught NoSuchMethodError: Cannot call "get$functions" on "#<JsLibraryMirror>" (Object #<JsLibraryMirror> has no method 'get$functions') index.html_bootstrap.dart.js:2369
Because source maps don't appear to work (they're turned on in Chrome, and I have .map files), I don't even know which part of my code is causing this.
I've tried with interop.js included both before dart.js, as the docs say, and after, as this issue says.
Looks like a bug in dart2js. Please file an issue, ideally with a reproducible test-case.
pub upgrade fixed it. It turns out that something had replaced the polymer 0.9.5 that I'd been using with 0.8.10+4. Quite odd. The solution to this is to set the polymer version as '>= 0.9.5' instead of 'any', which I will do eventually, but for now I'm interested to see if it happens again.

Resources