Skip to content

Commit

Permalink
Added tokenizer path to text2image (openvinotoolkit#1057)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov authored Oct 24, 2024
1 parent 5e37c60 commit 275729c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/python/py_text2image_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "openvino/genai/text2image/pipeline.hpp"

#include "tokenizers_path.hpp"
#include "py_utils.hpp"

namespace py = pybind11;
Expand All @@ -21,6 +22,7 @@ void init_clip_text_model(py::module_& m) {
.def(py::init([](
const std::filesystem::path& root_dir
) {
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
return std::make_unique<ov::genai::CLIPTextModel>(root_dir);
}),
py::arg("root_dir"), "Model root directory",
Expand All @@ -33,6 +35,7 @@ void init_clip_text_model(py::module_& m) {
const std::string& device,
const py::kwargs& kwargs
) {
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
return std::make_unique<ov::genai::CLIPTextModel>(root_dir, device, pyutils::kwargs_to_any_map(kwargs));
}),
py::arg("root_dir"), "Model root directory",
Expand Down Expand Up @@ -229,6 +232,7 @@ void init_clip_text_model_with_projection(py::module_& m) {
.def(py::init([](
const std::filesystem::path& root_dir
) {
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
return std::make_unique<ov::genai::CLIPTextModelWithProjection>(root_dir);
}),
py::arg("root_dir"), "Model root directory",
Expand All @@ -241,6 +245,7 @@ void init_clip_text_model_with_projection(py::module_& m) {
const std::string& device,
const py::kwargs& kwargs
) {
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
return std::make_unique<ov::genai::CLIPTextModelWithProjection>(root_dir, device, pyutils::kwargs_to_any_map(kwargs));
}),
py::arg("root_dir"), "Model root directory",
Expand Down
4 changes: 4 additions & 0 deletions src/python/py_text2image_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <pybind11/functional.h>

#include "openvino/genai/text2image/pipeline.hpp"

#include "tokenizers_path.hpp"
#include "py_utils.hpp"

namespace py = pybind11;
Expand Down Expand Up @@ -183,6 +185,7 @@ void init_text2image_pipeline(py::module_& m) {
.def(py::init([](
const std::filesystem::path& models_path
) {
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
return std::make_unique<ov::genai::Text2ImagePipeline>(models_path);
}),
py::arg("models_path"), "folder with exported model files.",
Expand All @@ -196,6 +199,7 @@ void init_text2image_pipeline(py::module_& m) {
const std::string& device,
const py::kwargs& kwargs
) {
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
return std::make_unique<ov::genai::Text2ImagePipeline>(models_path, device, text2image_kwargs_to_any_map(kwargs, true));
}),
py::arg("models_path"), "folder with exported model files.",
Expand Down

0 comments on commit 275729c

Please sign in to comment.