# HG changeset patch # User Sebastien Jodogne # Date 1681807989 -7200 # Node ID d4e769a0961f12dd1585a991524276a056ec05f9 # Parent 0d814292a17ec8dbaca16375ff9633673e0b3b19 automating invokation of protobuf in deep-learning diff -r 0d814292a17e -r d4e769a0961f Applications/StoneWebViewer/WebAssembly/CMakeLists.txt --- a/Applications/StoneWebViewer/WebAssembly/CMakeLists.txt Thu Mar 30 17:20:26 2023 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/CMakeLists.txt Tue Apr 18 10:53:09 2023 +0200 @@ -24,8 +24,6 @@ project(OrthancStone) include(${CMAKE_SOURCE_DIR}/../Version.cmake) -include(${CMAKE_SOURCE_DIR}/deep-learning/WebAssembly/Protobuf.cmake) # TODO - set(ORTHANC_STONE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../../../wasm-binaries/StoneWebViewer" CACHE PATH "Where to put the WebAssembly binaries") @@ -63,6 +61,8 @@ SET(ENABLE_LOCALE ON) # Necessary for text rendering SET(ENABLE_PUGIXML ON) # Necessary for OsiriX annotations SET(ORTHANC_SANDBOXED ON) +SET(ENABLE_PROTOBUF ON) # Necessary for deep learning +SET(ENABLE_PROTOBUF_COMPILER ON) # Necessary for deep learning # this will set up the build system for Stone of Orthanc and will # populate the ORTHANC_STONE_SOURCES CMake variable @@ -120,9 +120,21 @@ ${STONE_WRAPPER} ) -add_custom_target(StoneWrapper +add_custom_command( + OUTPUT + ${AUTOGENERATED_DIR}/DeepLearningWorker.pb.h + ${AUTOGENERATED_DIR}/DeepLearningWorker.pb.cc + COMMAND ${PROTOC_EXECUTABLE} --cpp_out=${AUTOGENERATED_DIR} -I${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/DeepLearningWorker.proto + DEPENDS + ${CMAKE_SOURCE_DIR}/DeepLearningWorker.proto + ProtobufCompiler + ) + +add_custom_target(AutogeneratedFiles DEPENDS ${STONE_WRAPPER} + ${AUTOGENERATED_DIR}/DeepLearningWorker.pb.cc ) @@ -135,9 +147,8 @@ add_executable(StoneWebViewer ${ORTHANC_STONE_SOURCES} - ${AUTOGENERATED_SOURCES} - ${PROTOBUF_SOURCES} # TODO - ${CMAKE_SOURCE_DIR}/Worker.pb.cc # TODO + ${AUTOGENERATED_SOURCES} # Populated by "EmbedResources()" + ${AUTOGENERATED_DIR}/DeepLearningWorker.pb.cc StoneWebViewer.cpp ) @@ -148,7 +159,7 @@ ) # Make sure to have the wrapper generated -add_dependencies(StoneWebViewer StoneWrapper) +add_dependencies(StoneWebViewer AutogeneratedFiles) # Declare installation files for the module diff -r 0d814292a17e -r d4e769a0961f Applications/StoneWebViewer/WebAssembly/DeepLearningWorker.proto --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Applications/StoneWebViewer/WebAssembly/DeepLearningWorker.proto Tue Apr 18 10:53:09 2023 +0200 @@ -0,0 +1,61 @@ +syntax = "proto2"; +option optimize_for = LITE_RUNTIME; + +package OrthancStone.Messages; + +enum RequestType { + PARSE_MODEL = 1; + LOAD_IMAGE = 2; + EXECUTE_STEP = 3; +} + +enum ResponseType { + INITIALIZED = 1; + PARSED_MODEL = 2; + LOADED_IMAGE = 3; + STEP_DONE = 4; +} + +message ParseModelRequest { + required bytes content = 1; +} + +message ParseModelResponse { + required uint32 number_of_steps = 1; +} + +message LoadImageRequest { + required string sop_instance_uid = 1; + required uint32 frame_number = 2; + required uint32 height = 3; + required uint32 width = 4; + repeated float values = 5 [packed=true]; +} + +message SegmentationMask { + required string sop_instance_uid = 1; + required uint32 frame_number = 2; + required uint32 height = 3; + required uint32 width = 4; + repeated bool values = 5 [packed=true]; +} + +message StepResponse { + required bool done = 1; + required float progress = 2; + optional SegmentationMask mask = 3; +} + +message Request { + required RequestType type = 1; + + optional ParseModelRequest parse_model = 2; + optional LoadImageRequest load_image = 3; +} + +message Response { + required ResponseType type = 1; + + optional ParseModelResponse parse_model = 2; + optional StepResponse step = 3; +} diff -r 0d814292a17e -r d4e769a0961f Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Thu Mar 30 17:20:26 2023 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Tue Apr 18 10:53:09 2023 +0200 @@ -3927,7 +3927,7 @@ #include -#include "Worker.pb.h" +#include enum DeepLearningState {