|
1 | 1 | import torch |
2 | 2 | from PIL import Image as PILImage |
3 | | -from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration |
| 3 | +from transformers import Qwen2_5_VLForConditionalGeneration, Qwen2_5_VLProcessor |
4 | 4 |
|
5 | 5 | from invokeai.app.invocations.baseinvocation import BaseInvocation, Classification, invocation |
6 | 6 | from invokeai.app.invocations.fields import ( |
@@ -71,14 +71,14 @@ def _encode(self, context: InvocationContext, images: list[PILImage.Image]) -> t |
71 | 71 |
|
72 | 72 | messages = [{"role": "user", "content": content}] |
73 | 73 |
|
74 | | - # Load the full processor (image_processor + tokenizer) from the tokenizer submodel path. |
75 | | - # Using AutoProcessor.from_pretrained ensures all components are loaded correctly |
76 | | - # regardless of whether the model uses Qwen2VLProcessor or Qwen2_5_VLProcessor. |
77 | | - # For diffusers models the processor config lives in the `tokenizer` subdirectory, |
78 | | - # so we append the submodel directory name to the root model path. |
| 74 | + # Load the processor from the tokenizer subdirectory of the diffusers root. |
| 75 | + # Qwen2_5_VLProcessor.from_pretrained is used directly instead of AutoProcessor |
| 76 | + # because AutoProcessor calls AutoConfig.from_pretrained first to determine the |
| 77 | + # model type, but the `tokenizer` subdirectory has no config.json with a model_type |
| 78 | + # key — only tokenizer/preprocessor files live there. |
79 | 79 | tokenizer_config = context.models.get_config(self.qwen_vl_encoder.tokenizer) |
80 | 80 | tokenizer_abs_path = context.models.get_absolute_path(tokenizer_config) / "tokenizer" |
81 | | - processor = AutoProcessor.from_pretrained(str(tokenizer_abs_path), local_files_only=True) |
| 81 | + processor = Qwen2_5_VLProcessor.from_pretrained(str(tokenizer_abs_path), local_files_only=True) |
82 | 82 |
|
83 | 83 | text_encoder_info = context.models.load(self.qwen_vl_encoder.text_encoder) |
84 | 84 | with text_encoder_info.model_on_device() as (_, text_encoder): |
|
0 commit comments