@@ -28,7 +28,7 @@ Sklearn
28
28
estimator=sklearn_estimator, artifact_dir=tempfile.mkdtemp()
29
29
)
30
30
31
- # Autogenerate score.py, pickled model, runtime.yaml, input_schema.json and output_schema.json
31
+ # Autogenerate score.py, serialized model, runtime.yaml, input_schema.json and output_schema.json
32
32
sklearn_model.prepare(
33
33
inference_conda_env="dbexp_p38_cpu_v1",
34
34
X_sample=X_train,
@@ -68,7 +68,7 @@ Create a model, prepare it, verify that it works, save it to the model catalog,
68
68
# Instantite ads.model.framework.xgboost_model.XGBoostModel using the trained XGBoost Model
69
69
xgboost_model = XGBoostModel(estimator=xgboost_estimator, artifact_dir=tempfile.mkdtemp())
70
70
71
- # Autogenerate score.py, pickled model, runtime.yaml, input_schema.json and output_schema.json
71
+ # Autogenerate score.py, serialized model, runtime.yaml, input_schema.json and output_schema.json
72
72
xgboost_model.prepare(
73
73
inference_conda_env="generalml_p38_cpu_v1",
74
74
X_sample=X_train,
@@ -109,7 +109,7 @@ Create a model, prepare it, verify that it works, save it to the model catalog,
109
109
# Instantite ads.model.lightgbm_model.XGBoostModel using the trained LGBM Model
110
110
lightgbm_model = LightGBMModel(estimator=lightgbm_estimator, artifact_dir=tempfile.mkdtemp())
111
111
112
- # Autogenerate score.py, pickled model, runtime.yaml, input_schema.json and output_schema.json
112
+ # Autogenerate score.py, serialized model, runtime.yaml, input_schema.json and output_schema.json
113
113
lightgbm_model.prepare(
114
114
inference_conda_env="generalml_p38_cpu_v1",
115
115
X_sample=X_train,
@@ -154,7 +154,7 @@ Create a model, prepare it, verify that it works, save it to the model catalog,
154
154
# Verify generated artifacts
155
155
torch_model.verify(test_data)
156
156
157
- #Register PyTorch model
157
+ # Register PyTorch model
158
158
model_id = torch_model.save(display_name="PyTorch Model")
159
159
160
160
@@ -214,7 +214,7 @@ Create a model, prepare it, verify that it works, save it to the model catalog,
214
214
# Verify generated artifacts
215
215
prediction = spark_model.verify(test)
216
216
217
- #Register Spark model
217
+ # Register Spark model
218
218
spark_model.save(display_name="Spark Pipeline Model")
219
219
220
220
@@ -248,13 +248,13 @@ Create a model, prepare it, verify that it works, save it to the model catalog,
248
248
# Instantite ads.model.framework.tensorflow_model.TensorFlowModel using the pre-trained TensorFlow Model
249
249
tf_model = TensorFlowModel(tf_estimator, artifact_dir=tempfile.mkdtemp())
250
250
251
- # Autogenerate score.py, pickled model, runtime.yaml, input_schema.json and output_schema.json
251
+ # Autogenerate score.py, serialized model, runtime.yaml, input_schema.json and output_schema.json
252
252
tf_model.prepare(inference_conda_env="tensorflow28_p38_cpu_v1")
253
253
254
254
# Verify generated artifacts
255
255
tf_model.verify(x_test[:1])
256
256
257
- #Register TensorFlow model
257
+ # Register TensorFlow model
258
258
model_id = tf_model.save(display_name="TensorFlow Model")
259
259
260
260
HuggingFace Pipelines
@@ -284,20 +284,20 @@ HuggingFace Pipelines
284
284
## Initiate a HuggingFacePipelineModel instance
285
285
zero_shot_image_classification_model = HuggingFacePipelineModel(classifier, artifact_dir=empfile.mkdtemp())
286
286
287
- ## Prepare a model artifact
288
- conda = "oci://bucket@namespace/path/to/conda/pack"
289
- python_version = "3.8 "
290
- zero_shot_image_classification_model.prepare(inference_conda_env=conda , inference_python_version = python_version, force_overwrite=True)
287
+ # Autogenerate score.py, serialized model, runtime.yaml
288
+ conda_pack_path = "oci://bucket@namespace/path/to/conda/pack"
289
+ python_version = "3.x "
290
+ zero_shot_image_classification_model.prepare(inference_conda_env=conda_pack_path , inference_python_version = python_version, force_overwrite=True)
291
291
292
292
## Test data
293
293
data = {"images": image, "candidate_labels": ["animals", "humans", "landscape"]}
294
294
body = cloudpickle.dumps(data) # convert image to bytes
295
295
296
- ## Verify
296
+ # Verify generated artifacts
297
297
zero_shot_image_classification_model.verify(data=data)
298
298
zero_shot_image_classification_model.verify(data=body)
299
299
300
- ## Save
300
+ # Register HuggingFace Pipeline model
301
301
zero_shot_image_classification_model.save()
302
302
303
303
## Deploy
@@ -336,7 +336,7 @@ Other Frameworks
336
336
generic_model = GenericModel(estimator=model, artifact_dir=tempfile.mkdtemp())
337
337
generic_model.summary_status()
338
338
339
- # Autogenerate score.py, pickled model, runtime.yaml, input_schema.json and output_schema.json
339
+ # Autogenerate score.py, serialized model, runtime.yaml, input_schema.json and output_schema.json
340
340
generic_model.prepare(
341
341
inference_conda_env="dbexp_p38_cpu_v1",
342
342
model_file_name="toy_model.pkl",
@@ -372,7 +372,7 @@ With Model Version Set
372
372
# Within the context manager, you can save the :ref:`Model Serialization` model without specifying the ``model_version_set`` parameter because it's taken from the model context manager. If the model version set doesn't exist in the model catalog, the example creates a model version set named ``my_model_version_set``. If the model version set exists in the model catalog, the models are saved to that model version set.
373
373
with ads.model.experiment(name="my_model_version_set", create_if_not_exists=True):
374
374
375
- # Autogenerate score.py, pickled model, runtime.yaml, input_schema.json and output_schema.json
375
+ # Autogenerate score.py, serialized model, runtime.yaml, input_schema.json and output_schema.json
376
376
generic_model.prepare(
377
377
inference_conda_env="dbexp_p38_cpu_v1",
378
378
model_file_name="toy_model.pkl",
0 commit comments