Skip to content

Instantly share code, notes, and snippets.

@st235
Created March 15, 2024 22:25
Show Gist options
  • Save st235/b87c7c125597ddea7092be13d5d33bc6 to your computer and use it in GitHub Desktop.
Save st235/b87c7c125597ddea7092be13d5d33bc6 to your computer and use it in GitHub Desktop.
Check assets file exists
Build file '/Downloads/11_ObjectDetection/app/build.gradle' line: 57
Could not determine the dependencies of task ':app:preBuild'.
> Could not create task ':app:assertModelsAreInAssets'.
> Cannot find yolov5s-fp16.tflite. Please, check your assets folder.
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
apply plugin: 'com.android.application'
...
apply from: './utils.gradle'
android {
...
}
repositories {
...
}
tasks.register('assertModelsAreInAssets') {
def models = [
'yolov5s-fp16.tflite',
'tflite_graph.tflite',
'frozen_inference_graph.pb',
'fasterrcnn_inception_optimized.pb',
'yolov5s.torchscript.ptl',
'deeplabv3_1_default_1.tflite',
]
for (model in models) {
if (!isAssetFileExists(model)) {
throw new GradleException("Cannot find ${model}. Please, check your assets folder.")
}
}
}
preBuild.dependsOn 'assertModelsAreInAssets'
dependencies {
...
}
ext.isAssetFileExists = { assetName ->
def assetFile = file("${rootDir}/app/src/main/assets/${assetName}")
return assetFile.exists()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment