Skip to content

Commit 9b3eee5

Browse files
committed
update code
1 parent 8959e7c commit 9b3eee5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

articles/cognitive-services/Computer-vision/how-to/model-customization.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ You can generate a SAS token with at least `read` permission on your Azure Blob
145145

146146
#### Option 2: Managed Identity or public accessible
147147

148-
`https://{your_blob}.blob.core.windows.net/`
149-
150148
You can also use [Managed Identity](/azure/active-directory/managed-identities-azure-resources/overview) to grant access.
151149

152150
Below is a series of steps for allowing the system-assigned Managed Identity of your Computer Vision resource to access your blob storage. In the Azure portal:
@@ -170,24 +168,25 @@ dataset_name = '{specify_your_dataset_name}'
170168
auth_kind = AuthenticationKind.SAS # or AuthenticationKind.MI
171169

172170
dataset_client = DatasetClient(resource_type, resource_name, multi_service_endpoint, resource_key)
171+
annotation_file_uris = ['{specify_your_annotation_uri}'] # example: https://example_data.blob.core.windows.net/datasets/cat_dog/train_coco.json
173172
# register dataset
174173
if auth_kind == AuthenticationKind.SAS:
175174
# option 1: sas
176175
sas_auth = Authentication(AuthenticationKind.SAS, '{your_sas_token}') # note the token/query string is needed, not the full url
177176
dataset = Dataset(name=dataset_name,
178177
annotation_kind=AnnotationKind.MULTICLASS_CLASSIFICATION, # checkout AnnotationKind for all annotation kinds
179-
annotation_file_uris=['https://{your_blob}.blob.core.windows.net/datasets/cat_dog/train_coco.json'],
178+
annotation_file_uris=annotation_file_uris,
180179
authentication=sas_auth)
181180
else:
182181
# option 2: managed identity or public accessible. make sure your storage is accessible via the managed identiy, if it is not public accessible
183182
dataset = Dataset(name=dataset_name,
184183
annotation_kind=AnnotationKind.MULTICLASS_CLASSIFICATION, # checkout AnnotationKind for all annotation kinds
185-
annotation_file_uris=['https://{your_blob}.blob.core.windows.net/datasets/cat_dog/train_coco.json'])
184+
annotation_file_uris=annotation_file_uris)
186185

187186
reg_dataset = dataset_client.register_dataset(dataset)
188187
logging.info(f'Register dataset: {reg_dataset.__dict__}')
189188

190-
# specify your evaluation dataset here
189+
# specify your evaluation dataset here, you can follow the same registeration process as the training dataset
191190
eval_dataset = None
192191
if eval_dataset:
193192
reg_eval_dataset = dataset_client.register_dataset(eval_dataset)
@@ -209,7 +208,6 @@ eval_params = EvaluationParameters(test_dataset_name=eval_dataset.name) if eval_
209208
model = Model(model_name, train_params, eval_params)
210209
model = training_client.train_model(model)
211210
logging.info(f'Start training: {model.__dict__}')
212-
213211
```
214212

215213
## Check the training status
@@ -231,7 +229,7 @@ Use the following code to get a prediction with a new sample image.
231229
from cognitive_service_vision_model_customization_python_samples import PredictionClient
232230
prediction_client = PredictionClient(resource_type, resource_name, multi_service_endpoint, resource_key)
233231

234-
with open('./media/microsoft_logo.png', 'rb') as f:
232+
with open('path_to_your_test_image.png', 'rb') as f:
235233
img = f.read()
236234

237235
prediction = prediction_client.predict(model_name, img, content_type='image/png')

0 commit comments

Comments
 (0)