Skip to content

Commit 275729c

Browse files
Added tokenizer path to text2image (openvinotoolkit#1057)
1 parent 5e37c60 commit 275729c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/python/py_text2image_models.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

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

14+
#include "tokenizers_path.hpp"
1415
#include "py_utils.hpp"
1516

1617
namespace py = pybind11;
@@ -21,6 +22,7 @@ void init_clip_text_model(py::module_& m) {
2122
.def(py::init([](
2223
const std::filesystem::path& root_dir
2324
) {
25+
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
2426
return std::make_unique<ov::genai::CLIPTextModel>(root_dir);
2527
}),
2628
py::arg("root_dir"), "Model root directory",
@@ -33,6 +35,7 @@ void init_clip_text_model(py::module_& m) {
3335
const std::string& device,
3436
const py::kwargs& kwargs
3537
) {
38+
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
3639
return std::make_unique<ov::genai::CLIPTextModel>(root_dir, device, pyutils::kwargs_to_any_map(kwargs));
3740
}),
3841
py::arg("root_dir"), "Model root directory",
@@ -229,6 +232,7 @@ void init_clip_text_model_with_projection(py::module_& m) {
229232
.def(py::init([](
230233
const std::filesystem::path& root_dir
231234
) {
235+
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
232236
return std::make_unique<ov::genai::CLIPTextModelWithProjection>(root_dir);
233237
}),
234238
py::arg("root_dir"), "Model root directory",
@@ -241,6 +245,7 @@ void init_clip_text_model_with_projection(py::module_& m) {
241245
const std::string& device,
242246
const py::kwargs& kwargs
243247
) {
248+
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
244249
return std::make_unique<ov::genai::CLIPTextModelWithProjection>(root_dir, device, pyutils::kwargs_to_any_map(kwargs));
245250
}),
246251
py::arg("root_dir"), "Model root directory",

src/python/py_text2image_pipeline.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <pybind11/functional.h>
1111

1212
#include "openvino/genai/text2image/pipeline.hpp"
13+
14+
#include "tokenizers_path.hpp"
1315
#include "py_utils.hpp"
1416

1517
namespace py = pybind11;
@@ -183,6 +185,7 @@ void init_text2image_pipeline(py::module_& m) {
183185
.def(py::init([](
184186
const std::filesystem::path& models_path
185187
) {
188+
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
186189
return std::make_unique<ov::genai::Text2ImagePipeline>(models_path);
187190
}),
188191
py::arg("models_path"), "folder with exported model files.",
@@ -196,6 +199,7 @@ void init_text2image_pipeline(py::module_& m) {
196199
const std::string& device,
197200
const py::kwargs& kwargs
198201
) {
202+
ScopedVar env_manager(pyutils::ov_tokenizers_module_path());
199203
return std::make_unique<ov::genai::Text2ImagePipeline>(models_path, device, text2image_kwargs_to_any_map(kwargs, true));
200204
}),
201205
py::arg("models_path"), "folder with exported model files.",

0 commit comments

Comments
 (0)