我正在尝试使用以下代码将 Keras hdf5 文件转换为 TensorFlow Lite 文件:
import tensorflow as tf
# Convert the model.
converter = tf.lite.TFLiteConverter.from_keras_model("/content/best_model_11class.hdf5")
tflite_model = converter.convert()
# Save the TF Lite model.
with tf.io.gfile.GFile('model.tflite', 'wb') as f:
f.write(tflite_model)
Run Code Online (Sandbox Code Playgroud)
我收到此错误from_keras_model:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-14-26467c686751> in <module>()
2
3 # Convert the model.
----> 4 converter = tf.lite.TFLiteConverter.from_keras_model("/content/best_model_11class.hdf5")
5 tflite_model = converter.convert()
6
/usr/local/lib/python3.6/dist-packages/tensorflow/lite/python/lite.py in from_keras_model(cls, model)
426 # to None.
427 # Once we have better support for dynamic shapes, …Run Code Online (Sandbox Code Playgroud) 尝试执行以下操作:
import tensorflow as tf
from keras.models import load_model, Model
from keras import backend as K
sess = tf.compat.v1.Session()
K.set_session(sess)
Run Code Online (Sandbox Code Playgroud)
当我在 Google Colab 中运行它时,我得到:
RuntimeError: `set_session` is not available when using TensorFlow 2.0.
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这一问题?
我使用 Firebase 允许用户使用其 Facebook 帐户或 Google 帐户登录。我已允许在同一电子邮件地址下创建多个帐户。
这是使用 Facebook 帐户成功登录后将用户发送到下一个屏幕的方法:
private void handleFacebookAccessToken(AccessToken token) {
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Intent intent = new Intent(MainActivity.this, Profile.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
overridePendingTransition(0, 0);
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
如果用户使用 Google 帐户登录,则可以使用以下方法将其发送到下一个屏幕:
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Intent intent = new …Run Code Online (Sandbox Code Playgroud)