Skip to content

legendhimself/SafeSearch-Detection

Repository files navigation

SafeSearch-Detection

Description

This is a project to detect the safe search of an image. The detection can be done in three ways:

  1. AWS Rekognition
  2. Google Vision
  3. Free API (Tensorflow)

Note The free API is not ready yet.

The detection can be switched from the validation.controller.ts file. It is advised to use the AWS Rekognition as it is the most accurate, verbose and is directly integrated with AWS S3.

Project Structure

Producer

stateDiagram-v2
[*] --> apps
apps --> producer
producer --> src
producer --> test
src --> detection
detection --> image.service
src --> app.controller
src --> app.module
src --> app.service
src --> main
src --> tsconfig.app.json

test --> app.e2e.spec
test --> jeste2e.json

Validation

stateDiagram-v2
[*] --> apps
apps --> validation
validation --> src
src --> DetectionModules
DetectionModules --> aws
DetectionModules --> google
DetectionModules --> free
src --> deleteQueue
src --> validation.controller
src --> validation.module
src --> validation.service
src --> main
src --> tsconfig.app.json

Installation

  1. Clone the repository
git clone https://github.com/legendhimself/SafeSearch-Detection.git
  1. Install the requirements
yarn

Running the application


Add your .env file in the root directory

cp .env.example .env
# Edit the .env file

Note Download the Google Service Account Key for Cloud Vision and add it to the root directory and add the file name to .env credFileName=filename.json

Development


  1. Development both producer and validation
yarn start:dev
  1. Development only producer
yarn start:dev:producer
  1. Development only validation
yarn start:dev:validation

Production


  1. Build
yarn build
  1. Production only producer
yarn start:prod:producer
  1. Production only validation
yarn start:prod:validation

Testing the API

You can make request to the API using the following endpoints:

  • http://localhost:<port>/image/upload - To add an image to the to the s3 bucket. Requires URL of the image in the body. The above endpoint will return success and s3 responseURL. If the image is not safe, it will delete the image from the s3 bucket in a few seconds.

Note The RabbitMQ queue is of durable type, so if the validationService is not running, the messages will be stored in the queue and will be consumed when the validation service is up and running.

You can also test the API using the swagger UI at http://localhost:<port>/api

Testing with cli

Unit Testing

yarn test

End to End Testing

yarn start:dev:validation
# open new terminal
yarn test:e2e

Detection Strictness

AWS - You can change the strictness of the detection by changing the allowedSecondLevelLabels and allowedTopLevelLabels in the aws.ts file.

Google - You can change the strictness of the detection by changing the annotations in the google.ts file.

Todo:

  • Complete the Free API
  • Add more tests and e2e tests
  • Add more documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published