Created
March 15, 2024 22:25
-
-
Save st235/b87c7c125597ddea7092be13d5d33bc6 to your computer and use it in GitHub Desktop.
Check assets file exists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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