Skip to content

Commit 5a20d9a

Browse files
Google AI Edge Gallerycopybara-github
authored andcommitted
Update model list screen to the new design.
Also update ux for multi-image message PiperOrigin-RevId: 791036851
1 parent 79d660e commit 5a20d9a

36 files changed

+1339
-927
lines changed

Android/src/app/src/main/java/com/google/ai/edge/gallery/data/Consts.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.ai.edge.gallery.data
1818

19+
import androidx.compose.ui.unit.dp
20+
1921
// Keys used to send/receive data to Work.
2022
const val KEY_MODEL_URL = "KEY_MODEL_URL"
2123
const val KEY_MODEL_NAME = "KEY_MODEL_NAME"
@@ -53,3 +55,6 @@ const val MAX_AUDIO_CLIP_DURATION_SEC = 30
5355

5456
// Audio-recording related consts.
5557
const val SAMPLE_RATE = 16000
58+
59+
// The size the icon shown under each of the model names in the model list screen.
60+
val MODEL_INFO_ICON_SIZE = 18.dp

Android/src/app/src/main/java/com/google/ai/edge/gallery/data/Model.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ data class Model(
9393
/** Whether the model is imported or not. */
9494
val imported: Boolean = false,
9595

96+
/* The task type ids that this model is best for. */
97+
val bestForTaskTypes: List<String> = listOf(),
98+
9699
// The following fields are managed by the app. Don't need to set manually.
97100
var normalizedName: String = "",
98101
var instance: Any? = null,

Android/src/app/src/main/java/com/google/ai/edge/gallery/data/ModelAllowlist.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ data class AllowedModel(
4040
val llmSupportImage: Boolean? = null,
4141
val llmSupportAudio: Boolean? = null,
4242
val estimatedPeakMemoryInBytes: Long? = null,
43+
val bestForTaskTypes: List<String>? = null,
4344
) {
4445
fun toModel(): Model {
4546
// Construct HF download url.
@@ -98,6 +99,7 @@ data class AllowedModel(
9899
learnMoreUrl = "https://huggingface.co/${modelId}",
99100
llmSupportImage = llmSupportImage == true,
100101
llmSupportAudio = llmSupportAudio == true,
102+
bestForTaskTypes = bestForTaskTypes ?: listOf(),
101103
)
102104
}
103105

Android/src/app/src/main/java/com/google/ai/edge/gallery/data/Tasks.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ val TASK_LLM_ASK_AUDIO =
112112
type = TaskType.LLM_ASK_AUDIO,
113113
icon = Icons.Outlined.Mic,
114114
models = mutableListOf(),
115-
// TODO(do not submit)
116115
description =
117116
"Instantly transcribe and/or translate audio clips using on-device large language models",
118117
docUrl = "https://ai.google.dev/edge/mediapipe/solutions/genai/llm_inference/android",
@@ -142,5 +141,11 @@ fun processTasks() {
142141
for (model in task.models) {
143142
model.preProcess()
144143
}
144+
// Move the model that is best for this task to the front.
145+
val bestModel = task.models.find { it.bestForTaskTypes.contains(task.type.id) }
146+
if (bestModel != null) {
147+
task.models.remove(bestModel)
148+
task.models.add(0, bestModel)
149+
}
145150
}
146151
}

Android/src/app/src/main/java/com/google/ai/edge/gallery/ui/common/ClickableLink.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import com.google.ai.edge.gallery.firebaseAnalytics
3939
import com.google.ai.edge.gallery.ui.theme.customColors
4040

4141
@Composable
42-
fun ClickableLink(url: String, linkText: String, icon: ImageVector) {
42+
fun ClickableLink(url: String, linkText: String, icon: ImageVector? = null) {
4343
val uriHandler = LocalUriHandler.current
4444
val annotatedText =
4545
AnnotatedString(
@@ -59,7 +59,9 @@ fun ClickableLink(url: String, linkText: String, icon: ImageVector) {
5959
)
6060

6161
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center) {
62-
Icon(icon, contentDescription = "", modifier = Modifier.size(16.dp))
62+
if (icon != null) {
63+
Icon(icon, contentDescription = "", modifier = Modifier.size(16.dp))
64+
}
6365
Text(
6466
text = annotatedText,
6567
textAlign = TextAlign.Center,

0 commit comments

Comments
 (0)