Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API extension for CompreFace #7

Open
3JL opened this issue Mar 24, 2023 · 3 comments
Open

API extension for CompreFace #7

3JL opened this issue Mar 24, 2023 · 3 comments

Comments

@3JL
Copy link

3JL commented Mar 24, 2023

Great plugin!! :)
I extended it to also work with CompreFace which is a facial recognition algorithm that can run locally. Below the code. It will need to be refined a bit here and there (I am far from a professional) and I am more than happy to help doing so. I can also write a tutorial or something if needed.
Best, J

`<?php

class CompreFace extends API {

function getInfo() : array
{
    return [
        "icon" => 'https://user-images.githubusercontent.com/3736126/147130206-17234c47-8d40-490f-8d93-57014fa6d87e.png',
        "site" => 'https://exadel.com/solutions/compreface/',
        "info" => `
        CompreFace is an open-source face recognition service that can be run on premises
        `,
    ];
}

function getConfParams() : array
{
    return [
        'ENDPOINT' => 'API Endpoint', 
        'KEY'=> 'API Key'
    ];
}

function generateTags($conf, $params) : array
{
    global $logger;
    $file_path = $this->getFileName($params['imageId']);

         
    $url ='http://'.$conf["ENDPOINT"].'/api/v1/recognition/recognize?limit=0&det_prob_threshold=0.6&prediction_count=1&face_plugins=landmarks,%20gender,%20age,%20calculator&status=true';

    $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('file'=> new CURLFILE($file_path)),
        CURLOPT_HTTPHEADER => array(
            'Content-Type: multipart/form-data',
            'x-api-key: '.$conf["KEY"]
        ),
    ));
    
    if (curl_errno($curl)) 
    {
        return [curl_error($curl)];
    }
    
    $response = curl_exec($curl);

    curl_close($curl);

    $json_response = json_decode($response);
    
    $tags = [];

    $json_result = $json_response->result;

    foreach ($json_result as $result) {

        if($result->subjects[0]->similarity > 0.65)
            array_push($tags,$result->subjects[0]->subject);
        $logger->info("Found " . $result->subjects[0]->subject);
    }
  
    return $tags;
}

}`

@3JL
Copy link
Author

3JL commented Mar 28, 2023

Some specific issues that I ran into using CompreFace that need to be resolved. I would benefit from a bit of help here :) @Zacharieg, would you be able to help out?

Issue 1 - error message despite successful tagging
Screenshot 2023-03-28 at 11 32 47

Detailed description: when running the plugin from the Batch Manager (for a single or multiple photos), an error is returned, while the images are correctly processed and tags correctly added to the figure.

Issue 2 - success message despite plugin not running for second selection
Screenshot 2023-03-28 at 11 37 16

Detailed description: when running the plugin from the Batch Manager (after a successful run) on a new selection, a success message is provided, but no photos are tagged.

Issue 3 - plugin hanging on 'Loading...'
Screenshot 2023-03-28 at 11 40 05

Detailed description: when running the plugin from a photo page ('Edit photo'), the plugin hangs on 'Loading..' and no tagging takes place.

@RStoroy
Copy link

RStoroy commented Mar 29, 2023

I have the same issues on ALL APIS.

@kkygeek
Copy link

kkygeek commented Apr 26, 2023

Same here, either with Azure or Imagga. Did the cURL check with Imagga, which was succesful, so the problem seems to be with the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants