0.01
No release in over 3 years
Low commit activity in last 3 years
Unofficial wrapper for the Sightengine API which provides image moderation including nudity detection, scammer detection, face attributes, and more.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 10.0
~> 3.0
~> 3.0

Runtime

 Project Readme

Sightengine

Unofficial wrapper for the Sightengine API which provides image moderation including nudity detection, scammer detection, face attributes, and more.

Official API docs can be found here: https://sightengine.com/docs/reference

Installation

Add this line to your application's Gemfile:

gem 'sightengine'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sightengine

Usage

Configuration

require 'sightengine'

client = Sightengine::Client.new(
  api_user: 'your api user',
  api_secret: 'your api secret'
)

Nudity check

response = client.nudity("https://sightengine.com/assets/img/examples/example2.jpg")

response.raw_nudity? # false
response.partial_nudity? # false
response.safe? # true

Face attributes

response = client.face_attributes("https://sightengine.com/assets/img/examples/example7.jpg")

response.get_faces.length # 1
face = response.get_faces.first

face.female? # true
face.male? # true
face.minor? # false
face.coordinates # [x1, y1, x2, y2] = [0.5156, 0.1936, 0.6922, 0.6207]

Scam detection

response = client.scam("https://d3m9459r9kwism.cloudfront.net/img/examples/example-scam1-1000.jpg")

response.scam? # true

Celebrities detection

response = client.celebrities("https://sightengine.com/assets/img/examples/example-craig-300.jpg")

response.celebrity? # true
response.celebrities # [{"name"=>"Daniel Craig", "prob"=>0.99}, {"name"=>"Graham Fellows", "prob"=>0.08}, ...]

Weapons, alcohol and drugs (WAD)

response = client.wad("https://sightengine.com/assets/img/examples/example2.jpg")

response.weapon?
response.drugs?
response.alcohol?

Multi-models check

# Detect nudity, scammers and celebrities in picture
response = client.check("https://d3m9459r9kwism.cloudfront.net/img/examples/example-scam1-1000.jpg", [
    Sightengine::NUDITY,
    Sightengine::SCAM,
    Sightengine::CELEBRITIES
])

response.raw_nudity? # false
response.scam? # true
response.celebrity? # false

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/leoht/sightengine.

License

The gem is available as open source under the terms of the MIT License.