From 504007453ec87e4089541c700edcc0dcff8892b7 Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Wed, 21 May 2025 11:19:12 +0200 Subject: [PATCH 01/15] pull image gen --- src/cli_parser.cpp | 11 ++++++++++- src/graph_export/graph_export.cpp | 2 ++ src/graph_export/graph_export_types.hpp | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cli_parser.cpp b/src/cli_parser.cpp index b061d99bea..f8240669bd 100644 --- a/src/cli_parser.cpp +++ b/src/cli_parser.cpp @@ -147,7 +147,7 @@ void CLIParser::parse(int argc, char** argv) { cxxopts::value(), "MODEL_REPOSITORY_PATH") ("task", - "Choose type of model export: text_generation - chat and completion endpoints, embeddings - embeddings endpoint, rerank - rerank endpoint.", + "Choose type of model export: text_generation - chat and completion endpoints, embeddings - embeddings endpoint, rerank - rerank endpoint, image_generation - image generation/edit/inpainting endpoints.", cxxopts::value()->default_value("text_generation"), "TASK") ("list_models", @@ -237,6 +237,11 @@ void CLIParser::parse(int argc, char** argv) { unmatchedOptions = std::get(this->graphOptionsParser).parse(result->unmatched()); break; } + case image_generation: { + std::cerr << "not implemented" << std::endl; + exit(OVMS_EX_USAGE); + break; + } case unknown: { std::cerr << "error parsing options - --task parameter unsupported value: " + result->operator[]("task").as(); exit(OVMS_EX_USAGE); @@ -452,6 +457,10 @@ void CLIParser::prepareGraph(HFSettingsImpl& hfSettings, const std::string& mode std::get(this->graphOptionsParser).prepare(hfSettings, modelName); break; } + case image_generation: { + throw std::logic_error("not implemented"); + break; + } case unknown: { throw std::logic_error("Error: --task parameter unsupported value: " + result->operator[]("task").as()); break; diff --git a/src/graph_export/graph_export.cpp b/src/graph_export/graph_export.cpp index 775ec25038..586ebc0fa0 100644 --- a/src/graph_export/graph_export.cpp +++ b/src/graph_export/graph_export.cpp @@ -283,6 +283,8 @@ Status GraphExport::createServableConfig(const std::string& directoryPath, const return createEmbeddingsGraphTemplate(directoryPath, hfSettings.embeddingsGraphSettings); } else if (hfSettings.task == rerank) { return createRerankGraphTemplate(directoryPath, hfSettings.rerankGraphSettings); + } else if (hfSettings.task == image_generation) { + throw std::logic_error("not implemented"); } } diff --git a/src/graph_export/graph_export_types.hpp b/src/graph_export/graph_export_types.hpp index f67fd15bf7..dcb93ba2cb 100644 --- a/src/graph_export/graph_export_types.hpp +++ b/src/graph_export/graph_export_types.hpp @@ -22,6 +22,7 @@ enum ExportType { text_generation, rerank, embeddings, + image_generation, unknown }; @@ -29,12 +30,14 @@ const std::map typeToString = { {text_generation, "text_generation"}, {rerank, "rerank"}, {embeddings, "embeddings"}, + {image_generation, "image_generation"}, {unknown, "unknown"}}; const std::map stringToType = { {"text_generation", text_generation}, {"rerank", rerank}, {"embeddings", embeddings}, + {"image_generation", image_generation}, {"unknown", unknown}}; std::string enumToString(ExportType type); From d7ef06e40ef624d2160df87afca070b15f8bebd3 Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Wed, 21 May 2025 12:07:39 +0200 Subject: [PATCH 02/15] save --- src/BUILD | 1 + src/capi_frontend/server_settings.hpp | 8 ++ src/cli_parser.cpp | 8 +- src/cli_parser.hpp | 3 +- src/graph_export/BUILD | 15 +++ src/graph_export/graph_export.cpp | 29 ++++- .../image_generation_graph_cli_parser.cpp | 102 ++++++++++++++++++ .../image_generation_graph_cli_parser.hpp | 45 ++++++++ 8 files changed, 206 insertions(+), 5 deletions(-) create mode 100644 src/graph_export/image_generation_graph_cli_parser.cpp create mode 100644 src/graph_export/image_generation_graph_cli_parser.hpp diff --git a/src/BUILD b/src/BUILD index 6c6475ca77..ebdad5a913 100644 --- a/src/BUILD +++ b/src/BUILD @@ -345,6 +345,7 @@ cc_library( "//src/graph_export:graph_cli_parser", "//src/graph_export:rerank_graph_cli_parser", "//src/graph_export:embeddings_graph_cli_parser", + "//src/graph_export:image_generation_graph_cli_parser", ], visibility = ["//visibility:public",], local_defines = COMMON_LOCAL_DEFINES, diff --git a/src/capi_frontend/server_settings.hpp b/src/capi_frontend/server_settings.hpp index a095763070..dca580a483 100644 --- a/src/capi_frontend/server_settings.hpp +++ b/src/capi_frontend/server_settings.hpp @@ -60,6 +60,13 @@ struct RerankGraphSettingsImpl { uint32_t version = 1; // FIXME: export_rerank_tokenizer python method - not supported currently? }; +struct ImageGenerationGraphSettingsImpl { + std::string modelName = ""; + std::string modelPath = "./"; + std::string targetDevice = "CPU"; + std::string defaultResolution = "512x512"; +}; + struct HFSettingsImpl { std::string sourceModel = ""; std::string downloadPath = ""; @@ -69,6 +76,7 @@ struct HFSettingsImpl { TextGenGraphSettingsImpl graphSettings; RerankGraphSettingsImpl rerankGraphSettings; EmbeddingsGraphSettingsImpl embeddingsGraphSettings; + ImageGenerationGraphSettingsImpl imageGenerationGraphSettings; }; struct ServerSettingsImpl { diff --git a/src/cli_parser.cpp b/src/cli_parser.cpp index f8240669bd..ad1e67f05e 100644 --- a/src/cli_parser.cpp +++ b/src/cli_parser.cpp @@ -26,6 +26,7 @@ #include "graph_export/graph_cli_parser.hpp" #include "graph_export/rerank_graph_cli_parser.hpp" #include "graph_export/embeddings_graph_cli_parser.hpp" +#include "graph_export/image_generation_graph_cli_parser.hpp" #include "ovms_exit_codes.hpp" #include "version.hpp" @@ -238,8 +239,9 @@ void CLIParser::parse(int argc, char** argv) { break; } case image_generation: { - std::cerr << "not implemented" << std::endl; - exit(OVMS_EX_USAGE); + ImageGenerationGraphCLIParser cliParser; + this->graphOptionsParser = std::move(cliParser); + unmatchedOptions = std::get(this->graphOptionsParser).parse(result->unmatched()); break; } case unknown: { @@ -458,7 +460,7 @@ void CLIParser::prepareGraph(HFSettingsImpl& hfSettings, const std::string& mode break; } case image_generation: { - throw std::logic_error("not implemented"); + std::get(this->graphOptionsParser).prepare(hfSettings, modelName); break; } case unknown: { diff --git a/src/cli_parser.hpp b/src/cli_parser.hpp index 7fc4527aff..26013d27fe 100644 --- a/src/cli_parser.hpp +++ b/src/cli_parser.hpp @@ -24,6 +24,7 @@ #include "graph_export/graph_cli_parser.hpp" #include "graph_export/rerank_graph_cli_parser.hpp" #include "graph_export/embeddings_graph_cli_parser.hpp" +#include "graph_export/image_generation_graph_cli_parser.hpp" namespace ovms { @@ -33,7 +34,7 @@ struct ModelsSettingsImpl; class CLIParser { std::unique_ptr options; std::unique_ptr result; - std::variant graphOptionsParser; + std::variant graphOptionsParser; public: CLIParser() = default; diff --git a/src/graph_export/BUILD b/src/graph_export/BUILD index e5a60eea0d..895520e60e 100644 --- a/src/graph_export/BUILD +++ b/src/graph_export/BUILD @@ -60,6 +60,21 @@ cc_library( visibility = ["//visibility:public"], ) +cc_library( + name = "image_generation_graph_cli_parser", + srcs = ["image_generation_graph_cli_parser.cpp"], + hdrs = ["image_generation_graph_cli_parser.hpp"], + deps = [ + "@ovms//src/graph_export:graph_export_types", + "@ovms//src/graph_export:graph_cli_parser", + "@ovms//src:cpp_headers", + "@ovms//src:libovms_server_settings", + "@ovms//src:ovms_exit_codes", + "@com_github_jarro2783_cxxopts//:cxxopts", + ], + visibility = ["//visibility:public"], +) + cc_library( name = "embeddings_graph_cli_parser", srcs = ["embeddings_graph_cli_parser.cpp"], diff --git a/src/graph_export/graph_export.cpp b/src/graph_export/graph_export.cpp index 586ebc0fa0..8345d98e53 100644 --- a/src/graph_export/graph_export.cpp +++ b/src/graph_export/graph_export.cpp @@ -268,6 +268,33 @@ static Status createEmbeddingsGraphTemplate(const std::string& directoryPath, co return createEmbeddingsSubconfigTemplate(directoryPath, graphSettings); } +static Status createImageGenerationGraphTemplate(const std::string& directoryPath, const ImageGenerationGraphSettingsImpl& graphSettings) { + std::ostringstream oss; + // clang-format off + oss << R"( +input_stream: "HTTP_REQUEST_PAYLOAD:input" +output_stream: "HTTP_RESPONSE_PAYLOAD:output" + +node: { + name: "ImageGenExecutor" + calculator: "ImageGenCalculator" + input_stream: "HTTP_REQUEST_PAYLOAD:input" + input_side_packet: "IMAGE_GEN_NODE_RESOURCES:pipes" + output_stream: "HTTP_RESPONSE_PAYLOAD:output" + node_options: { + [type.googleapis.com / mediapipe.ImageGenCalculatorOptions]: { + models_path: ")" << graphSettings.modelPath << R"(", + } + } +)"; + + // TODO: Remaining params + + // clang-format on + std::string fullPath = FileSystem::joinPath({directoryPath, "graph.pbtxt"}); + return createFile(fullPath, oss.str()); +} + GraphExport::GraphExport() { } @@ -284,7 +311,7 @@ Status GraphExport::createServableConfig(const std::string& directoryPath, const } else if (hfSettings.task == rerank) { return createRerankGraphTemplate(directoryPath, hfSettings.rerankGraphSettings); } else if (hfSettings.task == image_generation) { - throw std::logic_error("not implemented"); + return createImageGenerationGraphTemplate(directoryPath, hfSettings.imageGenerationGraphSettings); } } diff --git a/src/graph_export/image_generation_graph_cli_parser.cpp b/src/graph_export/image_generation_graph_cli_parser.cpp new file mode 100644 index 0000000000..fe9ba61b5c --- /dev/null +++ b/src/graph_export/image_generation_graph_cli_parser.cpp @@ -0,0 +1,102 @@ +//***************************************************************************** +// Copyright 2025 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** +#include "image_generation_graph_cli_parser.hpp" + +#include +#include +#include +#include +#include +#include +#include + +#include "../capi_frontend/server_settings.hpp" +#include "../ovms_exit_codes.hpp" +#include "../status.hpp" + +namespace ovms { + +ImageGenerationGraphSettingsImpl& ImageGenerationGraphCLIParser::defaultGraphSettings() { + static ImageGenerationGraphSettingsImpl instance; + return instance; +} + +void ImageGenerationGraphCLIParser::createOptions() { + this->options = std::make_unique("ovms --pull [PULL OPTIONS ... ]", "-pull --task image generation/edit/inpainting graph options"); + options->allow_unrecognised_options(); + + // clang-format off + options->add_options("image_generation") + ("graph_target_device", + "CPU, GPU, NPU or HETERO, default is CPU.", + cxxopts::value()->default_value("CPU"), + "GRAPH_TARGET_DEVICE") + ("default_resolution", + "Default width and height of requested image in case user does not provide it.", + cxxopts::value()->default_value("512x512"), + "DEFAULT_RESOLUTION"); +} + +void ImageGenerationGraphCLIParser::printHelp() { + if (!this->options) { + this->createOptions(); + } + std::cout << options->help({"image_generation"}) << std::endl; +} + +std::vector ImageGenerationGraphCLIParser::parse(const std::vector& unmatchedOptions) { + if (!this->options) { + this->createOptions(); + } + std::vector cStrArray; + cStrArray.reserve(unmatchedOptions.size() + 1); + cStrArray.push_back("ovms graph"); + std::transform(unmatchedOptions.begin(), unmatchedOptions.end(), std::back_inserter(cStrArray), [](const std::string& str) { return str.c_str(); }); + const char* const* args = cStrArray.data(); + result = std::make_unique(options->parse(cStrArray.size(), args)); + + return result->unmatched(); +} + +void ImageGenerationGraphCLIParser::prepare(HFSettingsImpl& hfSettings, const std::string& modelName) { + if (nullptr == result) { + // Pull with default arguments - no arguments from user + if (hfSettings.pullHfModelMode) { + hfSettings.imageGenerationGraphSettings = ImageGenerationGraphCLIParser::defaultGraphSettings(); + // Deduce model name + if (modelName != "") { + hfSettings.imageGenerationGraphSettings.modelName = modelName; + } else { + hfSettings.imageGenerationGraphSettings.modelName = hfSettings.sourceModel; + } + return; + } else { + throw std::logic_error("Tried to prepare server and model settings without graph parse result"); + } + } + + // Deduce model name + if (modelName != "") { + hfSettings.imageGenerationGraphSettings.modelName = modelName; + } else { + hfSettings.imageGenerationGraphSettings.modelName = hfSettings.sourceModel; + } + + hfSettings.imageGenerationGraphSettings.targetDevice = result->operator[]("graph_target_device").as(); + hfSettings.imageGenerationGraphSettings.defaultResolution = result->operator[]("default_resolution").as(); +} + +} // namespace ovms diff --git a/src/graph_export/image_generation_graph_cli_parser.hpp b/src/graph_export/image_generation_graph_cli_parser.hpp new file mode 100644 index 0000000000..dae6f17b1d --- /dev/null +++ b/src/graph_export/image_generation_graph_cli_parser.hpp @@ -0,0 +1,45 @@ +//***************************************************************************** +// Copyright 2025 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** +#pragma once + +#include +#include +#include + +#include + +#include "graph_cli_parser.hpp" + +namespace ovms { + +struct HFSettingsImpl; +struct ImageGenerationGraphSettingsImpl; +class Status; + +class ImageGenerationGraphCLIParser : public GraphCLIParser { +public: + ImageGenerationGraphCLIParser() = default; + std::vector parse(const std::vector& unmatchedOptions); + void prepare(HFSettingsImpl& hfSettings, const std::string& modelName); + + void printHelp(); + void createOptions(); + +private: + static ImageGenerationGraphSettingsImpl& defaultGraphSettings(); +}; + +} // namespace ovms From b741d8c3baeb42845e9e402d31792752ef17107b Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Wed, 21 May 2025 12:52:19 +0200 Subject: [PATCH 03/15] save --- src/graph_export/graph_export.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/graph_export/graph_export.cpp b/src/graph_export/graph_export.cpp index 8345d98e53..117f12eb4d 100644 --- a/src/graph_export/graph_export.cpp +++ b/src/graph_export/graph_export.cpp @@ -284,8 +284,11 @@ node: { node_options: { [type.googleapis.com / mediapipe.ImageGenCalculatorOptions]: { models_path: ")" << graphSettings.modelPath << R"(", + target_device: ")" << graphSettings.targetDevice << R"(", + default_resolution: ")" << graphSettings.defaultResolution << R"(" } } +} )"; // TODO: Remaining params From 210775673d35e22880cdadf738ba02b57421c9a5 Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Wed, 21 May 2025 14:24:56 +0200 Subject: [PATCH 04/15] unit test v1 --- src/test/ovmsconfig_test.cpp | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/src/test/ovmsconfig_test.cpp b/src/test/ovmsconfig_test.cpp index bc4395d8c3..7572fe1c66 100644 --- a/src/test/ovmsconfig_test.cpp +++ b/src/test/ovmsconfig_test.cpp @@ -377,6 +377,23 @@ TEST_F(OvmsConfigDeathTest, hfBadRerankGraphParameter) { EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "task: rerank - error parsing options - unmatched arguments : --normalize, true,"); } +TEST_F(OvmsConfigDeathTest, hfBadImageGenerationGraphParameter) { + char* n_argv[] = { + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--unsupported_param", + "true", + }; + int arg_count = 10; + EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "task: image_generation - error parsing options - unmatched arguments : --unsupported_param, true,"); +} + TEST_F(OvmsConfigDeathTest, hfBadEmbeddingsGraphParameter) { char* n_argv[] = { "ovms", @@ -523,6 +540,22 @@ TEST_F(OvmsConfigDeathTest, hfBadRerankGraphNoPull) { EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "error parsing options - unmatched arguments: --normalizes, true,"); } +TEST_F(OvmsConfigDeathTest, hfBadImageGenerationGraphNoPull) { + char* n_argv[] = { + "ovms", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--unsupported_param", + "true", + }; + int arg_count = 9; + EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "error parsing options - unmatched arguments: --unsupported_param, true,"); +} + TEST(OvmsGraphConfigTest, positiveAllChanged) { std::string modelName = "OpenVINO/Phi-3-mini-FastDraft-50M-int8-ov"; std::string downloadPath = "test/repository"; @@ -788,6 +821,64 @@ TEST(OvmsGraphConfigTest, positiveSomeChangedRerank) { ASSERT_EQ(hfSettings.rerankGraphSettings.modelName, servingName); } +TEST(OvmsGraphConfigTest, positiveAllChangedImageGeneration) { + std::string modelName = "OpenVINO/Phi-3-mini-FastDraft-50M-int8-ov"; + std::string downloadPath = "test/repository"; + char* n_argv[] = { + (char*)"ovms", + (char*)"--pull", + (char*)"--source_model", + (char*)modelName.c_str(), + (char*)"--model_repository_path", + (char*)downloadPath.c_str(), + (char*)"--task", + (char*)"image_generation", + (char*)"--graph_target_device", + (char*)"GPU", + (char*)"--default_resolution", + (char*)"1024x1024", + }; + + int arg_count = 12; + ConstructorEnabledConfig config; + config.parse(arg_count, n_argv); + + auto& hfSettings = config.getServerSettings().hfSettings; + ASSERT_EQ(hfSettings.sourceModel, modelName); + ASSERT_EQ(hfSettings.downloadPath, downloadPath); + ASSERT_EQ(hfSettings.pullHfModelMode, true); + ASSERT_EQ(hfSettings.task, ovms::image_generation); + ASSERT_EQ(hfSettings.imageGenerationGraphSettings.targetDevice, "GPU"); + ASSERT_EQ(hfSettings.imageGenerationGraphSettings.defaultResolution, "1024x1024"); +} + +TEST(OvmsGraphConfigTest, positiveDefaultImageGeneration) { + std::string modelName = "OpenVINO/Phi-3-mini-FastDraft-50M-int8-ov"; + std::string downloadPath = "test/repository"; + char* n_argv[] = { + (char*)"ovms", + (char*)"--pull", + (char*)"--source_model", + (char*)modelName.c_str(), + (char*)"--model_repository_path", + (char*)downloadPath.c_str(), + (char*)"--task", + (char*)"image_generation", + }; + + int arg_count = 8; + ConstructorEnabledConfig config; + config.parse(arg_count, n_argv); + + auto& hfSettings = config.getServerSettings().hfSettings; + ASSERT_EQ(hfSettings.sourceModel, modelName); + ASSERT_EQ(hfSettings.downloadPath, downloadPath); + ASSERT_EQ(hfSettings.pullHfModelMode, true); + ASSERT_EQ(hfSettings.task, ovms::image_generation); + ASSERT_EQ(hfSettings.imageGenerationGraphSettings.targetDevice, "CPU"); + ASSERT_EQ(hfSettings.imageGenerationGraphSettings.defaultResolution, "512x512"); +} + TEST(OvmsGraphConfigTest, positiveAllChangedEmbeddings) { std::string modelName = "OpenVINO/Phi-3-mini-FastDraft-50M-int8-ov"; std::string downloadPath = "test/repository"; From 6099e18eda449fd2cb043e23e459ca0bbb861dbe Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Wed, 21 May 2025 15:01:27 +0200 Subject: [PATCH 05/15] more unit tests --- src/test/graph_export_test.cpp | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/test/graph_export_test.cpp b/src/test/graph_export_test.cpp index 1ac94a8985..d5ed9bc74e 100644 --- a/src/test/graph_export_test.cpp +++ b/src/test/graph_export_test.cpp @@ -246,6 +246,27 @@ const std::string expectedEmbeddingsGraphContents = R"( } )"; +const std::string expectedImageGenerationGraphContents = R"( +input_stream: "HTTP_REQUEST_PAYLOAD:input" +output_stream: "HTTP_RESPONSE_PAYLOAD:output" + +node: { + name: "ImageGenExecutor" + calculator: "ImageGenCalculator" + input_stream: "HTTP_REQUEST_PAYLOAD:input" + input_side_packet: "IMAGE_GEN_NODE_RESOURCES:pipes" + output_stream: "HTTP_RESPONSE_PAYLOAD:output" + node_options: { + [type.googleapis.com / mediapipe.ImageGenCalculatorOptions]: { + models_path: "./", + target_device: "GPU", + default_resolution: "800x800" + } + } +} + +)"; + class GraphCreationTest : public TestWithTempDir { protected: void TearDown() { @@ -345,3 +366,17 @@ TEST_F(GraphCreationTest, negativeCreateFileWrongDirectoryPaths) { status = graphExporter->createServableConfig("/does/not/exist", hfSettings); ASSERT_EQ(status, ovms::StatusCode::PATH_INVALID); } + +TEST_F(GraphCreationTest, imageGenerationPositiveDefault) { + ovms::HFSettingsImpl hfSettings; + hfSettings.task = ovms::image_generation; + hfSettings.imageGenerationGraphSettings.targetDevice = "GPU"; + hfSettings.imageGenerationGraphSettings.defaultResolution = "800x800"; + std::string graphPath = ovms::FileSystem::appendSlash(this->directoryPath) + "graph.pbtxt"; + std::unique_ptr graphExporter = std::make_unique(); + auto status = graphExporter->createServableConfig(this->directoryPath, hfSettings); + ASSERT_EQ(status, ovms::StatusCode::OK); + + std::string graphContents = GetFileContents(graphPath); + ASSERT_EQ(expectedImageGenerationGraphContents, graphContents) << graphContents; +} From 8cf57ca4b389000f2ec23bae2a6679ebbec21e91 Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Mon, 26 May 2025 16:54:47 +0200 Subject: [PATCH 06/15] fix compilation issues --- .../image_generation_graph_cli_parser.cpp | 29 +++++++------------ src/test/graph_export_test.cpp | 3 +- src/test/ovmsconfig_test.cpp | 12 ++++---- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/graph_export/image_generation_graph_cli_parser.cpp b/src/graph_export/image_generation_graph_cli_parser.cpp index fe9ba61b5c..57df0b11c6 100644 --- a/src/graph_export/image_generation_graph_cli_parser.cpp +++ b/src/graph_export/image_generation_graph_cli_parser.cpp @@ -72,31 +72,24 @@ std::vector ImageGenerationGraphCLIParser::parse(const std::vector< } void ImageGenerationGraphCLIParser::prepare(HFSettingsImpl& hfSettings, const std::string& modelName) { + ImageGenerationGraphSettingsImpl imageGenerationGraphSettings = ImageGenerationGraphCLIParser::defaultGraphSettings(); + // Deduct model name + if (modelName != "") { + imageGenerationGraphSettings.modelName = modelName; + } else { + imageGenerationGraphSettings.modelName = hfSettings.sourceModel; + } if (nullptr == result) { // Pull with default arguments - no arguments from user - if (hfSettings.pullHfModelMode) { - hfSettings.imageGenerationGraphSettings = ImageGenerationGraphCLIParser::defaultGraphSettings(); - // Deduce model name - if (modelName != "") { - hfSettings.imageGenerationGraphSettings.modelName = modelName; - } else { - hfSettings.imageGenerationGraphSettings.modelName = hfSettings.sourceModel; - } - return; - } else { + if (!hfSettings.pullHfModelMode || !hfSettings.pullHfAndStartModelMode) { throw std::logic_error("Tried to prepare server and model settings without graph parse result"); } - } - - // Deduce model name - if (modelName != "") { - hfSettings.imageGenerationGraphSettings.modelName = modelName; } else { - hfSettings.imageGenerationGraphSettings.modelName = hfSettings.sourceModel; + imageGenerationGraphSettings.targetDevice = result->operator[]("graph_target_device").as(); + imageGenerationGraphSettings.defaultResolution = result->operator[]("default_resolution").as(); } - hfSettings.imageGenerationGraphSettings.targetDevice = result->operator[]("graph_target_device").as(); - hfSettings.imageGenerationGraphSettings.defaultResolution = result->operator[]("default_resolution").as(); + hfSettings.graphSettings = std::move(imageGenerationGraphSettings); } } // namespace ovms diff --git a/src/test/graph_export_test.cpp b/src/test/graph_export_test.cpp index 73f94210c6..14d0e59ca1 100644 --- a/src/test/graph_export_test.cpp +++ b/src/test/graph_export_test.cpp @@ -406,9 +406,10 @@ TEST_F(GraphCreationTest, negativeGraphOptionsNotInitialized) { TEST_F(GraphCreationTest, imageGenerationPositiveDefault) { ovms::HFSettingsImpl hfSettings; hfSettings.task = ovms::image_generation; - ovms::EmbeddingsGraphSettingsImpl imageGenerationGraphSettings; + ovms::ImageGenerationGraphSettingsImpl imageGenerationGraphSettings; imageGenerationGraphSettings.targetDevice = "GPU"; imageGenerationGraphSettings.defaultResolution = "800x800"; + hfSettings.graphSettings = std::move(imageGenerationGraphSettings); std::string graphPath = ovms::FileSystem::appendSlash(this->directoryPath) + "graph.pbtxt"; std::unique_ptr graphExporter = std::make_unique(); auto status = graphExporter->createServableConfig(this->directoryPath, hfSettings); diff --git a/src/test/ovmsconfig_test.cpp b/src/test/ovmsconfig_test.cpp index 1980558eaf..73b407b258 100644 --- a/src/test/ovmsconfig_test.cpp +++ b/src/test/ovmsconfig_test.cpp @@ -570,7 +570,7 @@ TEST_F(OvmsConfigDeathTest, hfBadImageGenerationGraphNoPull) { "true", }; int arg_count = 9; - EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "error parsing options - unmatched arguments: --unsupported_param, true,"); + EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "task: image_generation - error parsing options - unmatched arguments : --unsupported_param, true,"); } TEST(OvmsGraphConfigTest, positiveAllChanged) { @@ -958,8 +958,9 @@ TEST(OvmsGraphConfigTest, positiveAllChangedImageGeneration) { ASSERT_EQ(hfSettings.downloadPath, downloadPath); ASSERT_EQ(hfSettings.pullHfModelMode, true); ASSERT_EQ(hfSettings.task, ovms::image_generation); - ASSERT_EQ(hfSettings.imageGenerationGraphSettings.targetDevice, "GPU"); - ASSERT_EQ(hfSettings.imageGenerationGraphSettings.defaultResolution, "1024x1024"); + ovms::ImageGenerationGraphSettingsImpl imageGenerationGraphSettings = std::get(hfSettings.graphSettings); + ASSERT_EQ(imageGenerationGraphSettings.targetDevice, "GPU"); + ASSERT_EQ(imageGenerationGraphSettings.defaultResolution, "1024x1024"); } TEST(OvmsGraphConfigTest, positiveDefaultImageGeneration) { @@ -985,8 +986,9 @@ TEST(OvmsGraphConfigTest, positiveDefaultImageGeneration) { ASSERT_EQ(hfSettings.downloadPath, downloadPath); ASSERT_EQ(hfSettings.pullHfModelMode, true); ASSERT_EQ(hfSettings.task, ovms::image_generation); - ASSERT_EQ(hfSettings.imageGenerationGraphSettings.targetDevice, "CPU"); - ASSERT_EQ(hfSettings.imageGenerationGraphSettings.defaultResolution, "512x512"); + ovms::ImageGenerationGraphSettingsImpl imageGenerationGraphSettings = std::get(hfSettings.graphSettings); + ASSERT_EQ(imageGenerationGraphSettings.targetDevice, "CPU"); + ASSERT_EQ(imageGenerationGraphSettings.defaultResolution, "512x512"); } TEST(OvmsGraphConfigTest, positiveAllChangedEmbeddings) { From c18c3f9514891c53d81b24598d5a1159c489b4a6 Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Wed, 28 May 2025 15:57:50 +0200 Subject: [PATCH 07/15] add params --- demos/common/export_models/README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/demos/common/export_models/README.md b/demos/common/export_models/README.md index 04744a672e..209d7df67b 100644 --- a/demos/common/export_models/README.md +++ b/demos/common/export_models/README.md @@ -13,16 +13,17 @@ python export_model.py --help ``` Expected Output: ```console -usage: export_model.py [-h] {text_generation,embeddings,rerank} ... +usage: export_model.py [-h] {text_generation,embeddings,rerank,image_generation} ... Export Hugging face models to OVMS models repository including all configuration for deployments positional arguments: - {text_generation,embeddings,rerank} + {text_generation,embeddings,rerank,image_generation} subcommand help text_generation export model for chat and completion endpoints embeddings export model for embeddings endpoint rerank export model for rerank endpoint + image_generation export model for image generation endpoint ``` For every use case subcommand there is adjusted list of parameters: @@ -134,6 +135,15 @@ python export_model.py rerank \ --num_streams 2 ``` +### Image Generation Models +```console +python export_model.py image_generation \ + --source_model dreamlike-art/dreamlike-anime-1.0 \ + --weight-format int8 \ + --config_file_path models/config_all.json \ + --max_resolution 2048x2048 +``` + ## Deployment example After exporting models using the commands above (which use `--model_repository_path models` and `--config_file_path models/config_all.json`), you can deploy them with either with Docker or on Baremetal. From ac8f362312672ef88d75dfc239c32c0a4c591a99 Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Thu, 29 May 2025 11:57:03 +0200 Subject: [PATCH 08/15] save --- src/capi_frontend/server_settings.hpp | 2 +- src/graph_export/image_generation_graph_cli_parser.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/capi_frontend/server_settings.hpp b/src/capi_frontend/server_settings.hpp index 9298259965..99544f8164 100644 --- a/src/capi_frontend/server_settings.hpp +++ b/src/capi_frontend/server_settings.hpp @@ -75,7 +75,7 @@ struct ImageGenerationGraphSettingsImpl { std::string modelName = ""; std::string modelPath = "./"; std::string targetDevice = "CPU"; - std::string maxResolution = ""; // Format WxH, e.g., 1024x1024, TODO: Validate for WxH + std::string maxResolution = ""; // Format WxH, e.g., 1024x1024, TODO: Validate for WxH std::string defaultResolution = ""; // Format WxH, e.g., 1024x1024, TODO: Validate for WxH std::optional maxNumberImagesPerPrompt; std::optional defaultNumInferenceSteps; diff --git a/src/graph_export/image_generation_graph_cli_parser.cpp b/src/graph_export/image_generation_graph_cli_parser.cpp index 65ca25f357..050697d614 100644 --- a/src/graph_export/image_generation_graph_cli_parser.cpp +++ b/src/graph_export/image_generation_graph_cli_parser.cpp @@ -38,8 +38,6 @@ void ImageGenerationGraphCLIParser::createOptions() { this->options = std::make_unique("ovms --pull [PULL OPTIONS ... ]", "--pull --task image generation/edit/inpainting graph options"); options->allow_unrecognised_options(); - std::cout << "AA" << std::endl; - // clang-format off options->add_options("image_generation") ("graph_target_device", // TODO: Remove From 971e389c17fc58af8303226bfe52abad6b95aa2c Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Thu, 29 May 2025 12:47:13 +0200 Subject: [PATCH 09/15] save --- src/capi_frontend/server_settings.hpp | 6 +- src/cli_parser.cpp | 2 +- src/graph_export/BUILD | 1 + src/graph_export/graph_export.cpp | 5 ++ .../image_generation_graph_cli_parser.cpp | 78 ++++++++++++++++--- .../image_generation_graph_cli_parser.hpp | 3 +- src/test/ovmsconfig_test.cpp | 2 +- 7 files changed, 79 insertions(+), 18 deletions(-) diff --git a/src/capi_frontend/server_settings.hpp b/src/capi_frontend/server_settings.hpp index 99544f8164..be536e23a1 100644 --- a/src/capi_frontend/server_settings.hpp +++ b/src/capi_frontend/server_settings.hpp @@ -75,12 +75,12 @@ struct ImageGenerationGraphSettingsImpl { std::string modelName = ""; std::string modelPath = "./"; std::string targetDevice = "CPU"; - std::string maxResolution = ""; // Format WxH, e.g., 1024x1024, TODO: Validate for WxH - std::string defaultResolution = ""; // Format WxH, e.g., 1024x1024, TODO: Validate for WxH + std::string maxResolution = ""; + std::string defaultResolution = ""; std::optional maxNumberImagesPerPrompt; std::optional defaultNumInferenceSteps; std::optional maxNumInferenceSteps; - std::optional numStreams; // ? + std::string pluginConfig; }; struct HFSettingsImpl { diff --git a/src/cli_parser.cpp b/src/cli_parser.cpp index 877ce1e161..9bdc0e1e95 100644 --- a/src/cli_parser.cpp +++ b/src/cli_parser.cpp @@ -509,7 +509,7 @@ void CLIParser::prepareGraph(ServerSettingsImpl& serverSettings, HFSettingsImpl& break; } case IMAGE_GENERATION_GRAPH: { - std::get(this->graphOptionsParser).prepare(serverSettings.serverMode, hfSettings, modelName); + std::get(this->graphOptionsParser).prepare(serverSettings, hfSettings, modelName); break; } case UNKNOWN_GRAPH: { diff --git a/src/graph_export/BUILD b/src/graph_export/BUILD index a27329d536..7b9390f821 100644 --- a/src/graph_export/BUILD +++ b/src/graph_export/BUILD @@ -74,6 +74,7 @@ cc_library( "@ovms//src:libovms_server_settings", "@ovms//src:ovms_exit_codes", "@com_github_jarro2783_cxxopts//:cxxopts", + "@com_github_tencent_rapidjson//:rapidjson", ], visibility = ["//visibility:public"], ) diff --git a/src/graph_export/graph_export.cpp b/src/graph_export/graph_export.cpp index f06ae62e3f..684703cc42 100644 --- a/src/graph_export/graph_export.cpp +++ b/src/graph_export/graph_export.cpp @@ -272,6 +272,11 @@ node: { models_path: ")" << graphSettings.modelPath << R"(", target_device: ")" << graphSettings.targetDevice << R"(")"; + if (graphSettings.pluginConfig.size()) { + oss << R"( + plugin_config: ')" << graphSettings.pluginConfig << R"(')"; + } + if (graphSettings.maxResolution.size()) { oss << R"( max_resolution: ")" << graphSettings.maxResolution << R"(")"; diff --git a/src/graph_export/image_generation_graph_cli_parser.cpp b/src/graph_export/image_generation_graph_cli_parser.cpp index 050697d614..a266e8fda7 100644 --- a/src/graph_export/image_generation_graph_cli_parser.cpp +++ b/src/graph_export/image_generation_graph_cli_parser.cpp @@ -18,17 +18,31 @@ #include #include #include +#include #include #include #include #include +#pragma warning(push) +#pragma warning(disable : 6313) +#include +#include +#include +#include +#pragma warning(pop) + #include "../capi_frontend/server_settings.hpp" #include "../ovms_exit_codes.hpp" #include "../status.hpp" namespace ovms { +static bool isValidResolution(const std::string& resolution) { + static const std::regex pattern(R"(\d+x\d+)"); + return std::regex_match(resolution, pattern); +} + ImageGenerationGraphSettingsImpl& ImageGenerationGraphCLIParser::defaultGraphSettings() { static ImageGenerationGraphSettingsImpl instance; return instance; @@ -40,16 +54,12 @@ void ImageGenerationGraphCLIParser::createOptions() { // clang-format off options->add_options("image_generation") - ("graph_target_device", // TODO: Remove - "CPU, GPU, NPU or HETERO, default is CPU.", - cxxopts::value()->default_value("CPU"), - "GRAPH_TARGET_DEVICE") ("max_resolution", "Max allowed resolution in a format of WxH; W=width H=height. If not specified, inherited from model.", cxxopts::value(), "MAX_RESOLUTION") ("default_resolution", - "Default resolution when not specified by client. If not specified, inherited from model.", + "Default resolution when not specified by client in a format of WxH; W=width H=height. If not specified, inherited from model.", cxxopts::value(), "DEFAULT_RESOLUTION") ("max_number_images_per_prompt", @@ -63,7 +73,11 @@ void ImageGenerationGraphCLIParser::createOptions() { ("max_num_inference_steps", "Max allowed number of inference steps client is allowed to request for a given prompt.", cxxopts::value(), - "MAX_NUM_INFERENCE_STEPS"); + "MAX_NUM_INFERENCE_STEPS") + ("num_streams", + "The number of parallel execution streams to use for the image generation models. Use at least 2 on 2 socket CPU systems.", + cxxopts::value(), + "NUM_STREAMS"); } void ImageGenerationGraphCLIParser::printHelp() { @@ -87,8 +101,9 @@ std::vector ImageGenerationGraphCLIParser::parse(const std::vector< return result->unmatched(); } -void ImageGenerationGraphCLIParser::prepare(OvmsServerMode serverMode, HFSettingsImpl& hfSettings, const std::string& modelName) { +void ImageGenerationGraphCLIParser::prepare(ServerSettingsImpl& serverSettings, HFSettingsImpl& hfSettings, const std::string& modelName) { ImageGenerationGraphSettingsImpl imageGenerationGraphSettings = ImageGenerationGraphCLIParser::defaultGraphSettings(); + imageGenerationGraphSettings.targetDevice = hfSettings.targetDevice; // Deduct model name if (modelName != "") { imageGenerationGraphSettings.modelName = modelName; @@ -97,19 +112,58 @@ void ImageGenerationGraphCLIParser::prepare(OvmsServerMode serverMode, HFSetting } if (nullptr == result) { // Pull with default arguments - no arguments from user - if (serverMode != HF_PULL_MODE && serverMode != HF_PULL_AND_START_MODE) { + if (serverSettings.serverMode != HF_PULL_MODE && serverSettings.serverMode != HF_PULL_AND_START_MODE) { throw std::logic_error("Tried to prepare server and model settings without graph parse result"); } } else { - imageGenerationGraphSettings.targetDevice = result->operator[]("graph_target_device").as(); imageGenerationGraphSettings.maxResolution = result->count("max_resolution") ? result->operator[]("max_resolution").as() : ""; + if (!imageGenerationGraphSettings.maxResolution.empty() && !isValidResolution(imageGenerationGraphSettings.maxResolution)) { + throw std::invalid_argument("Invalid max_resolution format. Expected WxH, e.g., 1024x1024"); + } imageGenerationGraphSettings.defaultResolution = result->count("default_resolution") ? result->operator[]("default_resolution").as() : ""; - if (result->count("max_number_images_per_prompt")) // TODO: Validate zeros? + if (!imageGenerationGraphSettings.defaultResolution.empty() && !isValidResolution(imageGenerationGraphSettings.defaultResolution)) { + throw std::invalid_argument("Invalid default_resolution format. Expected WxH, e.g., 1024x1024"); + } + if (result->count("max_number_images_per_prompt")) { imageGenerationGraphSettings.maxNumberImagesPerPrompt = result->operator[]("max_number_images_per_prompt").as(); - if (result->count("default_num_inference_steps")) + if (imageGenerationGraphSettings.maxNumberImagesPerPrompt == 0) { + throw std::invalid_argument("max_number_images_per_prompt must be greater than 0"); + } + } + if (result->count("default_num_inference_steps")) { imageGenerationGraphSettings.defaultNumInferenceSteps = result->operator[]("default_num_inference_steps").as(); - if (result->count("max_num_inference_steps")) + if (imageGenerationGraphSettings.defaultNumInferenceSteps == 0) { + throw std::invalid_argument("default_num_inference_steps must be greater than 0"); + } + } + if (result->count("max_num_inference_steps")) { imageGenerationGraphSettings.maxNumInferenceSteps = result->operator[]("max_num_inference_steps").as(); + if (imageGenerationGraphSettings.maxNumInferenceSteps == 0) { + throw std::invalid_argument("max_num_inference_steps must be greater than 0"); + } + } + + if (result->count("num_streams") || serverSettings.cacheDir != "") { + rapidjson::Document pluginConfigDoc; + pluginConfigDoc.SetObject(); + rapidjson::Document::AllocatorType& allocator = pluginConfigDoc.GetAllocator(); + if (result->count("num_streams")) { + uint32_t numStreams = result->operator[]("num_streams").as(); + if (numStreams == 0) { + throw std::invalid_argument("num_streams must be greater than 0"); + } + pluginConfigDoc.AddMember("NUM_STREAMS", numStreams, allocator); + } + + if (!serverSettings.cacheDir.empty()) { + pluginConfigDoc.AddMember("CACHE_DIR", rapidjson::Value(serverSettings.cacheDir.c_str(), allocator), allocator); + } + + rapidjson::StringBuffer buffer; + rapidjson::Writer writer(buffer); + pluginConfigDoc.Accept(writer); + imageGenerationGraphSettings.pluginConfig = buffer.GetString(); + } } hfSettings.graphSettings = std::move(imageGenerationGraphSettings); diff --git a/src/graph_export/image_generation_graph_cli_parser.hpp b/src/graph_export/image_generation_graph_cli_parser.hpp index c9f4c5e60f..2207b39f90 100644 --- a/src/graph_export/image_generation_graph_cli_parser.hpp +++ b/src/graph_export/image_generation_graph_cli_parser.hpp @@ -27,13 +27,14 @@ namespace ovms { struct HFSettingsImpl; struct ImageGenerationGraphSettingsImpl; +struct ServerSettingsImpl; class Status; class ImageGenerationGraphCLIParser : public GraphCLIParser { public: ImageGenerationGraphCLIParser() = default; std::vector parse(const std::vector& unmatchedOptions); - void prepare(OvmsServerMode serverMode, HFSettingsImpl& hfSettings, const std::string& modelName); + void prepare(ServerSettingsImpl& serverMode, HFSettingsImpl& hfSettings, const std::string& modelName); void printHelp(); void createOptions(); diff --git a/src/test/ovmsconfig_test.cpp b/src/test/ovmsconfig_test.cpp index e9056409e8..4f4658e59f 100644 --- a/src/test/ovmsconfig_test.cpp +++ b/src/test/ovmsconfig_test.cpp @@ -994,7 +994,7 @@ TEST(OvmsGraphConfigTest, positiveAllChangedImageGeneration) { (char*)downloadPath.c_str(), (char*)"--task", (char*)"image_generation", - (char*)"--graph_target_device", + (char*)"target_device", (char*)"GPU", (char*)"--default_resolution", (char*)"1024x1024", From 3ec7803ed48a121ea0bcebdbfe5efefc4cae61b8 Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Thu, 29 May 2025 12:54:11 +0200 Subject: [PATCH 10/15] save --- src/graph_export/graph_export.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graph_export/graph_export.cpp b/src/graph_export/graph_export.cpp index 684703cc42..12adb50068 100644 --- a/src/graph_export/graph_export.cpp +++ b/src/graph_export/graph_export.cpp @@ -269,7 +269,7 @@ node: { output_stream: "HTTP_RESPONSE_PAYLOAD:output" node_options: { [type.googleapis.com / mediapipe.ImageGenCalculatorOptions]: { - models_path: ")" << graphSettings.modelPath << R"(", + models_path: ")" << graphSettings.modelPath << R"(" target_device: ")" << graphSettings.targetDevice << R"(")"; if (graphSettings.pluginConfig.size()) { From 7e9db6eb0da2fecb2226227c0648d3bcc4357a5e Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Thu, 29 May 2025 13:37:52 +0200 Subject: [PATCH 11/15] save --- src/test/graph_export_test.cpp | 11 +++++++--- src/test/ovmsconfig_test.cpp | 37 ++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/test/graph_export_test.cpp b/src/test/graph_export_test.cpp index 0abe463220..efa11b406b 100644 --- a/src/test/graph_export_test.cpp +++ b/src/test/graph_export_test.cpp @@ -258,9 +258,14 @@ node: { output_stream: "HTTP_RESPONSE_PAYLOAD:output" node_options: { [type.googleapis.com / mediapipe.ImageGenCalculatorOptions]: { - models_path: "./", - target_device: "GPU", - default_resolution: "800x800" + models_path: "./" + target_device: "GPU" + plugin_config: '{"NUM_STREAMS":14,"CACHE_DIR":"/cache"}' + max_resolution: "3000x4000" + default_resolution: "300x400" + max_number_images_per_prompt: 7 + default_num_inference_steps: 2 + max_num_inference_steps: 3 } } } diff --git a/src/test/ovmsconfig_test.cpp b/src/test/ovmsconfig_test.cpp index 4f4658e59f..a6c6122fb0 100644 --- a/src/test/ovmsconfig_test.cpp +++ b/src/test/ovmsconfig_test.cpp @@ -994,13 +994,25 @@ TEST(OvmsGraphConfigTest, positiveAllChangedImageGeneration) { (char*)downloadPath.c_str(), (char*)"--task", (char*)"image_generation", - (char*)"target_device", + (char*)"--cache_dir", + (char*)"/cache", + (char*)"--target_device", (char*)"GPU", + (char*)"--num_streams", + (char*)"14", + (char*)"--max_resolution", + (char*)"3000x4000", (char*)"--default_resolution", - (char*)"1024x1024", + (char*)"300x400", + (char*)"--max_number_images_per_prompt", + (char*)"7", + (char*)"--default_num_inference_steps", + (char*)"2", + (char*)"--max_num_inference_steps", + (char*)"3", }; - int arg_count = 12; + int arg_count = 24; ConstructorEnabledConfig config; config.parse(arg_count, n_argv); @@ -1011,7 +1023,15 @@ TEST(OvmsGraphConfigTest, positiveAllChangedImageGeneration) { ASSERT_EQ(hfSettings.task, ovms::IMAGE_GENERATION_GRAPH); ovms::ImageGenerationGraphSettingsImpl imageGenerationGraphSettings = std::get(hfSettings.graphSettings); ASSERT_EQ(imageGenerationGraphSettings.targetDevice, "GPU"); - ASSERT_EQ(imageGenerationGraphSettings.defaultResolution, "1024x1024"); + ASSERT_EQ(imageGenerationGraphSettings.maxResolution, "3000x4000"); + ASSERT_EQ(imageGenerationGraphSettings.defaultResolution, "300x400"); + ASSERT_TRUE(imageGenerationGraphSettings.maxNumberImagesPerPrompt.has_value()); + ASSERT_EQ(imageGenerationGraphSettings.maxNumberImagesPerPrompt.value(), 7); + ASSERT_TRUE(imageGenerationGraphSettings.defaultNumInferenceSteps.has_value()); + ASSERT_EQ(imageGenerationGraphSettings.defaultNumInferenceSteps.value(), 2); + ASSERT_TRUE(imageGenerationGraphSettings.maxNumInferenceSteps.has_value()); + ASSERT_EQ(imageGenerationGraphSettings.maxNumInferenceSteps.value(), 3); + ASSERT_EQ(imageGenerationGraphSettings.pluginConfig, "{\"NUM_STREAMS\":14,\"CACHE_DIR\":\"/cache\"}"); } TEST(OvmsGraphConfigTest, positiveDefaultImageGeneration) { @@ -1038,8 +1058,13 @@ TEST(OvmsGraphConfigTest, positiveDefaultImageGeneration) { ASSERT_EQ(config.getServerSettings().serverMode, ovms::HF_PULL_MODE); ASSERT_EQ(hfSettings.task, ovms::IMAGE_GENERATION_GRAPH); ovms::ImageGenerationGraphSettingsImpl imageGenerationGraphSettings = std::get(hfSettings.graphSettings); - ASSERT_EQ(imageGenerationGraphSettings.targetDevice, "CPU"); - ASSERT_EQ(imageGenerationGraphSettings.defaultResolution, "512x512"); + ASSERT_EQ(imageGenerationGraphSettings.targetDevice, "GPU"); + ASSERT_TRUE(imageGenerationGraphSettings.maxResolution.empty()); + ASSERT_TRUE(imageGenerationGraphSettings.defaultResolution.empty()); + ASSERT_FALSE(imageGenerationGraphSettings.maxNumberImagesPerPrompt.has_value()); + ASSERT_FALSE(imageGenerationGraphSettings.defaultNumInferenceSteps.has_value()); + ASSERT_FALSE(imageGenerationGraphSettings.maxNumInferenceSteps.has_value()); + ASSERT_TRUE(imageGenerationGraphSettings.pluginConfig.empty()); } TEST(OvmsGraphConfigTest, positiveAllChangedEmbeddings) { From bee95e7f99ec244012783573472be936605b5037 Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Thu, 29 May 2025 13:59:14 +0200 Subject: [PATCH 12/15] save --- src/test/ovmsconfig_test.cpp | 111 +++++++++++++++++++++++++++++++---- 1 file changed, 99 insertions(+), 12 deletions(-) diff --git a/src/test/ovmsconfig_test.cpp b/src/test/ovmsconfig_test.cpp index a6c6122fb0..6583795e48 100644 --- a/src/test/ovmsconfig_test.cpp +++ b/src/test/ovmsconfig_test.cpp @@ -380,21 +380,108 @@ TEST_F(OvmsConfigDeathTest, hfBadRerankGraphParameter) { EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "task: rerank - error parsing options - unmatched arguments : --normalize, true,"); } -TEST_F(OvmsConfigDeathTest, hfBadImageGenerationGraphParameter) { +TEST_F(OvmsConfigDeathTest, notSupportedImageGenerationGraphParameter) { char* n_argv[] = { - "ovms", - "--pull", - "--source_model", - "some/model", - "--model_repository_path", - "/some/path", - "--task", - "image_generation", - "--unsupported_param", - "true", + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--unsupported_param", "true", }; int arg_count = 10; - EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "task: image_generation - error parsing options - unmatched arguments : --unsupported_param, true,"); + EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), + "task: image_generation - error parsing options - unmatched arguments : --unsupported_param, true,"); +} + +TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_NumStreamsNotAnInt) { + char* n_argv[] = { + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--num_streams", "hello", + }; + int arg_count = 10; + EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), + "error parsing options: Argument ‘hello’ failed to parse"); +} + +TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_NumStreamsZero) { + char* n_argv[] = { + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--num_streams", "0", + }; + int arg_count = 10; + EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); +} + +TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxResolutionWrongFormat) { + char* n_argv[] = { + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--max_resolution", "hello", + }; + int arg_count = 10; + EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); +} + +TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultResolutionWrongFormat) { + char* n_argv[] = { + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--default_resolution", "hello", + }; + int arg_count = 10; + EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); +} + +TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumberImagesPerPromptNotAnInt) { + char* n_argv[] = { + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--max_number_images_per_prompt", "hello", + }; + int arg_count = 10; + EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), + "error parsing options: Argument ‘hello’ failed to parse"); +} + +TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumberImagesPerPromptZero) { + char* n_argv[] = { + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--max_number_images_per_prompt", "0", + }; + int arg_count = 10; + EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); +} + +TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultNumInferenceStepsNotAnInt) { + char* n_argv[] = { + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--default_num_inference_steps", "hello", + }; + int arg_count = 10; + EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), + "error parsing options: Argument ‘hello’ failed to parse"); +} + +TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultNumInferenceStepsZero) { + char* n_argv[] = { + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--default_num_inference_steps", "0", + }; + int arg_count = 10; + EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); +} + +TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumInferenceStepsNotAnInt) { + char* n_argv[] = { + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--max_num_inference_steps", "hello", + }; + int arg_count = 10; + EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), + "error parsing options: Argument ‘hello’ failed to parse"); +} + +TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumInferenceStepsZero) { + char* n_argv[] = { + "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", + "--task", "image_generation", "--max_num_inference_steps", "0", + }; + int arg_count = 10; + EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); } TEST_F(OvmsConfigDeathTest, hfBadEmbeddingsGraphParameter) { From c5bc5293d4815146f54fd429f82469f72bc2dc35 Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Thu, 29 May 2025 14:13:07 +0200 Subject: [PATCH 13/15] save --- src/test/graph_export_test.cpp | 34 +++++++++ src/test/ovmsconfig_test.cpp | 134 +++++++++++++++++++++++++++------ 2 files changed, 145 insertions(+), 23 deletions(-) diff --git a/src/test/graph_export_test.cpp b/src/test/graph_export_test.cpp index fd83803cb5..65d8a3f384 100644 --- a/src/test/graph_export_test.cpp +++ b/src/test/graph_export_test.cpp @@ -272,6 +272,26 @@ node: { )"; +const std::string expectedImageGenerationGraphContentsDefault = R"( +input_stream: "HTTP_REQUEST_PAYLOAD:input" +output_stream: "HTTP_RESPONSE_PAYLOAD:output" + +node: { + name: "ImageGenExecutor" + calculator: "ImageGenCalculator" + input_stream: "HTTP_REQUEST_PAYLOAD:input" + input_side_packet: "IMAGE_GEN_NODE_RESOURCES:pipes" + output_stream: "HTTP_RESPONSE_PAYLOAD:output" + node_options: { + [type.googleapis.com / mediapipe.ImageGenCalculatorOptions]: { + models_path: "./" + target_device: "CPU" + } + } +} + +)"; + class GraphCreationTest : public TestWithTempDir { protected: void TearDown() { @@ -409,6 +429,20 @@ TEST_F(GraphCreationTest, negativeGraphOptionsNotInitialized) { } TEST_F(GraphCreationTest, imageGenerationPositiveDefault) { + ovms::HFSettingsImpl hfSettings; + hfSettings.task = ovms::IMAGE_GENERATION_GRAPH; + ovms::ImageGenerationGraphSettingsImpl imageGenerationGraphSettings; + hfSettings.graphSettings = std::move(imageGenerationGraphSettings); + std::string graphPath = ovms::FileSystem::appendSlash(this->directoryPath) + "graph.pbtxt"; + std::unique_ptr graphExporter = std::make_unique(); + auto status = graphExporter->createServableConfig(this->directoryPath, hfSettings); + ASSERT_EQ(status, ovms::StatusCode::OK); + + std::string graphContents = GetFileContents(graphPath); + ASSERT_EQ(expectedImageGenerationGraphContentsDefault, graphContents) << graphContents; +} + +TEST_F(GraphCreationTest, imageGenerationPositiveFull) { ovms::HFSettingsImpl hfSettings; hfSettings.task = ovms::IMAGE_GENERATION_GRAPH; ovms::ImageGenerationGraphSettingsImpl imageGenerationGraphSettings; diff --git a/src/test/ovmsconfig_test.cpp b/src/test/ovmsconfig_test.cpp index 6583795e48..9bbd7d5c67 100644 --- a/src/test/ovmsconfig_test.cpp +++ b/src/test/ovmsconfig_test.cpp @@ -382,8 +382,16 @@ TEST_F(OvmsConfigDeathTest, hfBadRerankGraphParameter) { TEST_F(OvmsConfigDeathTest, notSupportedImageGenerationGraphParameter) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--unsupported_param", "true", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--unsupported_param", + "true", }; int arg_count = 10; EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), @@ -392,8 +400,16 @@ TEST_F(OvmsConfigDeathTest, notSupportedImageGenerationGraphParameter) { TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_NumStreamsNotAnInt) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--num_streams", "hello", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--num_streams", + "hello", }; int arg_count = 10; EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), @@ -402,8 +418,16 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_NumStreamsNotAnInt) { TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_NumStreamsZero) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--num_streams", "0", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--num_streams", + "0", }; int arg_count = 10; EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); @@ -411,8 +435,16 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_NumStreamsZero) { TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxResolutionWrongFormat) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--max_resolution", "hello", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--max_resolution", + "hello", }; int arg_count = 10; EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); @@ -420,8 +452,16 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxResolutionWrongForma TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultResolutionWrongFormat) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--default_resolution", "hello", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--default_resolution", + "hello", }; int arg_count = 10; EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); @@ -429,8 +469,16 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultResolutionWrongF TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumberImagesPerPromptNotAnInt) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--max_number_images_per_prompt", "hello", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--max_number_images_per_prompt", + "hello", }; int arg_count = 10; EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), @@ -439,8 +487,16 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumberImagesPerPromp TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumberImagesPerPromptZero) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--max_number_images_per_prompt", "0", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--max_number_images_per_prompt", + "0", }; int arg_count = 10; EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); @@ -448,8 +504,16 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumberImagesPerPromp TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultNumInferenceStepsNotAnInt) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--default_num_inference_steps", "hello", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--default_num_inference_steps", + "hello", }; int arg_count = 10; EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), @@ -458,8 +522,16 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultNumInferenceStep TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultNumInferenceStepsZero) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--default_num_inference_steps", "0", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--default_num_inference_steps", + "0", }; int arg_count = 10; EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); @@ -467,8 +539,16 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultNumInferenceStep TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumInferenceStepsNotAnInt) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--max_num_inference_steps", "hello", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--max_num_inference_steps", + "hello", }; int arg_count = 10; EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), @@ -477,8 +557,16 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumInferenceStepsNot TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumInferenceStepsZero) { char* n_argv[] = { - "ovms", "--pull", "--source_model", "some/model", "--model_repository_path", "/some/path", - "--task", "image_generation", "--max_num_inference_steps", "0", + "ovms", + "--pull", + "--source_model", + "some/model", + "--model_repository_path", + "/some/path", + "--task", + "image_generation", + "--max_num_inference_steps", + "0", }; int arg_count = 10; EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); @@ -1145,7 +1233,7 @@ TEST(OvmsGraphConfigTest, positiveDefaultImageGeneration) { ASSERT_EQ(config.getServerSettings().serverMode, ovms::HF_PULL_MODE); ASSERT_EQ(hfSettings.task, ovms::IMAGE_GENERATION_GRAPH); ovms::ImageGenerationGraphSettingsImpl imageGenerationGraphSettings = std::get(hfSettings.graphSettings); - ASSERT_EQ(imageGenerationGraphSettings.targetDevice, "GPU"); + ASSERT_EQ(imageGenerationGraphSettings.targetDevice, "CPU"); ASSERT_TRUE(imageGenerationGraphSettings.maxResolution.empty()); ASSERT_TRUE(imageGenerationGraphSettings.defaultResolution.empty()); ASSERT_FALSE(imageGenerationGraphSettings.maxNumberImagesPerPrompt.has_value()); From a4884b64a675852e2da740afbca1123de47afc6e Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Thu, 29 May 2025 15:47:19 +0200 Subject: [PATCH 14/15] Remove NotAnInt unit tests, since those are already covered in cxxopts --- src/test/ovmsconfig_test.cpp | 72 ------------------------------------ 1 file changed, 72 deletions(-) diff --git a/src/test/ovmsconfig_test.cpp b/src/test/ovmsconfig_test.cpp index 9bbd7d5c67..fb8c77c59e 100644 --- a/src/test/ovmsconfig_test.cpp +++ b/src/test/ovmsconfig_test.cpp @@ -398,24 +398,6 @@ TEST_F(OvmsConfigDeathTest, notSupportedImageGenerationGraphParameter) { "task: image_generation - error parsing options - unmatched arguments : --unsupported_param, true,"); } -TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_NumStreamsNotAnInt) { - char* n_argv[] = { - "ovms", - "--pull", - "--source_model", - "some/model", - "--model_repository_path", - "/some/path", - "--task", - "image_generation", - "--num_streams", - "hello", - }; - int arg_count = 10; - EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), - "error parsing options: Argument ‘hello’ failed to parse"); -} - TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_NumStreamsZero) { char* n_argv[] = { "ovms", @@ -467,24 +449,6 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultResolutionWrongF EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); } -TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumberImagesPerPromptNotAnInt) { - char* n_argv[] = { - "ovms", - "--pull", - "--source_model", - "some/model", - "--model_repository_path", - "/some/path", - "--task", - "image_generation", - "--max_number_images_per_prompt", - "hello", - }; - int arg_count = 10; - EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), - "error parsing options: Argument ‘hello’ failed to parse"); -} - TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumberImagesPerPromptZero) { char* n_argv[] = { "ovms", @@ -502,24 +466,6 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumberImagesPerPromp EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); } -TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultNumInferenceStepsNotAnInt) { - char* n_argv[] = { - "ovms", - "--pull", - "--source_model", - "some/model", - "--model_repository_path", - "/some/path", - "--task", - "image_generation", - "--default_num_inference_steps", - "hello", - }; - int arg_count = 10; - EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), - "error parsing options: Argument ‘hello’ failed to parse"); -} - TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultNumInferenceStepsZero) { char* n_argv[] = { "ovms", @@ -537,24 +483,6 @@ TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_DefaultNumInferenceStep EXPECT_THROW(ovms::Config::instance().parse(arg_count, n_argv), std::invalid_argument); } -TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumInferenceStepsNotAnInt) { - char* n_argv[] = { - "ovms", - "--pull", - "--source_model", - "some/model", - "--model_repository_path", - "/some/path", - "--task", - "image_generation", - "--max_num_inference_steps", - "hello", - }; - int arg_count = 10; - EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), - "error parsing options: Argument ‘hello’ failed to parse"); -} - TEST_F(OvmsConfigDeathTest, negativeImageGenerationGraph_MaxNumInferenceStepsZero) { char* n_argv[] = { "ovms", From 7c1904becf85ff773200895351907b1d0bf9b428 Mon Sep 17 00:00:00 2001 From: Damian Kalinowski Date: Thu, 29 May 2025 15:48:40 +0200 Subject: [PATCH 15/15] remove comment --- src/graph_export/graph_export.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/graph_export/graph_export.cpp b/src/graph_export/graph_export.cpp index 12adb50068..4f5842b44c 100644 --- a/src/graph_export/graph_export.cpp +++ b/src/graph_export/graph_export.cpp @@ -308,8 +308,6 @@ node: { } )"; - // TODO: Remaining params - // clang-format on std::string fullPath = FileSystem::joinPath({directoryPath, "graph.pbtxt"}); return FileSystem::createFileOverwrite(fullPath, oss.str());