Firebase ML module.

> [!CAUTION]
> **Warning: This API is now obsolete.**
>
> Firebase ML is deprecated and will be shut down on June 15, 2027.
> To host custom models, you must migrate to another solution. You can use Cloud Storage for
> Firebase as an alternative for hosting custom models. For more info, see
> <https://firebase.google.com/docs/ml/migrate-to-cloud-storage>

This module contains functions for creating, updating, getting, listing,
deleting, publishing and unpublishing Firebase ML models.

## Classes

### ListModelsPage

class firebase_admin.ml.ListModelsPage(*list_models_func* , *list_filter* , *page_size* , *page_token* , *app* ) Bases: `object`

Represents a page of models in a Firebase project.

> [!CAUTION]
> **Warning: This API is now obsolete.**
>
> Firebase ML is deprecated and will be shut down on June 15, 2027.
> To host custom models, you must migrate to another solution. You can use Cloud Storage for
> Firebase as an alternative for hosting custom models. For more info, see
> <https://firebase.google.com/docs/ml/migrate-to-cloud-storage>

Provides methods for traversing the models included in this page, as well as
retrieving subsequent pages of models. The iterator returned by
`iterate_all()` can be used to iterate through all the models in the
Firebase project starting from this page.


get_next_page()

:   Retrieves the next page of models if available.

    Returns:

    :   Next page of models, or None if this is the last page.

    Return type:

    :   [ListModelsPage](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.ListModelsPage "firebase_admin.ml.ListModelsPage")


iterate_all()

:   Retrieves an iterator for Models.

    Returned iterator will iterate through all the models in the Firebase
    project starting from this page. The iterator will never buffer more than
    one page of models in memory at a time.

    Returns:

    :   An iterator of Model instances.

    Return type:

    :   iterator

property has_next_page True if more pages are available.
property list_filter The filter string used to filter the models.
property models A list of Models from this page.
property next_page_token Token identifying the next page of results.

### Model

class firebase_admin.ml.Model(*display_name=None* , *tags=None* , *model_format=None* ) Bases: `object`

A Firebase ML Model object.

> [!CAUTION]
> **Warning: This API is now obsolete.**
>
> Firebase ML is deprecated and will be shut down on June 15, 2027.
> To host custom models, you must migrate to another solution. You can use Cloud Storage for
> Firebase as an alternative for hosting custom models. For more info, see
> <https://firebase.google.com/docs/ml/migrate-to-cloud-storage>

Parameters:
:
    - **display_name** -- The display name of your model - used to identify your model in code.

    - **tags** -- Optional list of strings associated with your model. Can be used in list queries.

    - **model_format** -- A subclass of ModelFormat. (e.g. TFLiteFormat) Specifies the model details.


classmethod from_dict(*data* , *app=None* )

:   Create an instance of the object from a dict.


as_dict(*for_upload=False* )

:   Returns a serializable representation of the object.


wait_for_unlocked(*max_time_seconds=None* )

:   Waits for the model to be unlocked. (All active operations complete)

    Parameters:

    :   **max_time_seconds** -- The maximum number of seconds to wait for the model to unlock.
        (None for no limit)

    Raises:

    :   **exceptions.DeadlineExceeded** -- If max_time_seconds passed and the model is still locked.

property create_time The time the model was created.
property display_name The model's display name, used to refer to the model in code and in
the Firebase console.
property etag The entity tag (ETag) of the model resource.
property locked True if the Model object is locked by an active operation.
property model_format The model's `ModelFormat` object, which represents the model's
format and storage location.
property model_hash SHA256 hash of the model binary.
property model_id The model's ID, unique to the project.
property published True if the model is published and available for clients to
download.
property tags Tag strings, used for filtering query results.
property update_time The time the model was last updated.
property validation_error Validation error message.

| ### ModelFormat class firebase_admin.ml.ModelFormat |
|---|
| Bases: `object` Abstract base class representing a Model Format such as TFLite. > [!CAUTION] > **Warning: This API is now obsolete.** > Firebase ML is deprecated and will be shut down on June 15, 2027. > To host custom models, you must migrate to another solution. You can use Cloud Storage for > Firebase as an alternative for hosting custom models. For more info, see > <https://firebase.google.com/docs/ml/migrate-to-cloud-storage> as_dict(*for_upload=False* ) :   Returns a serializable representation of the object. |

### TFLiteFormat

class firebase_admin.ml.TFLiteFormat(*model_source=None* ) Bases: [`ModelFormat`](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.ModelFormat "firebase_admin.ml.ModelFormat")

Model format representing a TFLite model.

> [!CAUTION]
> **Warning: This API is now obsolete.**
>
> Firebase ML is deprecated and will be shut down on June 15, 2027.
> To host custom models, you must migrate to another solution. You can use Cloud Storage for
> Firebase as an alternative for hosting custom models. For more info, see
> <https://firebase.google.com/docs/ml/migrate-to-cloud-storage>

Parameters:

:   **model_source** -- A TFLiteModelSource sub class. Specifies the details of the model source.


classmethod from_dict(*data* )

:   Create an instance of the object from a dict.


as_dict(*for_upload=False* )

:   Returns a serializable representation of the object.

property model_source The TF Lite model's location.
property size_bytes The size in bytes of the TF Lite model.

### TFLiteGCSModelSource

class firebase_admin.ml.TFLiteGCSModelSource(*gcs_tflite_uri* , *app=None* ) Bases: [`TFLiteModelSource`](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.TFLiteModelSource "firebase_admin.ml.TFLiteModelSource")

TFLite model source representing a tflite model file stored in GCS.

> [!CAUTION]
> **Warning: This API is now obsolete.**
>
> Firebase ML is deprecated and will be shut down on June 15, 2027.
> To host custom models, you must migrate to another solution. You can use Cloud Storage for
> Firebase as an alternative for hosting custom models. For more info, see
> <https://firebase.google.com/docs/ml/migrate-to-cloud-storage>


classmethod from_keras_model(*keras_model* , *model_file_name='firebase_ml_model.tflite'* , *bucket_name=None* , *app=None* )

:   Creates a Tensor Flow Lite model from the keras model, and uploads the model to GCS.

    Parameters:
    :
        - **keras_model** -- A tf.keras model.

        - **model_file_name** -- The name that the tflite model will be saved as in Cloud Storage.

        - **bucket_name** -- The name of an existing bucket. None to use the default bucket configured
          in the app.

        - **app** -- Optional. A Firebase app instance (or None to use the default app)


    Returns:

    :   The source created from the keras_model

    Return type:

    :   [TFLiteGCSModelSource](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.TFLiteGCSModelSource "firebase_admin.ml.TFLiteGCSModelSource")

    Raises:

    :   **ImportError** -- If the Tensor Flow or Cloud Storage Libraries have not been installed.


classmethod from_saved_model(*saved_model_dir* , *model_file_name='firebase_ml_model.tflite'* , *bucket_name=None* , *app=None* )

:   Creates a Tensor Flow Lite model from the saved model, and uploads the model to GCS.

    Parameters:
    :
        - **saved_model_dir** -- The saved model directory.

        - **model_file_name** -- The name that the tflite model will be saved as in Cloud Storage.

        - **bucket_name** -- The name of an existing bucket. None to use the default bucket configured
          in the app.

        - **app** -- Optional. A Firebase app instance (or None to use the default app)


    Returns:

    :   The source created from the saved_model_dir

    Return type:

    :   [TFLiteGCSModelSource](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.TFLiteGCSModelSource "firebase_admin.ml.TFLiteGCSModelSource")

    Raises:

    :   **ImportError** -- If the Tensor Flow or Cloud Storage Libraries have not been installed.


classmethod from_tflite_model_file(*model_file_name* , *bucket_name=None* , *app=None* )

:   Uploads the model file to an existing Google Cloud Storage bucket.

    Parameters:
    :
        - **model_file_name** -- The name of the model file.

        - **bucket_name** -- The name of an existing bucket. None to use the default bucket configured
          in the app.

        - **app** -- A Firebase app instance (or None to use the default app).


    Returns:

    :   The source created from the model_file

    Return type:

    :   [TFLiteGCSModelSource](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.TFLiteGCSModelSource "firebase_admin.ml.TFLiteGCSModelSource")

    Raises:

    :   **ImportError** -- If the Cloud Storage Library has not been installed.


as_dict(*for_upload=False* )

:   Returns a serializable representation of the object.

property gcs_tflite_uri URI of the model file in Cloud Storage.

| ### TFLiteModelSource class firebase_admin.ml.TFLiteModelSource |
|---|
| Bases: `object` Abstract base class representing a model source for TFLite format models. > [!CAUTION] > **Warning: This API is now obsolete.** > Firebase ML is deprecated and will be shut down on June 15, 2027. > To host custom models, you must migrate to another solution. You can use Cloud Storage for > Firebase as an alternative for hosting custom models. For more info, see > <https://firebase.google.com/docs/ml/migrate-to-cloud-storage> as_dict(*for_upload=False* ) :   Returns a serializable representation of the object. |

## Functions

| ### create_model firebase_admin.ml.create_model(*model* , *app=None* ) |
|---|
| Creates a model in the current Firebase project. > [!CAUTION] > **Warning: This API is now obsolete.** > Firebase ML is deprecated and will be shut down on June 15, 2027. > To host custom models, you must migrate to another solution. You can use Cloud Storage for > Firebase as an alternative for hosting custom models. For more info, see > <https://firebase.google.com/docs/ml/migrate-to-cloud-storage> Parameters: : - **model** -- An ml.Model to create. - **app** -- A Firebase app instance (or None to use the default app). Returns: :   The model that was created in Firebase ML. Return type: :   [Model](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.Model "firebase_admin.ml.Model") |

| ### delete_model firebase_admin.ml.delete_model(*model_id* , *app=None* ) |
|---|
| Deletes a model from the current project. > [!CAUTION] > **Warning: This API is now obsolete.** > Firebase ML is deprecated and will be shut down on June 15, 2027. > To host custom models, you must migrate to another solution. You can use Cloud Storage for > Firebase as an alternative for hosting custom models. For more info, see > <https://firebase.google.com/docs/ml/migrate-to-cloud-storage> Parameters: : - **model_id** -- The id of the model you wish to delete. - **app** -- A Firebase app instance (or None to use the default app). |

| ### get_model firebase_admin.ml.get_model(*model_id* , *app=None* ) |
|---|
| Gets the model specified by the given ID. > [!CAUTION] > **Warning: This API is now obsolete.** > Firebase ML is deprecated and will be shut down on June 15, 2027. > To host custom models, you must migrate to another solution. You can use Cloud Storage for > Firebase as an alternative for hosting custom models. For more info, see > <https://firebase.google.com/docs/ml/migrate-to-cloud-storage> Parameters: : - **model_id** -- The id of the model to get. - **app** -- A Firebase app instance (or None to use the default app). Returns: :   The requested model. Return type: :   [Model](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.Model "firebase_admin.ml.Model") |

| ### list_models firebase_admin.ml.list_models(*list_filter=None* , *page_size=None* , *page_token=None* , *app=None* ) |
|---|
| Lists the current project's models. > [!CAUTION] > **Warning: This API is now obsolete.** > Firebase ML is deprecated and will be shut down on June 15, 2027. > To host custom models, you must migrate to another solution. You can use Cloud Storage for > Firebase as an alternative for hosting custom models. For more info, see > <https://firebase.google.com/docs/ml/migrate-to-cloud-storage> Parameters: : - **list_filter** -- a list filter string such as `tags:'tag_1'`. None will return all models. - **page_size** -- A number between 1 and 100 inclusive that specifies the maximum number of models to return per page. None for default. - **page_token** -- A next page token returned from a previous page of results. None for first page of results. - **app** -- A Firebase app instance (or None to use the default app). Returns: :   A (filtered) list of models. Return type: :   [ListModelsPage](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.ListModelsPage "firebase_admin.ml.ListModelsPage") |

| ### publish_model firebase_admin.ml.publish_model(*model_id* , *app=None* ) |
|---|
| Publishes a Firebase ML model. > [!CAUTION] > **Warning: This API is now obsolete.** > Firebase ML is deprecated and will be shut down on June 15, 2027. > To host custom models, you must migrate to another solution. You can use Cloud Storage for > Firebase as an alternative for hosting custom models. For more info, see > <https://firebase.google.com/docs/ml/migrate-to-cloud-storage> A published model can be downloaded to client apps. Parameters: : - **model_id** -- The id of the model to publish. - **app** -- A Firebase app instance (or None to use the default app). Returns: :   The published model. Return type: :   [Model](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.Model "firebase_admin.ml.Model") |

| ### unpublish_model firebase_admin.ml.unpublish_model(*model_id* , *app=None* ) |
|---|
| Unpublishes a Firebase ML model. > [!CAUTION] > **Warning: This API is now obsolete.** > Firebase ML is deprecated and will be shut down on June 15, 2027. > To host custom models, you must migrate to another solution. You can use Cloud Storage for > Firebase as an alternative for hosting custom models. For more info, see > <https://firebase.google.com/docs/ml/migrate-to-cloud-storage> Parameters: : - **model_id** -- The id of the model to unpublish. - **app** -- A Firebase app instance (or None to use the default app). Returns: :   The unpublished model. Return type: :   [Model](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.Model "firebase_admin.ml.Model") |

| ### update_model firebase_admin.ml.update_model(*model* , *app=None* ) |
|---|
| Updates a model's metadata or model file. > [!CAUTION] > **Warning: This API is now obsolete.** > Firebase ML is deprecated and will be shut down on June 15, 2027. > To host custom models, you must migrate to another solution. You can use Cloud Storage for > Firebase as an alternative for hosting custom models. For more info, see > <https://firebase.google.com/docs/ml/migrate-to-cloud-storage> Parameters: : - **model** -- The ml.Model to update. - **app** -- A Firebase app instance (or None to use the default app). Returns: :   The updated model. Return type: :   [Model](https://firebase.google.com/docs/reference/admin/python/firebase_admin.ml#firebase_admin.ml.Model "firebase_admin.ml.Model") |