pixano.models.inference_model
InferenceModel(name, model_id='', device='', description='')
Bases: ABC
Abstract parent class for OfflineModel and OnlineModel
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Model name |
model_id |
str
|
Model ID |
device |
str
|
Model GPU or CPU device |
description |
str
|
Model description |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Model name |
required |
model_id
|
str
|
Model ID. Defaults to "". |
''
|
device
|
str
|
Model GPU or CPU device. Defaults to "". |
''
|
description
|
str
|
Model description. Defaults to "". |
''
|
Source code in pixano/models/inference_model.py
create_table(process_type, views, dataset)
Create inference table in dataset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
process_type
|
str
|
Process type - 'pre_ann' for pre-annotations to accept or reject as Ground Truth - 'model_run' for annotations to compare to Ground Truth - 'segment_emb' for segmentation embeddings - 'search_emb' for semantic search embeddings |
required |
views
|
list[str]
|
Dataset views |
required |
dataset
|
Dataset
|
Dataset |
required |
Returns:
Type | Description |
---|---|
DatasetTable
|
Inference table |
Source code in pixano/models/inference_model.py
export_to_onnx(library_dir)
Export Torch model to ONNX
Parameters:
Name | Type | Description | Default |
---|---|---|---|
library_dir
|
Path
|
Dataset library directory |
required |
preannotate(batch, views, uri_prefix, threshold=0.0, prompt='')
Generate annotations for dataset rows
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 |
threshold
|
float
|
Confidence threshold. Defaults to 0.0. |
0.0
|
prompt
|
str
|
Annotation text prompt. Defaults to "". |
''
|
Returns:
Type | Description |
---|---|
list[dict]
|
Annotation rows |
Source code in pixano/models/inference_model.py
precompute_embeddings(batch, views, uri_prefix)
Precompute embeddings for dataset rows
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 |
---|---|
list[dict]
|
Embedding rows |
Source code in pixano/models/inference_model.py
process_dataset(dataset_dir, views, process_type, splits=None, batch_size=1, threshold=0.0, prompt='')
Process dataset for annotations or embeddings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_dir
|
Path
|
Dataset directory |
required |
views
|
list[str]
|
Dataset views |
required |
process_type
|
str
|
Process type - 'pre_ann' for pre-annotations to accept or reject as Ground Truth - 'model_run' for annotations to compare to Ground Truth - 'segment_emb' for segmentation embeddings - 'search_emb' for semantic search embeddings |
required |
splits
|
list[str]
|
Dataset splits, all if None. Defaults to None. |
None
|
batch_size
|
int
|
Rows per process batch. Defaults to 1. |
1
|
threshold
|
float
|
Confidence threshold for predictions. Defaults to 0.0. |
0.0
|
prompt
|
str
|
Annotation text prompt. Defaults to "". |
''
|
Returns:
Type | Description |
---|---|
Dataset
|
Dataset |
Source code in pixano/models/inference_model.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 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 |
|