File tree Expand file tree Collapse file tree
app/src/main/kotlin/com/google/ai/sample Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ enum class ModelOption(
6060 " gemma-4-e4b-it" ,
6161 ApiProvider .GOOGLE ,
6262 " https://huggingface.co/litert-community/gemma-4-E4B-it-litert-lm/resolve/main/gemma-4-E4B-it.litertlm?download=true" ,
63+ supportsScreenshot = false ,
6364 isOfflineModel = true ,
6465 offlineModelFilename = " gemma-4-E4B-it.litertlm"
6566 ),
Original file line number Diff line number Diff line change @@ -345,21 +345,27 @@ class PhotoReasoningViewModel(
345345 )
346346 if (liteRtEngine == null ) {
347347 val liteRtBackend = if (backend == InferenceBackend .GPU ) Backend .GPU () else Backend .CPU ()
348- val visionBackend = if (currentModel.supportsScreenshot) Backend .GPU () else null
348+ val visionBackend = if (currentModel.supportsScreenshot) Backend .CPU () else null
349349 val audioBackend = null
350+ val cacheDir =
351+ if (modelFile.absolutePath.startsWith(" /data/local/tmp" )) {
352+ context.getExternalFilesDir(null )?.absolutePath
353+ } else {
354+ null
355+ }
350356 val engineConfig = EngineConfig (
351357 modelPath = modelFile.absolutePath,
352358 backend = liteRtBackend,
353359 visionBackend = visionBackend,
354360 audioBackend = audioBackend,
355361 maxNumTokens = null ,
356- cacheDir = context. cacheDir.absolutePath
362+ cacheDir = cacheDir
357363 )
358364 Log .i(
359365 TAG ,
360366 " Creating LiteRT engine with backend=$liteRtBackend , " +
361367 " visionBackend=$visionBackend , audioBackend=$audioBackend , " +
362- " cacheDir=${context. cacheDir.absolutePath} "
368+ " cacheDir=$cacheDir "
363369 )
364370 liteRtEngine = Engine (engineConfig).also { it.initialize() }
365371 Log .d(TAG , " Offline model initialized with LiteRT-LM Engine backend=$liteRtBackend " )
You can’t perform that action at this time.
0 commit comments