Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.0 Release #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Example/NSFWDetector.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = LOVOO;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
Expand All @@ -235,6 +235,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -313,7 +314,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-NSFWDetector_Example/Pods-NSFWDetector_Example-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-NSFWDetector_Example/Pods-NSFWDetector_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/NSFWDetector/NSFWDetector.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -322,7 +323,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-NSFWDetector_Example/Pods-NSFWDetector_Example-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-NSFWDetector_Example/Pods-NSFWDetector_Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -381,6 +382,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand All @@ -399,6 +401,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -424,7 +427,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -437,6 +440,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand All @@ -455,6 +459,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -473,7 +478,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -41,6 +41,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "NSFWDetector_Example.app"
BlueprintName = "NSFWDetector_Example"
ReferencedContainer = "container:NSFWDetector.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -53,17 +62,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "NSFWDetector_Example.app"
BlueprintName = "NSFWDetector_Example"
ReferencedContainer = "container:NSFWDetector.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -85,8 +83,6 @@
ReferencedContainer = "container:NSFWDetector.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
2 changes: 1 addition & 1 deletion Example/NSFWDetector/CameraViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CameraViewController: UIViewController, AVCaptureVideoDataOutputSampleBuff
}

private func didDetectNSFW(confidence: Float) {
if confidence > 0.8 {
if confidence > 0.9 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you arrive at 0.9 here? Experimental? I feel like that's still a bit on the maybe-side and would increase to 0.95.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it depends on the content of course. And for the camera demo I think it works quite great, because most people won't gonna strip completely naked to try it out :D

Upon some "personal testing" I found this version of the model to be suboptimal at detecting male genitals. My guess is that the training data set is biased, because whenever there is a male genital, there is also a woman in the training images.

So I will try it out some more and try to improve it for that use case

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should! That's the use case we're most interested in after all, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's why I tested it ;)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with @leberwurstsaft – it is the use case for us.
A super small sample of the linked training data also left me with the impression that the model could have a weakness in that regard.

Also, in the nudity files there seem to be a lot of textual overlays in the corners. The model might have a tendency to flag stuff as nude if there is text in a corner. But that shouldn’t be big of a problem as long as it doesn’t influence the amount of false-negatives too.

self.subsequentPositiveDetections += 1

guard self.subsequentPositiveDetections > 3 else {
Expand Down
4 changes: 2 additions & 2 deletions Example/NSFWDetector/ImageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class ImageViewController: UIViewController {
self.blurView.layer.cornerRadius = 10.0
self.blurView.clipsToBounds = true

guard let image = self.image else {
guard let image = self.image, let cgImage = image.cgImage else {
self.nsfwLabel.text = "No Image selected."
return
}

self.imageView.image = image

NSFWDetector.shared.check(image: image) { result in
NSFWDetector.shared.check(cgImage: cgImage) { result in
switch result {
case .error:
self.nsfwLabel.text = "Detection failed"
Expand Down
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- NSFWDetector (1.1.0)
- NSFWDetector (2.0.0)

DEPENDENCIES:
- NSFWDetector (from `../`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
NSFWDetector: 5158164f5e716652aa61cfa92dc7b252a6883415
NSFWDetector: 6847237b1f515548fce78027274d85ee37fa390a

PODFILE CHECKSUM: f9a9c6821210dfbaf2efbedd233ddc769e77db55

COCOAPODS: 1.5.3
COCOAPODS: 1.10.2
12 changes: 7 additions & 5 deletions Example/Pods/Local Podspecs/NSFWDetector.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading