0
# Training Operations
1
2
Complete machine learning pipeline management for Azure Custom Vision. The training client provides comprehensive functionality for building custom computer vision models including project management, data handling, model training, performance evaluation, and export capabilities.
3
4
## Capabilities
5
6
### Client Initialization
7
8
Create and configure the training client with authentication credentials.
9
10
```python { .api }
11
class CustomVisionTrainingClient:
12
def __init__(self, endpoint: str, credentials):
13
"""
14
Initialize the Custom Vision Training Client.
15
16
Parameters:
17
- endpoint: str, Custom Vision training endpoint URL
18
- credentials: Authentication credentials object
19
"""
20
21
class CustomVisionTrainingClientConfiguration:
22
"""Training client configuration settings."""
23
```
24
25
### Project Management
26
27
Create, configure, and manage Custom Vision projects for different computer vision tasks.
28
29
```python { .api }
30
def get_projects() -> list:
31
"""
32
Get all projects for the current user.
33
34
Returns:
35
list[Project]: List of user's projects
36
"""
37
38
def create_project(name: str, description: str = None, domain_id: str = None,
39
classification_type: str = None, target_export_platforms: list = None,
40
export_model_container_uri: str = None, notification_queue_uri: str = None) -> Project:
41
"""
42
Create a new Custom Vision project.
43
44
Parameters:
45
- name: str, project name
46
- description: str, optional project description
47
- domain_id: str, domain ID for the project type
48
- classification_type: str, "Multiclass" or "Multilabel"
49
- target_export_platforms: list, platforms for model export
50
- export_model_container_uri: str, container URI for exports
51
- notification_queue_uri: str, notification queue URI
52
53
Returns:
54
Project: Created project object
55
"""
56
57
def get_project(project_id: str) -> Project:
58
"""
59
Get project by ID.
60
61
Parameters:
62
- project_id: str, unique project identifier
63
64
Returns:
65
Project: Project object
66
"""
67
68
def update_project(project_id: str, project: Project) -> Project:
69
"""
70
Update project settings.
71
72
Parameters:
73
- project_id: str, project identifier
74
- project: Project, updated project object
75
76
Returns:
77
Project: Updated project object
78
"""
79
80
def delete_project(project_id: str):
81
"""
82
Delete a project permanently.
83
84
Parameters:
85
- project_id: str, project identifier to delete
86
"""
87
88
def export_project(project_id: str, platform: str, flavor: str = None, options: dict = None) -> str:
89
"""
90
Export project for transfer or backup.
91
92
Parameters:
93
- project_id: str, project identifier
94
- platform: str, export platform
95
- flavor: str, export flavor/variant
96
- options: dict, export options
97
98
Returns:
99
str: Export token for project import
100
"""
101
102
def import_project(name: str, export_token: str, export_model_container_uri: str = None,
103
notification_queue_uri: str = None) -> Project:
104
"""
105
Import project from export token.
106
107
Parameters:
108
- name: str, name for imported project
109
- export_token: str, token from export_project
110
- export_model_container_uri: str, container URI for models
111
- notification_queue_uri: str, notification queue URI
112
113
Returns:
114
Project: Imported project object
115
"""
116
```
117
118
### Domain Management
119
120
Manage available domains that define the type of computer vision model (classification, object detection, etc.).
121
122
```python { .api }
123
def get_domains() -> list:
124
"""
125
Get list of available domains for projects.
126
127
Returns:
128
list[Domain]: Available domains for different model types
129
"""
130
131
def get_domain(domain_id: str) -> Domain:
132
"""
133
Get specific domain information.
134
135
Parameters:
136
- domain_id: str, domain identifier
137
138
Returns:
139
Domain: Domain information object
140
"""
141
```
142
143
### Image Management
144
145
Upload, organize, and manage training images with metadata and tagging information.
146
147
```python { .api }
148
def create_images_from_data(project_id: str, image_data: bytes, tag_ids: list = None) -> ImageCreateSummary:
149
"""
150
Upload image from binary data with optional tags.
151
152
Parameters:
153
- project_id: str, target project identifier
154
- image_data: bytes, image binary data
155
- tag_ids: list, optional list of tag IDs to apply
156
157
Returns:
158
ImageCreateSummary: Summary of image creation results
159
"""
160
161
def create_images_from_files(project_id: str, batch: ImageFileCreateBatch) -> ImageCreateSummary:
162
"""
163
Upload multiple images from file batch.
164
165
Parameters:
166
- project_id: str, target project identifier
167
- batch: ImageFileCreateBatch, batch of file entries
168
169
Returns:
170
ImageCreateSummary: Summary of batch upload results
171
"""
172
173
def create_images_from_urls(project_id: str, batch: ImageUrlCreateBatch) -> ImageCreateSummary:
174
"""
175
Upload multiple images from URL batch.
176
177
Parameters:
178
- project_id: str, target project identifier
179
- batch: ImageUrlCreateBatch, batch of URL entries
180
181
Returns:
182
ImageCreateSummary: Summary of batch upload results
183
"""
184
185
def create_images_from_predictions(project_id: str, batch: ImageIdCreateBatch) -> ImageCreateSummary:
186
"""
187
Create training images from stored predictions.
188
189
Parameters:
190
- project_id: str, target project identifier
191
- batch: ImageIdCreateBatch, batch of prediction IDs
192
193
Returns:
194
ImageCreateSummary: Summary of image creation results
195
"""
196
197
def get_images(project_id: str, tag_ids: list = None, ordering: str = None,
198
take: int = 50, skip: int = 0) -> list:
199
"""
200
Get project images with filtering and pagination.
201
202
Parameters:
203
- project_id: str, project identifier
204
- tag_ids: list, filter by specific tag IDs
205
- ordering: str, sort order ("Newest", "Oldest", "Suggested")
206
- take: int, number of images to retrieve (max 256)
207
- skip: int, number of images to skip
208
209
Returns:
210
list[Image]: List of image objects
211
"""
212
213
def get_tagged_images(project_id: str, iteration_id: str = None, tag_ids: list = None,
214
ordering: str = None, take: int = 50, skip: int = 0) -> list:
215
"""
216
Get images that have been tagged.
217
218
Parameters:
219
- project_id: str, project identifier
220
- iteration_id: str, optional iteration filter
221
- tag_ids: list, filter by specific tag IDs
222
- ordering: str, sort order
223
- take: int, number of images to retrieve
224
- skip: int, number of images to skip
225
226
Returns:
227
list[Image]: List of tagged images
228
"""
229
230
def get_untagged_images(project_id: str, iteration_id: str = None,
231
take: int = 50, skip: int = 0) -> list:
232
"""
233
Get images that have not been tagged.
234
235
Parameters:
236
- project_id: str, project identifier
237
- iteration_id: str, optional iteration filter
238
- take: int, number of images to retrieve
239
- skip: int, number of images to skip
240
241
Returns:
242
list[Image]: List of untagged images
243
"""
244
245
def delete_images(project_id: str, image_ids: list = None, all_images: bool = None,
246
all_iterations: bool = None):
247
"""
248
Delete images from project.
249
250
Parameters:
251
- project_id: str, project identifier
252
- image_ids: list, specific image IDs to delete
253
- all_images: bool, delete all images
254
- all_iterations: bool, delete from all iterations
255
"""
256
257
def update_image_metadata(project_id: str, batch: ImageMetadataUpdateBatch) -> ImageMetadataUpdateSummary:
258
"""
259
Update metadata for multiple images.
260
261
Parameters:
262
- project_id: str, project identifier
263
- batch: ImageMetadataUpdateBatch, batch metadata updates
264
265
Returns:
266
ImageMetadataUpdateSummary: Summary of update results
267
"""
268
```
269
270
### Tag Management
271
272
Create and manage classification tags for organizing and labeling training data.
273
274
```python { .api }
275
def get_tags(project_id: str, iteration_id: str = None) -> list:
276
"""
277
Get all tags for a project.
278
279
Parameters:
280
- project_id: str, project identifier
281
- iteration_id: str, optional iteration filter
282
283
Returns:
284
list[Tag]: List of project tags
285
"""
286
287
def create_tag(project_id: str, name: str, description: str = None, type: str = None) -> Tag:
288
"""
289
Create a new tag for the project.
290
291
Parameters:
292
- project_id: str, project identifier
293
- name: str, tag name
294
- description: str, optional tag description
295
- type: str, tag type ("Regular", "Negative", "GeneralProduct")
296
297
Returns:
298
Tag: Created tag object
299
"""
300
301
def get_tag(project_id: str, tag_id: str) -> Tag:
302
"""
303
Get specific tag information.
304
305
Parameters:
306
- project_id: str, project identifier
307
- tag_id: str, tag identifier
308
309
Returns:
310
Tag: Tag object
311
"""
312
313
def update_tag(project_id: str, tag_id: str, tag: Tag) -> Tag:
314
"""
315
Update tag information.
316
317
Parameters:
318
- project_id: str, project identifier
319
- tag_id: str, tag identifier
320
- tag: Tag, updated tag object
321
322
Returns:
323
Tag: Updated tag object
324
"""
325
326
def delete_tag(project_id: str, tag_id: str):
327
"""
328
Delete a tag from the project.
329
330
Parameters:
331
- project_id: str, project identifier
332
- tag_id: str, tag identifier to delete
333
"""
334
335
def create_image_tags(project_id: str, batch: ImageTagCreateBatch) -> ImageTagCreateSummary:
336
"""
337
Apply tags to multiple images.
338
339
Parameters:
340
- project_id: str, project identifier
341
- batch: ImageTagCreateBatch, batch tag assignments
342
343
Returns:
344
ImageTagCreateSummary: Summary of tag creation results
345
"""
346
347
def delete_image_tags(project_id: str, image_ids: list, tag_ids: list):
348
"""
349
Remove tags from images.
350
351
Parameters:
352
- project_id: str, project identifier
353
- image_ids: list, image IDs to untag
354
- tag_ids: list, tag IDs to remove
355
"""
356
```
357
358
### Training and Iteration Management
359
360
Train custom vision models and manage different training iterations with performance tracking.
361
362
```python { .api }
363
def train_project(project_id: str, training_type: str = None, reserved_budget_in_hours: int = None,
364
force_train: bool = None, notification_email_address: str = None,
365
training_parameters: dict = None) -> Iteration:
366
"""
367
Start training a new model iteration.
368
369
Parameters:
370
- project_id: str, project identifier
371
- training_type: str, "Regular" or "Advanced"
372
- reserved_budget_in_hours: int, training time budget
373
- force_train: bool, force training even with few images
374
- notification_email_address: str, email for completion notification
375
- training_parameters: dict, advanced training parameters
376
377
Returns:
378
Iteration: New training iteration object
379
"""
380
381
def get_iterations(project_id: str) -> list:
382
"""
383
Get all training iterations for a project.
384
385
Parameters:
386
- project_id: str, project identifier
387
388
Returns:
389
list[Iteration]: List of training iterations
390
"""
391
392
def get_iteration(project_id: str, iteration_id: str) -> Iteration:
393
"""
394
Get specific iteration information.
395
396
Parameters:
397
- project_id: str, project identifier
398
- iteration_id: str, iteration identifier
399
400
Returns:
401
Iteration: Iteration object with details
402
"""
403
404
def update_iteration(project_id: str, iteration_id: str, iteration: Iteration) -> Iteration:
405
"""
406
Update iteration settings.
407
408
Parameters:
409
- project_id: str, project identifier
410
- iteration_id: str, iteration identifier
411
- iteration: Iteration, updated iteration object
412
413
Returns:
414
Iteration: Updated iteration object
415
"""
416
417
def delete_iteration(project_id: str, iteration_id: str):
418
"""
419
Delete a training iteration.
420
421
Parameters:
422
- project_id: str, project identifier
423
- iteration_id: str, iteration identifier to delete
424
"""
425
426
def publish_iteration(project_id: str, iteration_id: str, publish_name: str, prediction_id: str):
427
"""
428
Publish iteration for prediction use.
429
430
Parameters:
431
- project_id: str, project identifier
432
- iteration_id: str, iteration to publish
433
- publish_name: str, name for published model
434
- prediction_id: str, prediction resource ID
435
"""
436
437
def unpublish_iteration(project_id: str, iteration_id: str):
438
"""
439
Unpublish an iteration.
440
441
Parameters:
442
- project_id: str, project identifier
443
- iteration_id: str, iteration to unpublish
444
"""
445
```
446
447
### Performance Analysis
448
449
Evaluate model performance with detailed metrics and per-image analysis.
450
451
```python { .api }
452
def get_iteration_performance(project_id: str, iteration_id: str, threshold: float = None,
453
overlap_threshold: float = None) -> IterationPerformance:
454
"""
455
Get detailed performance metrics for an iteration.
456
457
Parameters:
458
- project_id: str, project identifier
459
- iteration_id: str, iteration identifier
460
- threshold: float, confidence threshold for metrics
461
- overlap_threshold: float, overlap threshold for object detection
462
463
Returns:
464
IterationPerformance: Comprehensive performance metrics
465
"""
466
467
def get_image_performances(project_id: str, iteration_id: str, tag_ids: list = None,
468
ordering: str = None, take: int = 50, skip: int = 0) -> list:
469
"""
470
Get per-image performance analysis.
471
472
Parameters:
473
- project_id: str, project identifier
474
- iteration_id: str, iteration identifier
475
- tag_ids: list, filter by specific tags
476
- ordering: str, sort order
477
- take: int, number of results to retrieve
478
- skip: int, number of results to skip
479
480
Returns:
481
list[ImagePerformance]: Per-image performance data
482
"""
483
```
484
485
### Quick Testing
486
487
Perform quick tests on trained models without formal publishing.
488
489
```python { .api }
490
def quick_test_image(project_id: str, image_data: bytes, iteration_id: str = None,
491
store: bool = True) -> ImagePrediction:
492
"""
493
Quick test with image data.
494
495
Parameters:
496
- project_id: str, project identifier
497
- image_data: bytes, test image binary data
498
- iteration_id: str, specific iteration to test (default: latest)
499
- store: bool, whether to store prediction results
500
501
Returns:
502
ImagePrediction: Prediction results
503
"""
504
505
def quick_test_image_url(project_id: str, image_url: str, iteration_id: str = None,
506
store: bool = True) -> ImagePrediction:
507
"""
508
Quick test with image URL.
509
510
Parameters:
511
- project_id: str, project identifier
512
- image_url: str, URL of test image
513
- iteration_id: str, specific iteration to test
514
- store: bool, whether to store prediction results
515
516
Returns:
517
ImagePrediction: Prediction results
518
"""
519
```
520
521
### Image Region Management
522
523
Manage bounding box regions for object detection training and region proposals.
524
525
```python { .api }
526
def get_image_region_proposals(project_id: str, image_id: str) -> ImageRegionProposal:
527
"""
528
Get region proposals for an image to assist with labeling.
529
530
Parameters:
531
- project_id: str, project identifier
532
- image_id: str, image identifier
533
534
Returns:
535
ImageRegionProposal: Suggested regions for labeling
536
"""
537
538
def create_image_regions(project_id: str, regions: list) -> ImageRegionCreateSummary:
539
"""
540
Create image regions (bounding boxes) for object detection.
541
542
Parameters:
543
- project_id: str, project identifier
544
- regions: list[ImageRegionCreateEntry], regions to create
545
546
Returns:
547
ImageRegionCreateSummary: Summary of region creation results
548
"""
549
550
def delete_image_regions(project_id: str, region_ids: list):
551
"""
552
Delete image regions.
553
554
Parameters:
555
- project_id: str, project identifier
556
- region_ids: list[str], region IDs to delete
557
"""
558
```
559
560
### Image Tagging Operations
561
562
Manage tag assignments for images.
563
564
```python { .api }
565
def create_image_tags(project_id: str, tags: list) -> ImageTagCreateSummary:
566
"""
567
Associate images with tags.
568
569
Parameters:
570
- project_id: str, project identifier
571
- tags: list[ImageTagCreateEntry], tag assignments
572
573
Returns:
574
ImageTagCreateSummary: Summary of tagging results
575
"""
576
577
def delete_image_tags(project_id: str, image_ids: list, tag_ids: list):
578
"""
579
Remove tag associations from images.
580
581
Parameters:
582
- project_id: str, project identifier
583
- image_ids: list[str], image identifiers
584
- tag_ids: list[str], tag identifiers to remove
585
"""
586
```
587
588
### Export Management
589
590
Manage model exports for different platforms and formats.
591
592
```python { .api }
593
def get_exports(project_id: str, iteration_id: str) -> list:
594
"""
595
Get all exports for an iteration.
596
597
Parameters:
598
- project_id: str, project identifier
599
- iteration_id: str, iteration identifier
600
601
Returns:
602
list[Export]: Available exports for the iteration
603
"""
604
605
def export_iteration(project_id: str, iteration_id: str, platform: str, flavor: str = None) -> Export:
606
"""
607
Export trained iteration to specified platform.
608
609
Parameters:
610
- project_id: str, project identifier
611
- iteration_id: str, iteration to export
612
- platform: str, target platform (TensorFlow, ONNX, etc.)
613
- flavor: str, platform variant
614
615
Returns:
616
Export: Export operation details
617
"""
618
```
619
620
### Prediction Management
621
622
Manage prediction results and queries.
623
624
```python { .api }
625
def delete_prediction(project_id: str, ids: list):
626
"""
627
Delete prediction results.
628
629
Parameters:
630
- project_id: str, project identifier
631
- ids: list[str], prediction IDs to delete
632
"""
633
634
def query_predictions(project_id: str, query: PredictionQueryToken) -> PredictionQueryResult:
635
"""
636
Query stored prediction results.
637
638
Parameters:
639
- project_id: str, project identifier
640
- query: PredictionQueryToken, query parameters
641
642
Returns:
643
PredictionQueryResult: Matching prediction results
644
"""
645
```
646
647
### Suggestion Operations
648
649
AI-powered suggestions for tagging and region labeling.
650
651
```python { .api }
652
def suggest_tags_and_regions(project_id: str, iteration_id: str, image_ids: list) -> list:
653
"""
654
Get AI suggestions for tags and regions on images.
655
656
Parameters:
657
- project_id: str, project identifier
658
- iteration_id: str, trained iteration for suggestions
659
- image_ids: list[str], images to analyze
660
661
Returns:
662
list[SuggestedTagAndRegion]: AI-generated suggestions
663
"""
664
665
def query_suggested_images(project_id: str, iteration_id: str, query: SuggestedTagAndRegionQueryToken) -> SuggestedTagAndRegionQuery:
666
"""
667
Query suggested images based on criteria.
668
669
Parameters:
670
- project_id: str, project identifier
671
- iteration_id: str, iteration identifier
672
- query: SuggestedTagAndRegionQueryToken, query parameters
673
674
Returns:
675
SuggestedTagAndRegionQuery: Matching suggested images
676
"""
677
678
def query_suggested_image_count(project_id: str, iteration_id: str, tag_ids: list = None, threshold: float = None) -> dict:
679
"""
680
Get count of images with suggestions.
681
682
Parameters:
683
- project_id: str, project identifier
684
- iteration_id: str, iteration identifier
685
- tag_ids: list[str], filter by tag IDs
686
- threshold: float, confidence threshold
687
688
Returns:
689
dict: Suggestion counts by category
690
"""
691
```
692
693
### Additional Image Operations
694
695
Extended image management capabilities.
696
697
```python { .api }
698
def get_artifact(project_id: str, path: str):
699
"""
700
Get artifact content from blob storage.
701
702
Parameters:
703
- project_id: str, project identifier
704
- path: str, artifact path
705
706
Returns:
707
Generator: Artifact content stream
708
"""
709
710
def get_image_performance_count(project_id: str, iteration_id: str, tag_ids: list = None) -> int:
711
"""
712
Get count of images with performance data.
713
714
Parameters:
715
- project_id: str, project identifier
716
- iteration_id: str, iteration identifier
717
- tag_ids: list[str], filter by tag IDs
718
719
Returns:
720
int: Count of images with performance data
721
"""
722
```
723
724
## Data Model Types
725
726
```python { .api }
727
class ImageCreateSummary:
728
"""Summary of image upload operations."""
729
is_batch_successful: bool
730
images: list # list[ImageCreateResult]
731
duplicated_images: list
732
733
class ImageFileCreateBatch:
734
"""Batch of images to upload from files."""
735
images: list # list[ImageFileCreateEntry]
736
tag_ids: list
737
738
class ImageFileCreateEntry:
739
"""Individual file upload entry."""
740
name: str = None
741
contents: bytes
742
tag_ids: list = None
743
regions: list = None
744
metadata: dict = None
745
746
class ImageTagCreateBatch:
747
"""Batch tag creation for images."""
748
tags: list # list[ImageTagCreateEntry]
749
750
class ImageTagCreateEntry:
751
"""Individual tag assignment entry."""
752
image_id: str
753
tag_id: str
754
755
class IterationPerformance:
756
"""Model performance metrics."""
757
per_tag_performance: list # list[TagPerformance]
758
precision: float
759
precision_std_deviation: float
760
recall: float
761
recall_std_deviation: float
762
average_precision: float
763
764
class Image:
765
"""Training image with metadata."""
766
id: str
767
created: datetime
768
width: int
769
height: int
770
image_uri: str
771
thumbnail_uri: str
772
tags: list # list[ImageTag]
773
regions: list # list[ImageRegion]
774
metadata: dict
775
```