This repository was archived by the owner on Mar 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Onnx model parser #45
Open
AlKurpiakov
wants to merge
26
commits into
embedded-dev-research:main
Choose a base branch
from
AlKurpiakov:ONNX-Model-Parser
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ab5dbf5
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 9eb09a6
Текущая ветка: ONNX-Model-Parser
AlKurpiakov f051a74
Текущая ветка: ONNX-Model-Parser
AlKurpiakov be3a143
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 02b7e35
Текущая ветка: ONNX-Model-Parser
AlKurpiakov cdd7ff7
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 554db69
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 6977b62
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 4c948ba
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 6d9ece4
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 7ac774e
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 96ea4d2
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 0ea25ea
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 97c7d81
Текущая ветка: ONNX-Model-Parser
AlKurpiakov b9b143e
Текущая ветка: ONNX-Model-Parser
AlKurpiakov 02adfb2
Текущая ветка: ONNX-Model-Parser
AlKurpiakov a00ccf7
Apply suggestions from code review
AlKurpiakov be78e1d
Apply suggestions from code review
AlKurpiakov 523e8c6
Apply suggestions from code review
AlKurpiakov 4961374
Apply suggestions from code review
AlKurpiakov b6fa564
Delete app/frontend/README.md
AlKurpiakov 6fa0e8e
Update CMakeLists.txt
AlKurpiakov 9de6597
Update CMakeLists.txt
AlKurpiakov c63661e
Update main.cpp
AlKurpiakov d414e9b
Update README.md
AlKurpiakov 74fecbd
Merge branch 'embedded-dev-research:main' into ONNX-Model-Parser
AlKurpiakov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| add_subdirectory(example) | ||
| add_subdirectory(frontend) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| cmake_minimum_required(VERSION 3.10) | ||
| project(ModelParser) | ||
|
|
||
| find_package(Protobuf REQUIRED) | ||
| set(ONNX_GENERATED_DIR "${CMAKE_SOURCE_DIR}/app/frontend/build/generated") | ||
|
|
||
|
|
||
| set(SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/app/frontend/GetModel.sh") | ||
|
|
||
| set(GENERATED_FILES | ||
| "${ONNX_GENERATED_DIR}/onnx.pb.cc" | ||
| "${ONNX_GENERATED_DIR}/onnx.pb.h" | ||
| "${ONNX_GENERATED_DIR}/yolo11x.onnx" | ||
| ) | ||
|
|
||
|
|
||
| add_custom_command( | ||
| OUTPUT ${GENERATED_FILES} | ||
| COMMAND ${CMAKE_COMMAND} -E make_directory "${ONNX_GENERATED_DIR}" | ||
| COMMAND ${CMAKE_COMMAND} -E chdir ${ONNX_GENERATED_DIR} bash ${SETUP_SCRIPT} "${ONNX_GENERATED_DIR}" | ||
| WORKING_DIRECTORY "${ONNX_GENERATED_DIR}" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot set directory to So it seems we will need to add |
||
| DEPENDS ${SETUP_SCRIPT} | ||
| COMMENT "Create directory, generate ONNX-files and get YOLO model" | ||
| ) | ||
|
|
||
| add_custom_target(generate_output ALL | ||
| DEPENDS ${GENERATED_FILES} | ||
| ) | ||
|
|
||
| set(ONNX_GENERATED_DIR "${CMAKE_SOURCE_DIR}/app/frontend/build/generated") | ||
|
|
||
| set_source_files_properties( | ||
| "${ONNX_GENERATED_DIR}/onnx.pb.cc" | ||
| "${ONNX_GENERATED_DIR}/onnx.pb.h" | ||
| "${ONNX_GENERATED_DIR}/yolo11x.onnx" | ||
| PROPERTIES GENERATED TRUE | ||
| ) | ||
|
|
||
| add_executable(ModelParser | ||
| main.cpp | ||
| "${ONNX_GENERATED_DIR}/onnx.pb.cc" | ||
| ) | ||
| add_dependencies(ModelParser generate_output) | ||
| target_include_directories(ModelParser PRIVATE | ||
| "${ONNX_GENERATED_DIR}" | ||
| ${Protobuf_INCLUDE_DIRS} | ||
| ) | ||
|
|
||
| target_link_libraries(ModelParser | ||
| ${Protobuf_LIBRARIES} | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/bin/bash | ||
|
|
||
| protoc --proto_path=3rdparty/onnx/onnx --cpp_out=$1 onnx.proto | ||
| yolo export model=$1/yolo11x.pt format=onnx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #include <fstream> | ||
| #include <iostream> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "./generated/onnx.pb.h" | ||
|
|
||
| int main() { | ||
| std::ifstream model_file("generated/yolo11x.onnx", std::ios::binary); | ||
|
|
||
| if (!model_file.is_open()) { | ||
| std::cerr << "Failed to open model" << std::endl; | ||
| return 1; | ||
| } | ||
|
|
||
| onnx::ModelProto model; | ||
| if (!model.ParseFromIstream(&model_file)) { | ||
| std::cerr << "Model parsing error" << std::endl; | ||
| return 1; | ||
| } | ||
| model_file.close(); | ||
|
|
||
| std::vector<std::string> layer; | ||
|
|
||
| for (int i = 0; i < model.graph().node_size(); ++i) { | ||
| const onnx::NodeProto& node = model.graph().node(i); | ||
| layer.emplace_back(node.op_type()); | ||
| } | ||
|
|
||
| for (auto it : layer) { | ||
| std::cout << it << std::endl; | ||
| } | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ultralytics >= 8.3.107 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.