Picture of the author

References

Models

This page explains how to work with Synativ Models. Once you have uploaded your dataset you can fine-tune one of the foundational models available through Synativ on your dataset.

List Foundation Models

To fine-tune a model, you need a foundation model. Synativ enables you to fine-tune a number of foundation models. You can check the list of foundational models we support by calling list_foundation_models:

synativ_api.list_foundation_models()

This will return a response object with a list of foundation models you can fine tune like:

ListFoundationModelsResponse(
	foundation_models=[
		FoundationModel(ref='sam_semantic_big', name='SAM-Big for Semantic Segmentation', description="SAM-based model for semantic segmentation. Uses the 'Big' variant of SAM."),
		FoundationModel(ref='sam_semantic_huge', name='SAM-Huge for Semantic Segmentation', description="SAM-based model for semantic segmentation. Uses the 'Huge' variant of SAM.")
	]
)

Each foundational model record contains:

  • ref: this is the reference you need to use when fine-tuning the model (next section).
  • name: this is a common well-known friendly name for that model.
  • description: a short description of this foundational model.

Fine-Tune Model

You can start fine-tuning by calling fine_tune:

synativ_api.fine_tune(
    dataset_id="synativ-dataset-866aff49-4534-4656-acba-8560eed4f89f",
    base_model="sam_semantic_big",
    metadata={}
)

You will receive a Model object which includes an id to reference that model in the future:

Model(
    creation_time='2023-08-22 15:39:26.577016',
    checkpoint='',
    metadata='{"learning_rate":0.01,"batch_size":5,"num_epochs":500}',
    base_model='sam_semantic_big',
    dataset_id='synativ-dataset-866aff49-4534-4656-acba-8560eed4f89f',
    id='synativ-model-2daf4f03-5523-43f0-bf8e-e925ec099a1e'
)

List Models

You can list your existing Models by calling list_models:

synativ_api.list_models()

You will receive a list of Models depending on how many Models you have fine-tuned:

ListModelsResponse(
	models=[
		Model(
            creation_time='2023-08-22 15:39:26.577016',
            checkpoint='',
            metadata='{"learning_rate":0.01,"batch_size":5,"num_epochs":500}',
            base_model='sam_semantic_big',
            dataset_id='synativ-dataset-866aff49-4534-4656-acba-8560eed4f89f',
            id='synativ-model-2daf4f03-5523-43f0-bf8e-e925ec099a1e'
        ),
		Model(
            creation_time='2023-08-22 15:17:58.479698',
            checkpoint='',
            metadata='{"learning_rate":0.01,"batch_size":5,"num_epochs":500}',
            base_model='sam_semantic_huge',
            dataset_id='synativ-dataset-bba9568b-c37d-49e3-b0bd-5268537c240d',
            id='synativ-model-f07d0c62-b6f2-4304-934e-de9df57dff99'
        )
	]
)

Get Model Details

You can get the details of a specific Model by calling get_model with the respective ModelId:

synativ_api.get_model(
    model_id="synativ-model-2daf4f03-5523-43f0-bf8e-e925ec099a1e"
)

You will receive an Model object as response:

Model(
    creation_time='2023-08-22 15:39:26.577016',
    checkpoint='',
    metadata='{"learning_rate":0.01,"batch_size":5,"num_epochs":500}',
    base_model='sam_semantic_big',
    dataset_id='synativ-dataset-866aff49-4534-4656-acba-8560eed4f89f',
    id='synativ-model-2daf4f03-5523-43f0-bf8e-e925ec099a1e'
)

Get Model Status

You can check the status of your Model by calling get_model_status with the respective ModelId:

synativ_api.get_model_status(
    model_id="synativ-model-2daf4f03-5523-43f0-bf8e-e925ec099a1e",
)

This will return a Status object with one of the following:

Status(status='NOT_FOUND')          ## Wrong model id
Status(status='QUEUED')             ## Job is queued
Status(status='SETTING_UP')         ## Job is setting up
Status(status='DOWNLOADING_DATA')   ## Downaloding data and pretrained models
Status(status='TRAINING')           ## Model training in progress
Status(status='SAVING_MODEL')       ## Saving fine-tuned model
Status(status='COMPLETED')          ## Fine-tuning has completed
Status(status='FAILED')             ## Fine-tuning has failed

Start Model Hosting

You can start hosting your fine-tuned model for real-time inference with Synativ by calling start_hosting with the respective ModelId:

synativ_api.start_hosting(
    model_id="synativ-model-2daf4f03-5523-43f0-bf8e-e925ec099a1e",
)

You will receive a Client object as response:

Client(
    creation_time='2023-08-22 15:39:26.577016',
    model_id='synativ-model-2daf4f03-5523-43f0-bf8e-e925ec099a1e'
    id='synativ-client-83ad82bd-3823-23e6-bf8e-18dfced6281'
)

You can now run inference on your images in real time by calling infer with the respective ClientId:

synativ_api.infer(
    image,
    client_id="synativ-client-83ad82bd-3823-23e6-bf8e-18dfced6281",
)

Please make sure that your images are in the same format as you have prepared them for training the model.

Stop Model Hosting

You can stop hosting your fine-tuned model with Synativ by calling stop_hosting with the respective ModelId:

synativ_api.stop_hosting(
    model_id="synativ-model-2daf4f03-5523-43f0-bf8e-e925ec099a1e",
)

The respective model will remain available for future hosting.

Delete Model

You can always delete a Model by calling delete_model with the respective ModelId:

synativ_api.delete_model(
    model_id="synativ-model-2daf4f03-5523-43f0-bf8e-e925ec099a1e"
)

Deleting a Model will completely delete all records and files of this model from our servers. We will have no way, whatsoever, to retrieve it.

Previous
Datasets