This is a project to detect the safe search of an image. The detection can be done in three ways:
- AWS Rekognition
- Google Vision
- 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.
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
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
- Clone the repository
git clone https://github.com/legendhimself/SafeSearch-Detection.git
- Install the requirements
yarn
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 both producer and validation
yarn start:dev
- Development only producer
yarn start:dev:producer
- Development only validation
yarn start:dev:validation
- Build
yarn build
- Production only producer
yarn start:prod:producer
- Production only validation
yarn start:prod:validation
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
yarn test
yarn start:dev:validation
# open new terminal
yarn test:e2e
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.
- Complete the Free API
- Add more tests and e2e tests
- Add more documentation