How to create a ONNX File? - neural-network

How to create an ONNX file manually? I mean without using the frameworks like PyTorch, caffe2, e.t.c, can we(binary encode maybe) create an onnx file, if we know the network details in prior like # of nodes, types of nodes, their connections, e.t.c?

Found it!! We can use onnx.helper class inside onnx library to create a model and save it in onnx format.

Related

Can I save python function as .tflite?

I want to preprocess an audio file and convert it to spectrogram before inserting it to my tflite model in flutter app. is there a way I can run my preprocessing function (.py) on flutter by converting it to .tflite?
That's currently not supported. You would have to include the preprocessing steps in the model itself (as TF ops, if the ops are supported in TFLite) so that it's included in converted TFLite model, or preprocess it manually outside the model in Flutter.
Kindly close the issue / mark this as the accepted answer if your issue is resolved.

Add input txt in FMU for co-simulation

I have an FMU for co-simulation and I want to add as input to this model a txt file with CombiTable and then export it again as an FMU. My question is how can I achieve that since OpenModelica cannot import FMU for co-simulation.
There are several Modelica Tools that allow for the re-export of FMUs, e.g. Dymola and SimulationX.
If you want to do it with open source software, you could export the combitable as a second FMU, and create a containerized FMU with fmpy out of these two FMUs, see https://github.com/CATIA-Systems/FMPy/blob/master/tests/test_fmu_container.py for an example.
I'm not sure if there are any tools that support such a way to pack FMUs.
You could however make a co-simulation SSP via OMEdit.
First make another FMU that contains the combitable.
Then make a new SSP, add both these FMUs.

Darknet model to onnx

I am currently working with Darknet on Yolov4, with 1 class.
I need to export those weights to onnx format, for tensorRT inference.
I've tried multiple technics, using ultralytics to convert or going from tensorflow to onnx. But none seems to work. Is there a direct way to do it?
Check this GitHub repo: https://github.com/Tianxiaomo/pytorch-YOLOv4
Running the demo_darknet2onnx.py script you'll be able to generate the ONNX model from the .cfg and .weights darknet files.
Usage example:
python demo_darknet2onnx.py <cfgFile> <weightFile> <imageFile> <batchSize>
You can also decide the batch size for the inference calls of the converted model.
The following repo exports yolov3 models from darknet to onnx, for tensorRT inference. You can use this as reference for your model.
https://github.com/jkjung-avt/tensorrt_demos/tree/master/yolo
You can convert scaled YOLO-yolov4,yolov4-csp.yolov4x-mish,yolov4-P5 etc models into onxx & its perfectly work fine.
https://github.com/linghu8812/tensorrt_inference

Error library Simulink

I have created a simple Simulink library because I am learning about masks. The library is saved into Documents folder, which is in path of MATLAB. To test my library, I've created a model and I've inserted my block from my library. When I want to change the value of a parameter in the mask I receive this error screenshot of message
Is there any configuration to do?
Thank you so much

Export from OpenCascade, import into OpenSceneGraph

We have a modeling tool which uses OCC, and a 3d editor using OSG. What I want to do is, export the model from the first tool and import into the second tool. I have been searching the web for days, but I can't find a solution.
Three things can solve my problem:
An exporter for OCC to export into OSG supported formats (.ive, .osg, and many more),
An importer for OSG to import from OCC supported formats (.stp, .step, .igs, .iges, .brp, .brep ),
A converter tool for converting between two formats, one format supported by OCC and one format supported by OSG.
Has anybody done this before, or know of anything that can help?
I am trying to avoid writing a custom exporter for OCC.
I found a solution. OpenCascade has an import/export example, which can export VRML files without texture support. Some modifications on the import export code and some modifications on other parts (where the OCC model is represented by VRML classes) was enough to successfully export my model to a VRML file. Then i built the VRML plugin for OpenSceneGraph and successfully imported the model.
CADExchanger (OCC based) does a pretty good job converting between BRep and other formats (STEP, IGES, STL, VRML...)
Why don't you have a look at pythonocc.org.
I'm assuming OSG takes meshes?
Load the STEP / IGES file in (python)OCC, grab its mesh, push the verts / indices to OSG.
Would that work?