Skip to content

Commit

Permalink
add MTCNN for face detection (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
thebino committed Aug 24, 2023
1 parent 77e11ae commit 3afe54c
Show file tree
Hide file tree
Showing 27 changed files with 957 additions and 15 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/continuous-delivery-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ jobs:
- name: Build release bundle
run: |
./gradlew --console=plain -PreleaseKeystore=${{ steps.decode_keystore.outputs.filePath }} -PreleaseStorePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }} -PreleaseKeyAlias=${{ secrets.ANDROID_KEYSTORE_KEY_ALIAS }} -PreleaseKeyPassword=${{ secrets.ANDROID_KEYSTORE_KEY_PASSWORD }} app:bundle
./gradlew --console=plain -PreleaseKeystore=${{ steps.decode_keystore.outputs.filePath }} -PreleaseStorePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }} -PreleaseKeyAlias=${{ secrets.ANDROID_KEYSTORE_KEY_ALIAS }} -PreleaseKeyPassword=${{ secrets.ANDROID_KEYSTORE_KEY_PASSWORD }} app:bundle app:assemble
- name: Publish release bundle
run: fastlane android deploy --verbose
Expand All @@ -322,3 +322,8 @@ jobs:
name: assets
path: |
${{ github.workspace }}/app/build/outputs/bundle/release
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/app/build/outputs/apk/release
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ android {
targetSdk = libs.versions.compileSdk.get().toInt()
// versionCode will be set manually on each release
versionCode = 9999
versionName = "0.1.0"
versionName = "0.2.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package photos.network.domain.photos

import org.koin.dsl.module
import photos.network.domain.photos.usecase.GetFacesUseCase
import photos.network.domain.photos.usecase.GetPhotoUseCase
import photos.network.domain.photos.usecase.GetPhotosUseCase
import photos.network.domain.photos.usecase.StartPhotosSyncUseCase
Expand All @@ -28,6 +29,13 @@ val domainPhotosModule = module {
)
}

factory {
GetFacesUseCase(
application = get(),
photoRepository = get(),
)
}

factory {
GetPhotoUseCase(
photoRepository = get(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2020-2023 Photos.network developers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package photos.network.domain.photos.usecase

import android.app.Application
import android.graphics.Bitmap
import android.net.Uri
import android.provider.MediaStore
import kotlinx.coroutines.flow.Flow
import photos.network.repository.photos.PhotoRepository
import photos.network.repository.photos.model.Box

class GetFacesUseCase(
private val application: Application,
private val photoRepository: PhotoRepository,
) {
operator fun invoke(photoUri: Uri): Flow<List<Box>> {
val bitmap: Bitmap = MediaStore.Images.Media.getBitmap(application.contentResolver, photoUri)
return photoRepository.getFaces(bitmap = bitmap)
}
}
7 changes: 7 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/102.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## [0.1.0] - 2023-08-17

### Added

- Fastlane for F-Droid deployment
7 changes: 7 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/103.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## [0.2.0] - 2023-08-24

### Added

- Added machine learning (MTCNN) to detect faces in photos
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ ktor = "2.1.1"
junit-junit = "4.13.2"
androidx-arch-core = "2.1.0"
truth = "1.1.3"
tensorflow-android = "1.13.1"


[libraries]
Expand Down Expand Up @@ -165,6 +166,8 @@ com-google-android-material = { group = "com.google.android.material", name = "m

security-crypto = { group = "androidx.security", name = "security-crypto", version.ref = "androidx-security-crypto" }

tensorflow-android = { group = "org.tensorflow", name = "tensorflow-android", version.ref = "tensorflow-android" }

coil = { group = "io.coil-kt", name = "coil", version.ref = "coil-kt" }
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil-kt" }

Expand Down
2 changes: 2 additions & 0 deletions repository/photos/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ dependencies {
implementation(projects.api)
api(projects.database.photos)

implementation(libs.tensorflow.android)

testImplementation(libs.mockk)
testImplementation(libs.junit.junit)
testImplementation(libs.truth)
Expand Down
Binary file not shown.
Loading

0 comments on commit 3afe54c

Please sign in to comment.