notAI-tech / NudeNet

Lightweight nudity detection
https://nudenet.notai.tech/
GNU Affero General Public License v3.0
1.66k stars 335 forks source link

JSON RESULTS NOT COMPLETE #121

Closed AlexUrrutia closed 9 months ago

AlexUrrutia commented 9 months ago

Hi, I am running it on docker and results I get are:

{
    "prediction": {
        "1.png": {
            "safe": 0.04798686131834984,
            "unsafe": 0.9520131945610046
        }
    },
    "success": true

How can I access data for all the properties Like this:

detection_example = [
 {'class': 'BELLY_EXPOSED',
  'score': 0.799403190612793,
  'box': [64, 182, 49, 51]},
 {'class': 'FACE_FEMALE',
  'score': 0.7881264686584473,
  'box': [82, 66, 36, 43]},
 ]
bedapudi6788 commented 9 months ago

Hi, the docker image I pushed is pretty old and based on v2. also looks like you are running docker image for classification instead of detection.

I will push a new docker image and update it here.

bedapudi6788 commented 9 months ago

https://github.com/notAI-tech/NudeNet#docker @AlexUrrutia

AlexUrrutia commented 9 months ago

https://github.com/notAI-tech/NudeNet#docker @AlexUrrutia

Thanks, I'll test it now

AlexUrrutia commented 9 months ago

Now I get this:

{
    "success": false,
    "reason": "Received json input. Expected multi-part file input."
}
bedapudi6788 commented 9 months ago

curl -F f1=@"images.jpeg" "http://localhost:8080/infer" this is the curl.

bedapudi6788 commented 9 months ago

what curl are you sending ?

AlexUrrutia commented 9 months ago

Hello, I was using the php script posted here some time ago...

<?php

header("Content-Type: application/json");
$url = "http://localhost:8080/infer";
$image1 = base64_encode(file_get_contents('https://domain.com/16955673673220129769.jpg'));

$data = array('data' => array('image'=>$image1));
$payload = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result1 = curl_exec($ch);
print_r($result1);

?>
AlexUrrutia commented 9 months ago

ok I fixed the code and now it works, thanks!

<?php

$url = "http://localhost:8080/infer";

$imageFilePath = 'path/to/image/image.jpg';

$imageFileHandle = fopen($imageFilePath, 'r');

if ($imageFileHandle === false) {
    die('Unable to open the image file.');
}

$ch = curl_init($url);

$postData = [
    'image' => curl_file_create($imageFilePath, 'image/jpeg', 'image.jpg'),
];

curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

$result = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'cURL Error: ' . curl_error($ch);
} else {
    echo $result;
}

curl_close($ch);
fclose($imageFileHandle);
?>