小编ADe*_*Dev的帖子

如何在flutter应用程序中使用tflite模型的预测功能

我有一个模型,可以通过对此处的一组数字执行预测函数来检测糖尿病

model1 = Sequential()
model1.add(Dense(500, input_dim=8, activation='sigmoid'))
model1.add(Dense(100, activation='sigmoid'))
model1.add(Dense(2, activation='softmax'))
model1.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
model1.fit(x_train,y_train, epochs=1000, batch_size=70, validation_data=(x_test, y_test))
    

y_pred= model1.predict(x_test)
y_pred_prob = model1.predict_proba(x_test)

 

#s=round(b[0,0])

keras_file = "diabetes.h5"
keras.models.save_model(model1, keras_file)

converter = tf.lite.TFLiteConverter.from_keras_model_file(keras_file)

tflite_model = converter.convert()
open("diabetes.tflite", "wb").write(tflite_model)

#print(model.predict(np.array([[1,85,66,29,0,26.6,0.351,31]])))
Run Code Online (Sandbox Code Playgroud)

我已将模型转换为 tflite 文件并将其添加到 flutter 应用程序中,现在我想(model.pretict())在 main.c 中使用预测函数。dart in flutter 所以我添加了 tflite 文件并导入了 main.dart

 @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController Pregnancies = new TextEditingController();
  TextEditingController Glucose = new TextEditingController();
  TextEditingController BloodPressure = new TextEditingController(); …
Run Code Online (Sandbox Code Playgroud)

deep-learning flutter tensorflow-lite

5
推荐指数
0
解决办法
1045
查看次数

Flutter:无法加载资源

我无法将图像作为背景上传到容器,我已将图像添加到资产文件夹中并将其添加到 pubspec.yaml 并向我显示该错误:

I/flutter ( 6664): ??? EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ?????????????????????????????????????????????????????
I/flutter ( 6664): The following assertion was thrown resolving an image codec:
I/flutter ( 6664): Unable to load asset: assets/images/img.png
I/flutter ( 6664): 
I/flutter ( 6664): When the exception was thrown, this was the stack:
I/flutter ( 6664): #0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)
I/flutter ( 6664): <asynchronous suspension>
I/flutter ( 6664): #1      AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:484:44)
I/flutter ( 6664): #2      AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:469:14)
I/flutter ( 6664): #3      ImageProvider.resolve.<anonymous closure>.<anonymous closure>.<anonymous closure> …
Run Code Online (Sandbox Code Playgroud)

assets dart android-studio flutter

3
推荐指数
2
解决办法
2万
查看次数

无法找到合适的 Visual Studio 工具链。请运行“颤振医生”以获取更多详细信息

我正在尝试在 Visual Studio 2019 中创建和运行 Flutter 桌面应用程序,我已经下载了所需的文件(MSBuild 和 MSVC),但仍然出现错误。我使用的是 2013 版并卸载了它并安装了 2019 版,并且所有内容都已更新

当我运行 flutter run 命令时会发生这种情况

Launching lib\main.dart on Windows in debug mode...
Unable to find suitable Visual Studio toolchain. Please run `flutter doctor` for more details.
Run Code Online (Sandbox Code Playgroud)

当我运行 flutter 医生给我这个错误

[!] Visual Studio - develop for Windows (Visual Studio Community 2019 16.4.5)
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop
      development with C++" workload, and include these components:
        MSBuild
        MSVC v142 …
Run Code Online (Sandbox Code Playgroud)

visual-studio flutter-desktop

3
推荐指数
6
解决办法
6890
查看次数