Skip to content

Commit

Permalink
更新支持onnx
Browse files Browse the repository at this point in the history
  • Loading branch information
scarsty committed Mar 8, 2022
1 parent 676d8c7 commit 6710643
Show file tree
Hide file tree
Showing 13 changed files with 733 additions and 101 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ cmake-build-release
.vscode/
3rdparty/
.idea
.cache/
.cache/
models/
nn-editor/onnx.pb.cc
nn-editor/onnx.pb.h
2 changes: 1 addition & 1 deletion 3rdparty/ImGuiFileDialog
2 changes: 1 addition & 1 deletion 3rdparty/imgui
Submodule imgui updated 56 files
+14 −14 .github/workflows/build.yml
+2 −2 backends/imgui_impl_allegro5.cpp
+62 −34 backends/imgui_impl_glfw.cpp
+7 −3 backends/imgui_impl_glfw.h
+1 −1 backends/imgui_impl_glut.cpp
+5 −1 backends/imgui_impl_opengl3.cpp
+24 −19 backends/imgui_impl_osx.mm
+22 −16 backends/imgui_impl_sdl.cpp
+2 −1 backends/imgui_impl_sdl.h
+1 −1 backends/imgui_impl_sdlrenderer.cpp
+3 −3 backends/imgui_impl_win32.cpp
+2 −0 backends/imgui_impl_win32.h
+1 −1 docs/BACKENDS.md
+70 −23 docs/CHANGELOG.txt
+1 −1 docs/EXAMPLES.md
+1 −1 docs/FAQ.md
+1 −1 docs/FONTS.md
+4 −4 docs/README.md
+2 −2 examples/example_allegro5/main.cpp
+2 −2 examples/example_emscripten_opengl3/main.cpp
+1 −1 examples/example_glfw_metal/Makefile
+2 −2 examples/example_glfw_metal/main.mm
+1 −1 examples/example_glfw_opengl2/Makefile
+2 −2 examples/example_glfw_opengl2/main.cpp
+1 −1 examples/example_glfw_opengl3/Makefile
+2 −2 examples/example_glfw_opengl3/main.cpp
+2 −2 examples/example_glfw_vulkan/main.cpp
+1 −1 examples/example_glut_opengl2/Makefile
+3 −2 examples/example_glut_opengl2/main.cpp
+2 −2 examples/example_null/Makefile
+2 −2 examples/example_sdl_directx11/main.cpp
+1 −1 examples/example_sdl_metal/Makefile
+2 −2 examples/example_sdl_metal/main.mm
+1 −1 examples/example_sdl_opengl2/Makefile
+2 −2 examples/example_sdl_opengl2/main.cpp
+1 −1 examples/example_sdl_opengl3/Makefile
+2 −2 examples/example_sdl_opengl3/main.cpp
+1 −1 examples/example_sdl_sdlrenderer/Makefile
+5 −5 examples/example_sdl_sdlrenderer/main.cpp
+2 −2 examples/example_sdl_vulkan/main.cpp
+5 −4 examples/example_win32_directx10/main.cpp
+5 −4 examples/example_win32_directx11/main.cpp
+5 −4 examples/example_win32_directx12/main.cpp
+5 −4 examples/example_win32_directx9/main.cpp
+4 −4 imconfig.h
+168 −76 imgui.cpp
+30 −22 imgui.h
+14 −7 imgui_demo.cpp
+6 −29 imgui_draw.cpp
+40 −35 imgui_internal.h
+16 −8 imgui_tables.cpp
+11 −5 imgui_widgets.cpp
+0 −4 misc/cpp/imgui_stdlib.cpp
+0 −4 misc/cpp/imgui_stdlib.h
+12 −9 misc/fonts/binary_to_compressed_c.cpp
+2 −2 misc/freetype/README.md
2 changes: 1 addition & 1 deletion 3rdparty/nb
Submodule nb updated from 754bd1 to a196d9
77 changes: 0 additions & 77 deletions models/squeezenet_v1.1.param

This file was deleted.

2 changes: 1 addition & 1 deletion nn-editor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int main(int argc, char* argv[])
}

#ifdef USE_OPENGL3
#if __APPLE__
#ifdef __APPLE__
// GL 3.2 Core + GLSL 150
const char* glsl_version = "#version 150";
SDL_GL_SetAttribute(
Expand Down
4 changes: 4 additions & 0 deletions nn-editor/nn-editor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@
<ClCompile Include="nodeloader.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="ncnnloader.cpp" />
<ClCompile Include="onnx.pb.cc" />
<ClCompile Include="onnxloader.cpp" />
<ClCompile Include="yamlyololoader.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="ccccloader.h" />
<ClInclude Include="nodeloader.h" />
<ClInclude Include="ncnnloader.h" />
<ClInclude Include="node.h" />
<ClInclude Include="onnx.pb.h" />
<ClInclude Include="onnxloader.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="yamlyololoader.h" />
</ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions nn-editor/nn-editor.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
<ClCompile Include="yamlyololoader.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="onnxloader.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="onnx.pb.cc">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="nodeloader.h">
Expand All @@ -89,5 +95,11 @@
<ClInclude Include="resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="onnxloader.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="onnx.pb.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion nn-editor/nn-editor.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>../models/squeezenet_v1.1.param</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>../models/squeezenet1.1-7.onnx</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions nn-editor/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct Node

std::vector<Node*> prevs, nexts; //需注意下面的prev_pin和next_pin是画图的点数,准许大于等于size

//以下子类可以不处理
//use to draw nodes
int id, text_id;
int prev_pin = 0, next_pin = 0;
Expand Down
42 changes: 24 additions & 18 deletions nn-editor/nodeloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "ncnnloader.h"
#endif // NETEDIT_LOADER_NCNN

#include "onnxloader.h"

NodeLoader* create_loader(const std::string& filename, int index)
{
if (index > 0)
Expand Down Expand Up @@ -55,6 +57,10 @@ NodeLoader* create_loader(const std::string& filename, int index)
}
}
#endif // NETEDIT_LOADER_NCNN
if (ext == "onnx")
{
return new onnxloader();
}
return new ccccLoader();
}

Expand All @@ -80,49 +86,49 @@ void NodeLoader::calPosition(std::deque<Node>& nodes)
}
}
//层序
for (auto& n : nodes_turn)
for (auto& n : nodes)
{
if (n->prevs.size() > 0)
if (n.prevs.size() > 0)
{
for (auto& np : n->prevs)
for (auto& np : n.prevs)
{
n->turn = (std::max)(n->turn, np->turn + 1);
n.turn = (std::max)(n.turn, np->turn + 1);
}
}
}
//每层个数
std::map<int, int> turn_count, turn_count1;
for (auto& n : nodes_turn)
for (auto& n : nodes)
{
turn_count[n->turn]++;
turn_count[n.turn]++;
}
int width = 400;
for (auto& n : nodes_turn)
for (auto& n : nodes)
{
n->position_y = 150 * (n->turn + 1);
n->position_x = width * 2 - width * (turn_count[n->turn] / 2.0) + width * (turn_count1[n->turn]++);
n.position_y = 150 * (n.turn + 1);
n.position_x = width * 2 - width * (turn_count[n.turn] / 2.0) + width * (turn_count1[n.turn]++);
}
//同一层的上下层打散
for (auto& n : nodes_turn)
for (auto& n : nodes)
{
if (n->prevs.size() <= 1)
//if (n.prevs.size() <= 1)
{
int count = n->nexts.size();
int count = n.nexts.size();
int count1 = 0;
for (auto& n1 : n->nexts)
for (auto& n1 : n.nexts)
{
if (n1->nexts.size() > 1)
n1->position_x = n->position_x + width / 2 - width * (count / 2.0) + width * (count1++);
n1->position_x = n.position_x + width / 2 - width * (count / 2.0) + width * (count1++);
}
}
if (n->nexts.size() <= 1)
//if (n.nexts.size() <= 1)
{
int count = n->prevs.size();
int count = n.prevs.size();
int count1 = 0;
for (auto& n1 : n->prevs)
for (auto& n1 : n.prevs)
{
if (n1->prevs.size() > 1)
n1->position_x = n->position_x + width / 2 - width * (count / 2.0) + width * (count1++);
n1->position_x = n.position_x + width / 2 - width * (count / 2.0) + width * (count1++);
}
}
}
Expand Down
Loading

0 comments on commit 6710643

Please sign in to comment.