Skip to content
This repository was archived by the owner on Apr 8, 2023. It is now read-only.

Commit 7f54e3c

Browse files
committed
移除采样过程中的水平旋转、移除opencv库,修复:https://github.com/devzwy/open_nsfw_android/issues/4#issuecomment-494745262
1 parent 6a012d8 commit 7f54e3c

File tree

162 files changed

+103
-35341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+103
-35341
lines changed

.idea/gradle.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,22 @@ __请添加__
4747
nsfwBean?.nsfw ...
4848
```
4949

50-
- 项目打包时请使用如下代码确定你使用的ndk,否则会打包全部类型的库文件,导致项目异常庞大
51-
```
52-
ndk {
53-
abiFilters 'armeabi-v7a'
54-
}
55-
```
56-
### [点我下载apk(arm+x86)](https://fir.im/nsfw)
50+
### [点我下载apk](https://fir.im/nsfw)
5751

5852
### 扫码下载
5953

6054
![图片](https://github.com/devzwy/open_nsfw_android/blob/master/img/2.png)
6155

56+
### Demo运行结果:
57+
## 提示:下面的图片不要在公共场所打开!!!
58+
6259
## 提示:下面的图片不要在公共场所打开!!!
60+
61+
## 提示:下面的图片不要在公共场所打开!!!
62+
6363
## 提示:下面的图片不要在公共场所打开!!!
64+
6465
## 提示:下面的图片不要在公共场所打开!!!
6566

66-
### Demo运行结果(后期手动打码防止屏蔽):
6767

6868
![图片](https://github.com/devzwy/open_nsfw_android/blob/master/img/1.png)

app/build.gradle

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,16 @@ android {
1010
applicationId "com.example.open_nsfw_android"
1111
minSdkVersion 15
1212
targetSdkVersion 28
13-
versionCode 2
14-
versionName "1.1"
13+
versionCode 3
14+
versionName "1.2.6"
1515
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16-
ndk {
17-
abiFilters 'armeabi-v7a','x86_64'
18-
}
1916
}
2017
buildTypes {
2118
debug{
2219
minifyEnabled false //开启混淆
2320
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2421
}
2522
}
26-
2723
aaptOptions {
2824
noCompress "tflite"
2925
}

app/src/main/java/com/example/open_nsfw_android/MainActivity.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.example.open_nsfw_android
22

3+
import android.Manifest
34
import android.annotation.SuppressLint
45
import android.content.Intent
56
import android.content.pm.PackageManager
67
import android.graphics.BitmapFactory
78
import android.os.Bundle
9+
import android.support.v4.app.ActivityCompat
10+
import android.support.v4.content.ContextCompat
811
import android.support.v7.app.AppCompatActivity
912
import android.support.v7.widget.LinearLayoutManager
1013
import android.view.View
@@ -32,6 +35,11 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
3235
initAdapter()
3336
initClickListener()
3437
tv_version.text = "当前版本:${this.packageManager.getPackageInfo(packageName, 0).versionName}"
38+
if (ContextCompat.checkSelfPermission(this,
39+
Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){ //表示未授权时
40+
//进行授权
41+
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),1);
42+
}
3543
}
3644

3745
override fun onClick(v: View) {

app/src/main/java/com/example/open_nsfw_android/MainAdapter.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@ class MainAdapter(nsfwList: List<MyNsfwBean>?) :
1616
val textView = helper.getView<TextView>(R.id.tv_text)
1717
val imageView = helper.getView<ImageView>(R.id.iv)
1818
val view = helper.getView<RelativeLayout>(R.id.view)
19-
var nsfwStr = "色情图片"
2019
var color = ContextCompat.getColor(mContext, R.color.nsfw1)
2120
when (item.nsfw) {
22-
in 0.0..0.3 -> {
23-
nsfwStr = "正常图片"
21+
in 0.0..0.2 -> {
2422
color = ContextCompat.getColor(mContext, R.color.nsfw3)
2523
}
26-
in 0.3..0.6 -> {
27-
nsfwStr = "👙比基尼"
24+
in 0.2..0.8 -> {
2825
color = ContextCompat.getColor(mContext, R.color.nsfw2)
2926
}
3027
}
3128
textView.text =
32-
"path = ${"img/${item.path}"} \n\nSFW score: ${item.sfw}\nNSFW score: ${item.nsfw} \n\n 鉴定结果: ${nsfwStr}"
29+
"path = ${"img/${item.path}"} \n\nSFW score: ${item.sfw}\n\nNSFW score: ${item.nsfw}"
3330
imageView.setImageBitmap(item.bitmap)
3431
view.setBackgroundColor(color)
3532
}

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
android:orientation="vertical"
55
android:layout_width="match_parent"
6+
67
android:layout_height="match_parent">
78
<LinearLayout android:layout_width="match_parent"
89
android:orientation="horizontal"

app/src/main/res/values/colors.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<color name="colorPrimary">#008577</color>
44
<color name="colorPrimaryDark">#00574B</color>
55
<color name="semi_transparent">#66000000</color>
6-
<color name="nsfw1">#56FF0000</color>
7-
<color name="nsfw2">#20FD9904</color>
8-
<color name="nsfw3">#FFFFFF</color>
9-
<color name="colorAccent">#D81B60</color>
6+
<color name="nsfw1">#96CC1B1B</color>
7+
<color name="nsfw2">#00BCD4</color>
8+
<color name="nsfw3">#4CAF50</color>
9+
<color name="colorAccent">#FF0000</color>
1010
</resources>

nsfw/CMakeLists.txt

Lines changed: 0 additions & 44 deletions
This file was deleted.

nsfw/build.gradle

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,12 @@ apply plugin: 'com.android.library'
33
android {
44
compileSdkVersion 28
55

6-
76
defaultConfig {
87
minSdkVersion 15
98
targetSdkVersion 28
109
versionCode 1
1110
versionName "1.0"
12-
1311
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14-
externalNativeBuild {
15-
cmake {
16-
cppFlags "-frtti -fexceptions"
17-
}
18-
}
19-
// ndk {
20-
// abiFilters 'armeabi-v7a'
21-
// }
2212
}
2313

2414
buildTypes {
@@ -27,41 +17,14 @@ android {
2717
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2818
}
2919
}
30-
31-
externalNativeBuild {
32-
cmake {
33-
path "CMakeLists.txt"
34-
}
35-
}
36-
37-
sourceSets {
38-
main {
39-
jniLibs.srcDirs = ['libs']
40-
assets.srcDir("main/assets")
41-
}
42-
}
43-
4420
}
4521

4622
dependencies {
4723
implementation fileTree(dir: 'libs', include: ['*.jar'])
48-
4924
implementation 'com.android.support:appcompat-v7:28.0.0'
5025
testImplementation 'junit:junit:4.12'
5126
androidTestImplementation 'com.android.support.test:runner:1.0.2'
5227
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
5328
implementation 'org.tensorflow:tensorflow-lite:+'
5429
implementation 'org.tensorflow:tensorflow-lite-gpu:+'
55-
implementation project(path: ':openCVLibrary340')
56-
}
57-
58-
task nativeLibsToJar(type: Jar, description: 'create a jar archive of the native libs') {
59-
destinationDir file("$buildDir/native-libs")
60-
baseName 'native-libs'
61-
from fileTree(dir: 'libs', include: '**/*.so')
62-
into 'lib/'
63-
}
64-
tasks.withType(JavaCompile) {
65-
compileTask -> compileTask.dependsOn(nativeLibsToJar)
66-
// implementation project(path: ':openCVLibrary340')
67-
}
30+
}

0 commit comments

Comments
 (0)