Three.js - "Unknown format" Error when using .FBX Models - javascript

im fairly new to THREE.js. Im trying to load a .FBX Object via the FBXLoader located in three/examples/jsm/loaders/FBXLoader.
Also, i'm using this in React.js.
Now, the page loads but the model isnt there. The error in the console says: An error happened: Error: THREE.FBXLoader: Unknown format.
My FBX File seems to be in binary format, not in ASCII Format.
I really dont know what to do.
My Code:
//deleted
I also tried moving the models folder in and out of the public folder.
Thanks in advance.

I found a solution.
My FBX file had an old version, also it had Binary encoding.
Switching to ASCII and a newer version fixed everything.

Related

Why loadGraphModel function from tensorflow.js not working?

I am working on deploy an ML that I trained using tensorflow (in Python). The model is saved as an .h5 file. After converting the model using the tensorflowjs_converter --input_format=keras ./model/myFile.h5 /JS_model/ command.
I imported the tensorflow library using the following:
<script src="https://cdn.jsdelivr.net/npm/#tensorflow/tfjs/dist/tf.min.js"> </script>
After this, I ws able to load the model using the loadLayersModel() function. However, when using the loadGraphModel, it does not work. It outputs this error on the browser:
''
I also tried using the tf.models.save_model.save() function in python which it outputs the variables and assets folders, as well as the .pb file. However, an error still occurs. Using the code above, changing only the path to 'THE_classifier' (which is the name of the folder where asset, variables and the .pb is located), the output is:
I want to work with the loadGraphModel() function because according to various sources, it provides a faster inference time.
layers models and graph models have different internal layout, they are not compatible and interchangable. if its a layers model, it must be loaded with tf.loadLayersModel and if its a graph model, it must be loaded with tf.loadGraphModel
graph models are frozen models - so if you want to convert keras model to graph, you need to freeze it first, else it can only be converted to layers model
(and thats where difference in inference time comes from - its faster to evaluate a frozen model than one that is still using variables)

Error: Cant't find end of central directory

I am trying to open my base64 file as docx which is created with react-docx library and for that I am using another library react-file-viewer, but I get the following error: "Error: Cant't find end of central directory : is this a zip file ? If it is, see http://...".
I also tried it with react-iframe but unfortunately browsers don't support docx files and it works but it downloads the file instead of displaying. And I need it to be displayed.
This is my code:
<FileViewer
fileType='docx'
filePath={`data:application/docx;base64,${file}`}
/>
If anyone could help me with that. I am looking for the solution for many days and can't find any.

Errors including and calling FBXLoader with Three.js

I'm new to three.js and I was following along a tutorial on loading GLTF Models using Three.js. I wanted to practice by using the FBX loader to import and animate models from Mixamo.
The tutorial used CDNs for the three.min.js and GLTFLoader files. I tried doing the same for the FBXLoader. However, I keep getting errors calling the FBXLoader from my main.js file
In my HTML I have:
In my main.js I've tried calling it like so:
const loader = new THREE.FBXLoader();
and
const loader = new FBXLoader();
then get the following respective errors
Uncaught TypeError: THREE.FBXLoader is not a constructor
Uncaught ReferenceError: FBXLoader is not defined
I've messed around with it quite a bit, and tried removing the type "module" and changing "jsm" to "js" with no luck either. (Plus I also encounter a deprecation warning when I do that). I don't have the best understanding of importing plugins from three.js so any clarification would help.
Also, I see that GLTF is the preferred format for Three.js, should I convert my FBX model and animations from Mixamo to GLTF using blender?
Thank you
Did you try loading the FBXLoader first via script- tag in your html as it must be before instantiating it ? If not, load the .js- version.

Convert tfjs model for using in Tensorflow in c++

I'm new to tensorflow and I have one question, My project has two majors part, first written in NodeJs that train my model from dataset and save model to local storage, so I have two files:
model.json
wights.bin
The second part is written in c++, After couple of days I could build tensorflow with bazel and add it to my OpenCv project, so here is my question :
I want to train my model in NodeJs part and use these models in my C++ part. Is this possible ?
also I saw tjs converter but it converts models to use in NodeJs not vice versa.
Update :
After searching a lot I figured out that I should convert my models to protobuff file, but tfjs-Converter does not support this type of conversion and another point is that I want to use my model with opencv library.
Update 2
Finally I could change my model to .pb file, first I use tfjs_converter to convert to keras model(.h5 file) and after that use this python script to convert to .pb file and opencv can successfully load model. But I got this error in using model :
libc++abi.dylib: terminating with uncaught exception of type
cv::Exception: OpenCV(4.1.0)
/tmp/opencv-20190505-12101-14vk1fh/opencv-4.1.0/modules/dnn/src/dnn.cpp:524:
error: (-2:Unspecified error) Can't create layer
"flatten_Flatten1/Shape" of type "Shape" in function
'getLayerInstance'
Any help ?
thanks
Finally i solved my own problem.
Here is the steps that I've done :
Convert my tfjs model to keras model using tfjs-converter
Using this python scripts to change keras(.h5) model to frozen model(.pb)
Use this tutorial to optimize my .pb model
Finally everything works great!

Expressjs : issue with image file encoding during res.download

I have a pretty run-of-the-mill node.js server with expressjs installed locally for development purposes; I store various files and request them via a basic HTTP call that returns the file through express' res.download feature. Most of the time, this works without a hitch. For a very small subset of files, however, the end-user receives a file that is much larger than expected (almost 2x) and is unreadable by any conventional viewer. Out of maybe a hundred files, this has only happened twice, and both were JPG files, but the sample is too small to draw any conclusion. What I know :
The issue is reproductible : if it happens with a file, it always happens;
The issue is not related to the way files are stored : if I swap the problematic file with another one but keep everything else the same (name, location, etc.), it works fine;
Right before the res.download happens, the file is okay : checking its size with fs.stats returns the correct value
The HTTP response encounters no visible problem : no error, 200 response code...
The source file seems to have normal metadata and JPG markers
UPDATE I did some tests, and the issue seems to be somehow related to encoding : the mangled response file is, for reasons unknown, encoded in UTF-8 ; the size discrepancy comes from all non-UTF-8 characters being replaced by EF BF BD (the unknown character symbol) ! I still can't understand why it happens, what makes these few files different from others, and if it can be detected and/or corrected upstream.
UPDATE 2 After some additional tests, I still can't quite pinpoint the cause, but I can add the following info :
Systems-wise, the issue happens during the data streaming in fs.js
The root cause is located somewhere in the EXIF data of the image
For those interested, the source image (source.JPG) and download result (response.JPG) can be found here : http://www.sycomor.fr/test/ ; I also added a similar image that isn't affected by the download and comes out clean. For what it's worth, both pictures were taken minutes apart, with the same camera at the same settings, so I strongly doubt the issue is caused by some external source.
Thanks !
Your issue comes from 'connect-livereload' in your express configuration.
It corrupts binary stream while injecting the reloading script.
Refer to https://github.com/intesso/connect-livereload/issues/39 for details.

Categories