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
Add this line to your application's Gemfile:
gem'sightengine'And then execute:
$ bundle
Or install it yourself as:
$ gem install sightengine
require'sightengine'client=Sightengine::Client.new(api_user: 'your api user',api_secret: 'your api secret')response=client.nudity("https://sightengine.com/assets/img/examples/example2.jpg")response.raw_nudity?# falseresponse.partial_nudity?# falseresponse.safe?# trueresponse=client.face_attributes("https://sightengine.com/assets/img/examples/example7.jpg")response.get_faces.length# 1face=response.get_faces.firstface.female?# trueface.male?# trueface.minor?# falseface.coordinates# [x1, y1, x2, y2] = [0.5156, 0.1936, 0.6922, 0.6207]response=client.scam("https://d3m9459r9kwism.cloudfront.net/img/examples/example-scam1-1000.jpg")response.scam?# trueresponse=client.celebrities("https://sightengine.com/assets/img/examples/example-craig-300.jpg")response.celebrity?# trueresponse.celebrities# [{"name"=>"Daniel Craig", "prob"=>0.99}, {"name"=>"Graham Fellows", "prob"=>0.08}, ...]response=client.wad("https://sightengine.com/assets/img/examples/example2.jpg")response.weapon?response.drugs?response.alcohol?# Detect nudity, scammers and celebrities in pictureresponse=client.check("https://d3m9459r9kwism.cloudfront.net/img/examples/example-scam1-1000.jpg",[Sightengine::NUDITY,Sightengine::SCAM,Sightengine::CELEBRITIES])response.raw_nudity?# falseresponse.scam?# trueresponse.celebrity?# falseAfter 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.
Bug reports and pull requests are welcome on GitHub at https://github.com/leoht/sightengine.
The gem is available as open source under the terms of the MIT License.