Git Product home page Git Product logo

client-php's Introduction

About

Use the Sightengine Moderation API to instantly moderate images and videos. See http://sightengine.com for more information.

Before starting, please make sure you have created an account on https://sightengine.com

Install

composer require sightengine/client-php

Initialize the client

You will need your API USER and API SECRET to initialize the client. You can find both of them on your Sightengine account.

use \Sightengine\SightengineClient;

$client = new SightengineClient('{api_user}', '{api_secret}');

Moderate an image

The API accepts both standard still images: JPEG, PNG, WEBP etc. and multi-frame GIF images.

Several moderation engines are available for you to choose from (nudity detection, inappropriate content detection etc...). Please refer to the documentation for more.

Moderate an image through a public URL:

# Detect nudity in an image

$output = $client->check(['nudity'])->set_url('http://img09.deviantart.net/2bd0/i/2009/276/c/9/magic_forrest_wallpaper_by_goergen.jpg')

# Detect nudity, weapons, alcohol, drugs, likely fruadulant users, celebrities and faces in an image, along with image properties and type
$output = $client->check(['nudity', 'type', 'properties', 'wad', 'face', 'scam', 'celebrity'])->set_url('http://img09.deviantart.net/2bd0/i/2009/276/c/9/magic_forrest_wallpaper_by_goergen.jpg')

Moderate a local image:

# Detect nudity in an image
$output = $client->check(['nudity'])->set_file('/full/path/to/image.jpg')

# Detect nudity, weapons, alcohol, drugs and faces in an image, along with image properties and type
$output = $client->check(['nudity', 'type', 'properties', 'wad', 'face'])->set_file('/full/path/to/image.jpg')

Moderate a binary image:

# Detect nudity in an image
$output = $client->check(['nudity'])->set_bytes($binary_image)

# Detect nudity, weapons, alcohol, drugs and faces in an image, along with image properties and type
$output = $client->check(['nudity', 'type', 'properties', 'wad', 'face'])->set_bytes($binary_image)

Video and Stream Moderation

You can perform either synchronous or asynchronous Video Moderation.

  • Synchronous Moderation is simple and easy: the Moderation result is provided directly in the reponse to your API request. Synchronous Moderation is only available for videos that are less than 1 minute long.
  • Asynchronous Moderation is available for any video or stream. Moderation results are provided through a so-called callback mechanism. You define a callback URL and the Moderation Engine will send back moderation events to that URL in realtime.

Synchronous Video Moderation

Beware: this is only for videos that have a duration below 1 minute.

$client->check(['nudity', 'wad'])->video_sync('https://sightengine.com/assets/stream/examples/funfair.mp4')

Asynchronous Video Moderation

The first step to moderate a video stream is to submit the video stream to the API, along with a callback URL.

$client->check(['nudity', 'wad'])->video('https://sightengine.com/assets/stream/examples/funfair.mp4', 'https://example.com/yourcallback')

Once you have submitted the video, the API will start POSTing moderation updates to your callback URL.

Please see our Documentation for more details.

Feedback

In order to report a misclassification, you need to report the image that was misclassified, the model that was run on this image (models are nudity, face, type, wad), and the correct class of the image.

For each model, there are different classes that you may report. Here are the details:

The nudity model has 3 classes:

  • raw: corresponding to raw nudity
  • partial: corresponding to partial nudity
  • safe: corresponding to no nudity

The face model has 3 classes:

  • none
  • single
  • multiple

The type model has 2 classes:

  • photo
  • illustration

The wad model has 3 classes:

  • no-weapons
  • weapons
  • no-alcohol
  • alcohol
  • no-drugs
  • drugs
$client->feedback(model, class,image)

Example of feedback on a local image:

$client->feedback("nudity","safe", "/full/path/to/image.jpg")
$client->feedback("type","illustration", "/full/path/to/image.jpg")
$client->feedback("nudity","raw", "/full/path/to/image.jpg")

Example of feedback through a public URL::

$client->feedback("nudity","safe", "http://img09.deviantart.net/2bd0/i/2009/276/c/9/magic_forrest_wallpaper_by_goergen.jpg")
$client->feedback("type","illustration", "http://img09.deviantart.net/2bd0/i/2009/276/c/9/magic_forrest_wallpaper_by_goergen.jpg")
$client->feedback("nudity","raw", "http://img09.deviantart.net/2bd0/i/2009/276/c/9/magic_forrest_wallpaper_by_goergen.jpg")

client-php's People

Contributors

davidlis avatar rlmckenney avatar vesper8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

client-php's Issues

composer error in Laravel 9

Tried to install this package in Laravel 9 with composer and got the following error:

Problem 1 - Root composer.json requires sightengine/client-php ^1.3 -> satisfiable by sightengine/client-php[1.3]. - sightengine/client-php 1.3 requires guzzlehttp/guzzle ~6.0 -> found guzzlehttp/guzzle[6.0.0, ..., 6.5.x-dev] but it conflicts with your root composer.json require (^7.2).

Seems to be a problem with the requirement of Guzzle (7.0 by the package / 7.2 by Laravel).

Could you please update the package to make it compatible with the newest Laravel version. Thanks.

guzzlehttp requirement

The requirement for guzzlehttp is out of dated and conflicting with newer packages with composer.

Uncaught Error: Class 'Sightengine\\SightengineClient' not found

Hi, I tried installing your SDK but I can't get it to work, any idea? please help, I'm stuck

PHP Fatal error: Uncaught Error: Class 'Sightengine\\SightengineClient' not found in /var/www/html/photobooth/app.php

<?php
use \Sightengine\SightengineClient; 
$client = new SightengineClient('xxxxxxxx', 'xxxxxxxxxxxxxxxx');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.