| # TensorFlow Inception |
|
|
| Image classification with the Inception v1 (GoogLeNet) network trained on ImageNet. |
| The model was originally distributed as a frozen TensorFlow graph |
| (`tensorflow_inception_graph.pb`) and converted to ONNX for use with OpenCV's DNN module. |
|
|
| ## Model Details |
| - **Architecture**: Inception v1 / GoogLeNet |
| - **Input**: RGB image, 224×224, raw 0–255 float, NHWC layout (`input:0`, shape `[1, 224, 224, 3]`) |
| - **Output**: ImageNet class scores, softmax over 1008 classes (`softmax2:0`) |
| - **Framework**: ONNX (converted from the TensorFlow frozen graph via tf2onnx, opset 18) |
| - **Original weights**: https://github.com/petewarden/tf_ios_makefile_example/raw/master/data/tensorflow_inception_graph.pb |
| |
| ## Usage |
| |
| ### Python |
| ```bash |
| python demo.py --model tensorflow_inception_graph_2026jul.onnx --image example_outputs/input_image.png --output example_outputs/output_image.png |
| ``` |
| |
| Or import directly: |
| ```python |
| import cv2 |
|
|
| net = cv2.dnn.readNet("tensorflow_inception_graph_2026jul.onnx") |
| # see demo.py for the full inference pipeline |
| ``` |
| |
| ### C++ |
| The C++ demo runs inference with OpenCV's DNN module (default engine — no ONNX Runtime |
| needed). Adjust the OpenCV paths to your setup: |
| ```bash |
| OCV=/path/to/opencv # OpenCV source tree |
| OCVBUILD=/path/to/opencv/build # OpenCV build directory (generated headers + libs) |
| g++ -std=c++17 demo.cpp -o demo \ |
| -I$OCV/include \ |
| -I$OCV/modules/core/include \ |
| -I$OCV/modules/dnn/include \ |
| -I$OCV/modules/imgproc/include \ |
| -I$OCV/modules/imgcodecs/include \ |
| -I$OCVBUILD \ |
| -L$OCVBUILD/lib -Wl,-rpath,$OCVBUILD/lib -lopencv_dnn -lopencv_imgcodecs -lopencv_imgproc -lopencv_core |
| ./demo --model tensorflow_inception_graph_2026jul.onnx --image example_outputs/input_image.png |
| ``` |
| |
| ## Conversion |
| The ONNX model was exported from the frozen TensorFlow graph with tf2onnx (opset 18) |
| via [convert_to_onnx.py](./convert_to_onnx.py) — inputs `input:0`, outputs `softmax2:0`, |
| input shape overridden to `[1, 224, 224, 3]`. Requires `tensorflow`, `tf2onnx`, and `onnx`. |
| |
| ```bash |
| python convert_to_onnx.py --pb ../pb/tensorflow_inception_graph.pb |
| ``` |
| |
| ## License |
| See [LICENSE](./LICENSE) — the model is released by the TensorFlow Authors under the Apache License 2.0. |
| |