Error reading original efficientdet-d3_frozen.pb on openCV`s readNetFromTensorflow.
During the process, I successfully converted the original coco checkpoint of the efficientdet-d3 dataset into a frozen tensorflow model by EfficientDet :
python model_inspect.py --runmode=saved_model --model_name=efficientdet-d3 --ckpt_path=efficientdet-d3 --saved_model_dir=export_orig
Python 3.9.11
tensorflow>=2.10.0
OS Windows
Successfully tested the file on a test image - detection works
python model_inspect.py --runmode=saved_model_infer --model_name=efficientdet-d3 --saved_model_dir=export_orig\efficientdet-d3_frozen.pb --min_score_thresh=0.1 --input_image=test2.jpg --output_image_dir=output
config.yaml
input_rand_hflip: True jitter_max: 1 jitter_min: 1 num_classes: 2 max_level: 7 num_scales: 2 anchor_scale: 4 skip_crowd_during_training: False label_map: {0: background, 1: ball}
Then strange things happen: We take the frozen model .pb and try to use it in other project with other Env: Opencv 4.6.0 CUDA 11.4 Ubuntu 20.04 Python 3.8.10 NODEJS u4@\opencv4nodejs
Let's run the code:
let net = await cv2.readNetFromTensorflow(modelPbPathOrig);
We get an error:
ReadNetFromTensorflow - OpenCV Error: (Input layer not found: fpn_cells/cell_2/fnode7/WSM_1) in connect, in file /home/stuurgurs/opencv4/opencv-4.7.0/modules/dnn/src/tensorflow/tf_importer.cpp
What is the problem I can’t understand?
I tried to create a frozen model file with different hyperparameters, with a different number of classes and other settings - get an error.
I also tried to create and use a graph file .pbtxt with .pb - get an error.
I tried to use other opencv_face_detector_uint8.pb model files - it loads without errors!
The solution was to perform tensorFlow graph transform with tensorflow/tools/graph_transforms/transform_graph
also you should take all outputs. Yu can see your graph outputs by
to build this tool you can run on ububtu cmd next command:
bazel build tensorflow/tools/graph_transforms:summarize_graph