优化
This commit is contained in:
@@ -137,12 +137,14 @@ object FoodModule {
|
||||
}
|
||||
suspend fun getFoodScoreList(bitmap: Bitmap, queryCount: Int = 15): List<IdNameScore> {
|
||||
val floatArray = bitmap2FloatArray(bitmap, false) ?: return emptyList()
|
||||
Timber.tag("FoodModule").d("向量:${floatArray.toJsonString()}")
|
||||
val nameScoreList = queryFoodNameScore(floatArray, queryCount)
|
||||
if (nameScoreList.isEmpty()) {
|
||||
return emptyList()
|
||||
}
|
||||
//暂时不过滤
|
||||
val maxScoreList = nameScoreList
|
||||
.filter { it.score < 0.15 }
|
||||
//.filter { it.score < 0.15 }
|
||||
.groupBy { it.name }
|
||||
.map { (_, value) -> value.minByOrNull { it.score }!! }
|
||||
.toMutableList()
|
||||
|
||||
@@ -177,11 +177,12 @@ object ObjectBox {
|
||||
}
|
||||
|
||||
suspend fun filter(name:String?) = safeDbOp {
|
||||
var list = getBox<Food>()?.all?.distinctBy { it.name }
|
||||
val list = getBox<Food>()?.all?.distinctBy { it.name }
|
||||
if (name.isNullOrBlank().not()) {
|
||||
list?.filter { it.name?.contains(name!!) == true }
|
||||
}
|
||||
list?:emptyList()
|
||||
list?.filter { it.name?.contains(name) == true }
|
||||
} else {
|
||||
list
|
||||
}?:emptyList()
|
||||
}
|
||||
|
||||
suspend fun remove(name:String) = safeDbOp {
|
||||
|
||||
Reference in New Issue
Block a user