Send feedback
firebase_admin.ml module
Stay organized with collections
Save and categorize content based on your preferences.
Firebase ML module.
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.
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
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.
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.
as_dict ( for_upload = False )
Returns a serializable representation of the object.
classmethod from_dict ( data , app = None )
Create an instance of the object from a dict.
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.
class firebase_admin.ml. ModelFormat
Bases: object
Abstract base class representing a Model Format such as TFLite.
as_dict ( for_upload = False )
Returns a serializable representation of the object.
TFLiteAutoMlSource class firebase_admin.ml. TFLiteAutoMlSource ( auto_ml_model , app = None )
Bases: TFLiteModelSource
TFLite model source representing a tflite model created with AutoML.
AutoML model support is deprecated and will be removed in the next major version.
as_dict ( for_upload = False )
Returns a serializable representation of the object.
property auto_ml_model
Resource name of the model, created by the AutoML API or Cloud console.
class firebase_admin.ml. TFLiteFormat ( model_source = None )
Bases: ModelFormat
Model format representing a TFLite model.
Parameters:
model_source – A TFLiteModelSource sub class. Specifies the details of the model source.
as_dict ( for_upload = False )
Returns a serializable representation of the object.
classmethod from_dict ( data )
Create an instance of the object from a dict.
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
TFLite model source representing a tflite model file stored in GCS.
as_dict ( for_upload = False )
Returns a serializable representation of the object.
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
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
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
Raises:
ImportError – If the Cloud Storage Library has not been installed.
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.
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.
Parameters:
Returns:
The model that was created in Firebase ML.
Return type:
Model
delete_model firebase_admin.ml. delete_model ( model_id , app = None )
Deletes a model from the current project.
Parameters:
get_model firebase_admin.ml. get_model ( model_id , app = None )
Gets the model specified by the given ID.
Parameters:
Returns:
The requested model.
Return type:
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.
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
publish_model firebase_admin.ml. publish_model ( model_id , app = None )
Publishes a Firebase ML model.
A published model can be downloaded to client apps.
Parameters:
Returns:
The published model.
Return type:
Model
unpublish_model firebase_admin.ml. unpublish_model ( model_id , app = None )
Unpublishes a Firebase ML model.
Parameters:
Returns:
The unpublished model.
Return type:
Model
update_model firebase_admin.ml. update_model ( model , app = None )
Updates a model’s metadata or model file.
Parameters:
Returns:
The updated model.
Return type:
Model
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-09-26 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-09-26 UTC."],[],[]]