我使用firebase作为数据库和存储器,我想在python上运行我的模型并执行predict。
我如何加载模型并在python上运行它?
如何访问存储在存储中的模型?
我试着去做:
# 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()
我检查了我是否连接到存储,并有上传和下载照片的选项。
然后,我复制了指向模型的链接
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)
但它显示了错误,并且不起作用:
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
请帮助我:)
2条答案
按热度按时间k2arahey1#
使用Firebase客户端将模型下载到本地目标,然后从本地存储加载。
mspsb9vt2#
这是一般性的问题,你可以创建一个项目,并访问其数据库或驱动器尝试使用GoogleDrive。
您可以遵循Google Drive中的指导原则,该指导原则使用具有项目凭据访问权限的Google云端硬盘。
这个问题是关于谷歌云,但它适用于Tensorflow或任何文件可以用相同的想法共反演。
[样品]: