File | Date | Author | Commit |
---|---|---|---|
.github | 2022-06-27 |
![]() |
[1d47af] Create codeql-analysis.yml |
Keras.cpp | 2022-06-24 |
![]() |
[e435ba] Add files via upload |
Keras.h | 2022-06-24 |
![]() |
[e435ba] Add files via upload |
Keras2cpp.py | 2022-06-24 |
![]() |
[81a825] Add files via upload |
LICENSE | 2022-06-24 |
![]() |
[1fa11a] Initial commit |
README.md | 2022-06-24 |
![]() |
[45e057] Update README.md |
img1.ppm | 2022-06-24 |
![]() |
[e435ba] Add files via upload |
main.cpp | 2022-06-24 |
![]() |
[e435ba] Add files via upload |
modellayersonlytext.txt | 2022-06-24 |
![]() |
[e435ba] Add files via upload |
modeltext.txt | 2022-06-24 |
![]() |
[e435ba] Add files via upload |
convert and use your keras trained model in c/c++ project in the easist way. Multithreaded implementation for faster execution. Tested on visual studio vc++, but can be used with any other compiler.
Step 1: Convert Your Keras Model into text files
Step 2: Include Keras.h and Keras.cpp files into your project
Step 3: Read or convert your image into keras format
Step 4: call ExecuteKerasSegmentation
Step 5: save result
For step 1:
1a - Load your keras model
model=keras.models.load_model('model.h5')
2a - Save your keras model into two text files
save_keras_model_as_text(model, open('modeltext.txt', 'w') )
save_keras_model_as_text(model, open('modellayersonlytext.txt', 'w') , noweight=True)
Step 2: #include "Keras.h"
Step 3: Open an image into keras format or convert your image into keras format
int w,h;
int *img = open_image_ppm("img1.ppm", w,h);
Step 4:
char modelfile ="modellayersonlytext.txt";
char weightfile="modeltext.txt";
int *result = ExecuteKerasSegmentation(img, h, w, 3, modelfile, weightfile);
Step 5: Save or Use your result.
save_image_pgm("segmentation_map.pgm",result,h,w,127);