替换模型,重新识别改为更新数据不关闭弹窗,设备联调优化

This commit is contained in:
马增飞
2025-11-13 18:10:03 +08:00
parent 95e02d71de
commit 2003325724
18 changed files with 385 additions and 155 deletions
@@ -62,9 +62,13 @@ object FoodModule {
)
val outputTensor = module_mobile.forward(IValue.from(inputTensor)).toTensor()
val floatArray = outputTensor.dataAsFloatArray
if (bitmap.isRecycled.not()) {
bitmap.recycle()
}
// try {
// if (bitmap.isRecycled.not()) {
// bitmap.recycle()
// }
// } catch (e: Exception) {
// e.printStackTrace()
// }
return floatArray
}
@@ -107,7 +111,7 @@ object FoodModule {
fun getFoodScoreList(bitmap: Bitmap, queryCount: Int = 15): List<IdNameScore> {
val floatArray = bitmap2FloatArray(bitmap)
val nameScoreList = queryFoodNameScore(floatArray, queryCount)
val maxScoreList = nameScoreList.groupBy { it.name }.map { (_, value) -> value.maxByOrNull { it.score }!! }.toMutableList()
val maxScoreList = nameScoreList.groupBy { it.name }.map { (_, value) -> value.minByOrNull { it.score }!! }.toMutableList()
val map = mutableMapOf<String, Int>()
nameScoreList.forEach {
val key = it.name