task downloadModelFile(type: Download) {
    src 'https://storage.googleapis.com/download.tensorflow.org/models/tflite/task_library/object_detection/android/lite-model_ssd_mobilenet_v1_1_metadata_2.tflite'
    dest project.ext.ASSET_DIR + '/mobilenetv1.tflite'
    overwrite false
}

task downloadModelFile0(type: Download) {
    src 'https://storage.googleapis.com/download.tensorflow.org/models/tflite/task_library/object_detection/android/lite-model_efficientdet_lite0_detection_metadata_1.tflite'
    dest project.ext.ASSET_DIR + '/efficientdet-lite0.tflite'
    overwrite false
}

task downloadModelFile1(type: Download) {
    src 'https://storage.googleapis.com/download.tensorflow.org/models/tflite/task_library/object_detection/android/lite-model_efficientdet_lite1_detection_metadata_1.tflite'
    dest project.ext.ASSET_DIR + '/efficientdet-lite1.tflite'
    overwrite false
}

task downloadModelFile2(type: Download) {
    src 'https://storage.googleapis.com/download.tensorflow.org/models/tflite/task_library/object_detection/android/lite-model_efficientdet_lite2_detection_metadata_1.tflite'
    dest project.ext.ASSET_DIR + '/efficientdet-lite2.tflite'
    overwrite false
}

task copyTestModel(type: Copy, dependsOn: downloadModelFile) {
    from project.ext.ASSET_DIR + '/mobilenetv1.tflite'
    into project.ext.TEST_ASSETS_DIR
}

preBuild.dependsOn downloadModelFile, downloadModelFile0, downloadModelFile1, downloadModelFile2,
        copyTestModel