Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Feb 13, 2025
1 parent 66d3003 commit 13a55d7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion optimum/exporters/openvino/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def main_export(
subfolder=subfolder,
revision=revision,
cache_dir=cache_dir,
token=token
token=token,
)
if library_name == "sentence_transformers":
logger.warning(
Expand Down
2 changes: 1 addition & 1 deletion optimum/exporters/openvino/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def export_from_model(
task = TasksManager.map_from_synonym(task)
else:
try:
task = TasksManager._infer_task_from_model_or_model_class(model=model, library_name=library_name)
task = TasksManager._infer_task_from_model_or_model_class(model=model)
except (ValueError, KeyError) as e:
raise RuntimeError(
f"The model task could not be automatically inferred in `export_from_model`. Please provide the argument `task` with the relevant task from {', '.join(TasksManager.get_all_tasks())}. Detailed error: {e}"
Expand Down
5 changes: 1 addition & 4 deletions optimum/exporters/openvino/model_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3944,10 +3944,7 @@ def __exit__(self, exc_type, exc_value, traceback):

class JanusVisionGenEmbeddingModelPatcher(ModelPatcher):
def __init__(
self,
config: "OnnxConfig",
model: Union["PreTrainedModel", "TFPreTrainedModel"],
model_kwargs: Dict[str, Any]
self, config: "OnnxConfig", model: Union["PreTrainedModel", "TFPreTrainedModel"], model_kwargs: Dict[str, Any]
):
model.__orig_forward = model.forward
model.forward = model.prepare_gen_img_embeds
Expand Down
10 changes: 7 additions & 3 deletions optimum/intel/openvino/modeling_visual_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ def _submodel_names(self):
for part in self.additional_parts:
if part == "lm_head" and getattr(self, part + "_model", None) is not None:
model_names.append(part + "_model")
continue
continue
if getattr(self, part, None) is not None:
model_names.append(part + "_model")
return model_names
Expand Down Expand Up @@ -2454,7 +2454,7 @@ def generate_image(
image_token_num_per_image: int = 576,
img_size: int = 384,
patch_size: int = 16,
generator=None
generator=None,
):
from PIL import Image

Expand Down Expand Up @@ -2503,7 +2503,11 @@ def generate_image(
logits = logit_uncond + cfg_weight * (logit_cond - logit_uncond)
probs = torch.softmax(logits / temperature, dim=-1)

next_token = torch.multinomial(probs, num_samples=1) if generator is None else torch.multinomial(probs, num_samples=1, generator=generator)
next_token = (
torch.multinomial(probs, num_samples=1)
if generator is None
else torch.multinomial(probs, num_samples=1, generator=generator)
)
generated_tokens[:, i] = next_token.squeeze(dim=-1)

next_token = torch.cat([next_token.unsqueeze(dim=1), next_token.unsqueeze(dim=1)], dim=1).view(-1)
Expand Down
2 changes: 1 addition & 1 deletion tests/openvino/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
"st-bert": "sentence-transformers/all-MiniLM-L6-v2",
"st-mpnet": "sentence-transformers/all-mpnet-base-v2",
"sana": "katuni4ka/tiny-random-sana",
"janus": "katuni4ka/tiny-random-janus"
"janus": "katuni4ka/tiny-random-janus",
}


Expand Down

0 comments on commit 13a55d7

Please sign in to comment.