Giter Site home page Giter Site logo

fakeface's Introduction

This API is deprecated and no longer hosted. You are welcome to make use of the code to host your own version.

This API returns image URLs of fake human faces generated by thispersondoesnotexist.

alt text

Each image has been pre-analysed by an AI algorithm called pypy-agender to identify gender and age (obviously non-exact).

As such, the user of the API can specify gender, minimum and maximum age for the image to be returned.

Data can be returned via JSON format, a direct redirect to the image or a simple response with the image URL.

JSON data for a face

Endpoint

https://fakeface.rest/face/json

Optional query parameters

  • gender : accepts "male" or "female"; defaults to both if not provided

  • minimum_age : integer

  • maximum_age : integer

Response

{
  age: 45,
  date_added: "Sun, 02 Aug 2020 22:08:56 GMT",
  filename: "female_45_b3e57178eb323fee36df8e8b4690c11ef82f3baa.jpg",
  gender: "female",
  image_url: "https://content.fakeface.rest/female_45_b3e57178eb323fee36df8e8b4690c11ef82f3baa.jpg",
  last_served: "Sun, 02 Aug 2020 22:08:56 GMT",
  source: "thispersondoesnotexist"
}

Example queries:

https://fakeface.rest/face/json

https://fakeface.rest/face/json?gender=male

https://fakeface.rest/face/json?gender=female&minimum_age=35

https://fakeface.rest/face/json?maximum_age=50&gender=female

Redirect to a face

Endpoint

https://fakeface.rest/face/view

Query parameters

(same as above for JSON)

Response

Browser redirects right to image

Example queries:

https://fakeface.rest/face/view

https://fakeface.rest/face/view?gender=male

Inserting into HTML

The above address can be used in the src for an img in HTML to dynamically generate a new face on each load:

alt text

If you want to insert multiple different faces and prevent the browser caching then you can append any number or random string to the end of the endpoint as follows:

https://fakeface.rest/face/view/55?gender=male

https://fakeface.rest/face/view/anythingcangohere_theapidoesntdoanythingwithit?gender=male

Redirect to a thumbnail of a face

Endpoint

https://fakeface.rest/thumb/view

Query parameters

(same as above for JSON)

Response

Browser redirects right to thumbnail (350x350 maximum) image.

Example queries:

https://fakeface.rest/thumb/view

https://fakeface.rest/thumb/view?gender=male

Inserting into html:

alt text

alt text

Licence

All of these images are generated by https://thispersondoesnotexist.com and are provided for usage only as allowed by that project's creators.

Credits

All the hard work was done by the makers of https://thispersondoesnotexist.com and pypy-agender

fakeface's People

Contributors

adeeteya avatar hankhank10 avatar secureuplink 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fakeface's Issues

API requests have stopped working again few days ago

I'm ready to donate for a hosting if necessary. Kindly asking the owner to put fakeface.rest API back online or give a copy with the database to a new owner. I've been using this API for educational purposes for about 2 years now. Thank you.

Feature request: Could you send the dimensions of the photo in response?

Hello, thank you for a very cool library!

I have a small feature request that I've mentioned in the title - could you send the image dimensions in the API response? It would be nice to know them to prevent layout shifts, some image libraries even explicitly require them.

In the documentation you mention that thumbnails are 350x350 and I see any other image I've generated was 866x866. Would still be nice if we knew for sure in the response.

Thank you!

500 error on endpoints.

I really appreciate this service and these endpoints but I think they are returning 500 at the moment. Not sure if these endpoints are still supported?

CORS

This api is great thank you for your work.. would be much better if you allowed cross origin resource sharing(CORS) .

SSL certificate problem: certificate has expired

Hi:
I have this code to get and save face image from your API:

[request.php]

$minAge = 18;
$maxAge = 81;
$gender = 'male';
$fakeFaceUrl = "https://fakeface.rest/face/json?minimum_age={$minAge}&maximum_age={$maxAge}&gender={$gender}";
$obj = json_decode(file_get_contents($fakeFaceUrl), true);
$imageBaseName = 11 . '-img-profile-';
$response = fetchImageFromUrl($obj['image_url'], 'imags/uploads/users', false, $imageBaseName);

[helper.php]

if(!function_exists('fetchImageFromUrl')) {
    function fetchImageFromUrl(
        string $url,
        ?string $dir,
        bool $isFullPath,
        ?string $imageBaseName
    ): bool|\RuntimeException|string {
        $dir = $dir === null ? sys_get_temp_dir() : $dir; // GNU/Linux / OS X / Windows compatible
        // Validate directory path
        if (! is_dir($dir) || ! is_writable($dir)) {
            mkdir($dir, 0777, true);
        }

        $imageBaseName = $imageBaseName === null ? '' : $imageBaseName;
        $parts = explode('.', $url);
        $imageExtension = end($parts);

        // Generate a random filename. Use the server address so that a file
        // generated at the same time on a different server won't have a collision.
        $name = md5(uniqid(empty($_SERVER['SERVER_ADDR']) ? '' : $_SERVER['SERVER_ADDR'], true));
        $filename = $imageBaseName . $name . "." . $imageExtension;
        $filepath = $dir . DIRECTORY_SEPARATOR . $filename;

        // save file
        if (function_exists('curl_exec')) {
            // use cURL
            $fp = fopen($filepath, 'w');
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_FILE, $fp);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0');
            // - Para no exigir VALIDEZ DE CERTICADO SSL
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            $success = curl_exec($ch) && curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200;
            fclose($fp);
            curl_close($ch);

            if (! $success) {
                unlink($filepath);
                echo "\nNO_SUCCESS_CURL";
                echo "\n";
                echo curl_error($ch);

                // could not contact the distant URL or HTTP error - fail silently.
                return false;
            }
        } elseif (ini_get('allow_url_fopen')) {
            // use remote fopen() via copy()
            $success = copy($url, $filepath);
            if (! $success) {
                // could not contact the distant URL or HTTP error - fail silently.
                return false;
            }
        } else {
            return new \RuntimeException('The image formatter downloads an image from a remote HTTP server. Therefore, it requires that PHP can request remote hosts, either via cURL or fopen()');
        }

        return $isFullPath ? $filepath : $filename;
    }
}

When I execute the request, the file doesn't save if the CURL option is applied. Because of this exception or error:

SSL certificate problem: certificate has expired

Only, when I put this line before the curl_exec, everything works fine and the image is saved:

        //...
        // - To NOT require SSL certificate validation
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $success = curl_exec($ch) && curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200;
        //...

So, is it possible that your certificate has expired and needs to be renewed, or could the source of the error be something else?
Thanks for any response. Regards

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.