pixano_inference.providers.transformers
Provider for Hugging Face Transformers models.
TransformersProvider(*args, **kwargs)
Bases: ModelProvider
Provider for Hugging Face Transformers models.
Source code in pixano_inference/providers/transformers.py
image_mask_generation(request, model, *args, **kwargs)
Generate a mask from the image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
ImageMaskGenerationRequest
|
Request for the generation. |
required |
model
|
TransformerModel
|
Model to use for the generation. |
required |
args
|
Any
|
Additional arguments. |
()
|
kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
ImageMaskGenerationOutput
|
Output of the generation |
Source code in pixano_inference/providers/transformers.py
image_zero_shot_detection(request, model, *args, **kwargs)
Perform zero-shot image detection.
Source code in pixano_inference/providers/transformers.py
load_model(name, task, device, path=None, processor_config={}, config={})
Load a model from transformers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the model. |
required |
task
|
Task | str
|
Task of the model. |
required |
device
|
device
|
Device to use for the model. |
required |
path
|
Path | str | None
|
Path to the model or its Hugging Face hub's identifier. |
None
|
processor_config
|
dict
|
Configuration for the processor. |
{}
|
config
|
dict
|
Configuration for the model. |
{}
|
Returns:
Type | Description |
---|---|
TransformerModel
|
Loaded model. |
Source code in pixano_inference/providers/transformers.py
text_image_conditional_generation(request, model, *args, **kwargs)
Generate text from an image and a prompt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
TextImageConditionalGenerationRequest
|
Request for text-image conditional generation. |
required |
model
|
TransformerModel
|
Model for text-image conditional generation |
required |
args
|
Any
|
Additional arguments. |
()
|
kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
TextImageConditionalGenerationOutput
|
Output of text-image conditional generation. |
Source code in pixano_inference/providers/transformers.py
get_conditional_generation_transformer_from_pretrained(name, path, **model_kwargs)
Get a transformer model from transformers using automodel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the model. |
required |
path
|
Path | str | None
|
Path to the model or its Hugging Face hub's identifier. |
required |
model_kwargs
|
Any
|
Additional keyword arguments for the model. |
{}
|
Returns:
Type | Description |
---|---|
PreTrainedModel
|
Model from Transformers. |
Source code in pixano_inference/providers/transformers.py
get_transformer_automodel_from_pretrained(pretrained_model_name_or_path, task, **model_kwargs)
Get a transformer model from transformers using automodel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pretrained_model_name_or_path
|
str | Path
|
Name or path of the pretrained model. |
required |
task
|
Task
|
Task of the model. |
required |
model_kwargs
|
Any
|
Additional keyword arguments for the model. |
{}
|
Source code in pixano_inference/providers/transformers.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|