Home > Enterprise >  Can I load hdf5 model from firebase storage?
Can I load hdf5 model from firebase storage?

Time:05-12

I use firebase as a database and storage and I want to run my model on the python and perform predict.

How can I load the model and run it on python?

How do I access a model stored in storage?

I tried to do:

# import firebase_admin
# from firebase_admin import credentials
# from firebase_admin import storage
#
# cred = credentials.Certificate('serviceAccountKey.json')
# firebase_admin.initialize_app(cred, {
# 'storageBucket': 'gs://app.appspot.com.appspot.com'
# })

import pyrebase
config={
    "apiKey": "",
    "authDomain": "app.firebaseapp.com",
    "storageBucket":"app.appspot.com",
    "databaseURL":"https://app.firebaseio.com",
    "type": "service_account",
    "project_id": "app"
    # "private_key_id": "633bcc74c30d50157a0aea2dd"
}

firebase=pyrebase.initialize_app(config)
storage=firebase.storage()

I checked that I am connected to storage and have the option to upload and download photos.

Then I copied the link to the model what firease storage

import numpy as np
from tensorflow.keras.preprocessing import image
import tensorflow as tf

MODEL_PATH = "gs://app.appspot.com/model.hdf5"

model = tf.keras.models.load_model(MODEL_PATH)

But it shows me errors and does not work:

Traceback (most recent call last):
  File "C:\Users\hoday\Documents\GitHub\SRD\storgesever.py", line 4, in <module>
    import pyrebase
  File "C:\Users\hoday\venv\untitled\lib\site-packages\pyrebase\__init__.py", line 1, in <module>
    from .pyrebase import initialize_app
  File "C:\Users\hoday\venv\untitled\lib\site-packages\pyrebase\pyrebase.py", line 1, in <module>
    import requests
  File "C:\Users\hoday\venv\untitled\lib\site-packages\requests\__init__.py", line 63, in <module>
    from . import utils
  File "C:\Users\hoday\venv\untitled\lib\site-packages\requests\utils.py", line 27, in <module>
    from .cookies import RequestsCookieJar, cookiejar_from_dict
  File "C:\Users\hoday\venv\untitled\lib\site-packages\requests\cookies.py", line 172, in <module>
    class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'

Process finished with exit code 1

Please help me :)

CodePudding user response:

Use the Firebase client to download the model to the local destination and then load it from the local storage.

CodePudding user response:

That is generic questions you can create a project and access its database or drive try using GoogleDrive.

You can follow the guidelines from Output

  • Related