pixano_inference.transformers.clip
CLIP(pretrained_model='openai/clip-vit-base-patch32', model_id='')
Bases: InferenceModel
CLIP: Connecting text and images
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Model name |
model_id |
str
|
Model ID |
device |
str
|
Model GPU or CPU device (e.g. "cuda", "cpu") |
description |
str
|
Model description |
model |
CLIPModel
|
CLIP model |
processor |
CLIPProcessor
|
CLIP processor |
tokenizer |
CLIPTokenizerFast
|
CLIP tokenizer |
pretrained_model |
str
|
Pretrained model name or path |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pretrained_model |
str
|
Pretrained model name or path |
'openai/clip-vit-base-patch32'
|
model_id |
str
|
Previously used ID, generate new ID if "". Defaults to "". |
''
|
Source code in pixano_inference/transformers/clip.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
precompute_embeddings(batch, views, uri_prefix)
Embedding precomputing for a batch
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch |
RecordBatch
|
Input batch |
required |
views |
list[str]
|
Dataset views |
required |
uri_prefix |
str
|
URI prefix for media files |
required |
Returns:
Type | Description |
---|---|
RecordBatch
|
Embedding rows |
Source code in pixano_inference/transformers/clip.py
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 |
|
semantic_search(query)
Process semantic search query with CLIP
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
Search query text |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Search query vector |
Source code in pixano_inference/transformers/clip.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|