flutter_nude_checker 1.0.1 copy "flutter_nude_checker: ^1.0.1" to clipboard
flutter_nude_checker: ^1.0.1 copied to clipboard

A new Flutter plugin for checking nude images with mobile gpu acceleration.

Flutter Nude Photo Checker - A Flutter Package for Detecting Nude Images #

Flutter License

The flutter_nude_checker package provides a simple way to detect nude images in Flutter apps. It uses the yahoo open_nsfw model to detect nude images. The model is able to detect nudity with better accuracy.

Features #

  • Detect nude images in Flutter apps
  • Detect nudity with GPU acceleration
  • Detect nudity in images from the internet or from the device's gallery

Installation #

  1. Add this package to your pubspec.yaml file:

    dependencies:
      flutter_nude_checker: ^1.0.0
    
  2. Run flutter pub get to install the package.

Usage #

Download the tflite model from here and add it to the assets folder of your project. Then, add the following code to your project to detect nude images:

  Future<void> _getNSFWScore() async {
    
    final modelPath = await getModelPath("nsfw.tflite");

    final picker = ImagePicker();
    try {
      final XFile? image = await picker.pickImage(source: ImageSource.gallery); // You can also use ImageSource.camera for the camera
      if (image != null) {
        final nsfwScore =
            await FlutterNudeChecker.getNSFWScore(image.path, modelPath);
        print("NSFW Score: ${nsfwScore.nsfwScore}");
       
      } else {
        print("No image selected.");
      }
    } catch (e) {
      print("Error: $e");
    }
  }

Add the getModelPath function to your project:

Future<String> getModelPath(String assetName) async {
    // Get the temporary directory
    final tempDir = await getTemporaryDirectory();

    // Create a new file in the temporary directory
    final file = File('${tempDir.path}/$assetName');

    // Write the asset content to the new file
    final assetData = await rootBundle.load('assets/$assetName');
    final bytes = assetData.buffer.asUint8List();
    await file.writeAsBytes(bytes, flush: true);

    // Return the file path
    return file.path;
  }

For more detailed usage and customization options, please refer to the documentation.

Contributing #

We welcome contributions! If you have any ideas, bug fixes, or improvements, please open an issue or submit a pull request on our GitHub repository.

TODO #

  • Add support for Android
  • Add support for iOS

License #

This package is available under the MIT License. See the LICENSE file for more details.

About #

This package is developed and maintained by MD. SHAHIDUL ISLAM.

If you have any questions or need assistance, feel free to contact us at shahidul1425@cseku.ac.bd.