unitorch.models.kolors¤
KolorsMPSProcessor¤
Bases: HfImageClassificationProcessor, HfTextClassificationProcessor
Initializes the KolorsMPSProcessor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vocab_path
|
str
|
Path to the vocabulary file. |
None
|
merge_path
|
str
|
Path to the merge file. |
None
|
vision_config_path
|
str
|
Path to the vision processor configuration file. |
None
|
max_seq_length
|
int
|
Maximum sequence length. Defaults to 77. |
77
|
position_start_id
|
int
|
Starting position ID. Defaults to 0. |
0
|
Source code in src/unitorch/models/kolors/processing.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
text_classification ¤
text_classification(
text: str, max_seq_length: Optional[int] = None
)
Processes text for classification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Input text. |
required |
max_seq_length
|
int
|
Maximum sequence length. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
GenericOutputs |
Processed text inputs. |
Source code in src/unitorch/models/kolors/processing.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
image_classification ¤
image_classification(image: Union[Image, str])
Processes an image for classification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image or str
|
Input image or path. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GenericOutputs |
Processed image inputs. |
Source code in src/unitorch/models/kolors/processing.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
classification ¤
classification(
text: str,
image: Union[Image, str],
condition: str,
max_seq_length: Optional[int] = None,
)
Processes text, image, and condition for multimodal classification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Input text. |
required |
image
|
Image or str
|
Input image or path. |
required |
condition
|
str
|
Condition text. |
required |
max_seq_length
|
int
|
Maximum sequence length. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
GenericOutputs |
Processed text, image, and condition inputs. |
Source code in src/unitorch/models/kolors/processing.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
KolorsMPSModel¤
Bases: GenericModel
Initializes the KolorsMPSModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str
|
Path to the CLIP configuration file. |
required |
Source code in src/unitorch/models/kolors/modeling.py
217 218 219 220 221 222 223 224 225 226 227 | |
forward ¤
forward(
input_ids: Tensor,
attention_mask: Tensor,
position_ids: Tensor,
pixel_values: Tensor,
condition_input_ids: Tensor,
condition_attention_mask: Tensor,
condition_position_ids: Tensor,
labels: Optional[Tensor] = None,
)
Forward pass of the KolorsMPSModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_ids
|
Tensor
|
Text token IDs. |
required |
attention_mask
|
Tensor
|
Text attention mask. |
required |
position_ids
|
Tensor
|
Text position IDs. |
required |
pixel_values
|
Tensor
|
Image pixel values. |
required |
condition_input_ids
|
Tensor
|
Condition text token IDs. |
required |
condition_attention_mask
|
Tensor
|
Condition text attention mask. |
required |
condition_position_ids
|
Tensor
|
Condition text position IDs. |
required |
labels
|
Tensor
|
Labels (unused). Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
torch.Tensor: Scaled similarity scores. |
Source code in src/unitorch/models/kolors/modeling.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |