-
Notifications
You must be signed in to change notification settings - Fork 217
ImageGen models support for --pull #3302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5040074
pull image gen
dkalinowski d7ef06e
save
dkalinowski b741d8c
save
dkalinowski 2107756
unit test v1
dkalinowski 6099e18
more unit tests
dkalinowski 86dd78d
Merge remote-tracking branch 'origin/main' into pull-image-gen
dkalinowski 8cf57ca
fix compilation issues
dkalinowski 981c117
Merge remote-tracking branch 'origin/main' into pull-image-gen
dkalinowski 4a6e271
Merge remote-tracking branch 'origin/main' into pull-image-gen
dkalinowski b8befc5
Merge remote-tracking branch 'origin/main' into pull-image-gen
dkalinowski c18c3f9
add params
dkalinowski 1baa83b
Merge remote-tracking branch 'origin/main' into pull-image-gen
dkalinowski ac8f362
save
dkalinowski 971e389
save
dkalinowski 3ec7803
save
dkalinowski 7e9db6e
save
dkalinowski f89764b
Merge remote-tracking branch 'origin/main' into pull-image-gen
dkalinowski bee95e7
save
dkalinowski c5bc529
save
dkalinowski a4884b6
Remove NotAnInt unit tests, since those are already covered in cxxopts
dkalinowski 7c1904b
remove comment
dkalinowski c5c42a4
Merge remote-tracking branch 'origin/main' into pull-image-gen
dkalinowski 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
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
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
//***************************************************************************** | ||
// 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 <algorithm> | ||
#include <iostream> | ||
#include <optional> | ||
#include <stdexcept> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#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<cxxopts::Options>("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<std::string>()->default_value("CPU"), | ||
"GRAPH_TARGET_DEVICE") | ||
("default_resolution", | ||
"Default width and height of requested image in case user does not provide it.", | ||
cxxopts::value<std::string>()->default_value("512x512"), | ||
"DEFAULT_RESOLUTION"); | ||
} | ||
|
||
void ImageGenerationGraphCLIParser::printHelp() { | ||
if (!this->options) { | ||
this->createOptions(); | ||
} | ||
std::cout << options->help({"image_generation"}) << std::endl; | ||
} | ||
|
||
std::vector<std::string> ImageGenerationGraphCLIParser::parse(const std::vector<std::string>& unmatchedOptions) { | ||
if (!this->options) { | ||
this->createOptions(); | ||
} | ||
std::vector<const char*> 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<cxxopts::ParseResult>(options->parse(cStrArray.size(), args)); | ||
|
||
return result->unmatched(); | ||
} | ||
|
||
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.pullHfAndStartModelMode) { | ||
throw std::logic_error("Tried to prepare server and model settings without graph parse result"); | ||
} | ||
} else { | ||
imageGenerationGraphSettings.targetDevice = result->operator[]("graph_target_device").as<std::string>(); | ||
imageGenerationGraphSettings.defaultResolution = result->operator[]("default_resolution").as<std::string>(); | ||
} | ||
|
||
hfSettings.graphSettings = std::move(imageGenerationGraphSettings); | ||
} | ||
|
||
} // namespace ovms |
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,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 <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <cxxopts.hpp> | ||
|
||
#include "graph_cli_parser.hpp" | ||
|
||
namespace ovms { | ||
|
||
struct HFSettingsImpl; | ||
struct ImageGenerationGraphSettingsImpl; | ||
class Status; | ||
|
||
class ImageGenerationGraphCLIParser : public GraphCLIParser { | ||
public: | ||
ImageGenerationGraphCLIParser() = default; | ||
std::vector<std::string> parse(const std::vector<std::string>& unmatchedOptions); | ||
void prepare(HFSettingsImpl& hfSettings, const std::string& modelName); | ||
|
||
void printHelp(); | ||
void createOptions(); | ||
|
||
private: | ||
static ImageGenerationGraphSettingsImpl& defaultGraphSettings(); | ||
}; | ||
|
||
} // namespace ovms |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed