ChenglongMa / SkinToneClassifier

An easy-to-use library for skin tone classification
https://chenglongma.com/SkinToneClassifier/
GNU General Public License v3.0
97 stars 13 forks source link

using stone in my code #7

Closed esraabdalgani closed 1 year ago

esraabdalgani commented 1 year ago

any idea how to use stone in my code so I can create an API from it .

ChenglongMa commented 1 year ago

Hi @esraabdalgani,

Thanks for your attention to this project. Could you please give me more context? I don't quite understand your requirement.

Thanks!

esraabdalgani commented 1 year ago

we are trying to build an API for an avatar system 3D when we upload "photo" service from amazon"aws Recognition" gave us all the details about faces " eyes color , ..etc " except skin color ... I need your library to implement it in our code so i can upload a photo it retain a skin color tone ... using flask or lambda function .. any idea how to do this ?

ChenglongMa commented 1 year ago

Oh, I see. However, this library is designed to be used in the command line. But I can try to implement it as a library that can be imported into other Python projects.

It would be great if you could tell me what the input and expected output are in your API. For example, suppose we have a function named process in stone:

import stone

output = stone.process(image, *args)

What parameters do you need to put in this function, and what results do you expect?

Thanks!

esraabdalgani commented 1 year ago

I think if you put the same options that ' I can specify in the command line' ..image url , image type and output DIRECTORY.. etc and it would be great if the same result as a "JSON" . can you please tell me how long will it take to implement this ? thank you so much.

ChenglongMa commented 1 year ago

Hi @esraabdalgani,

I can try to implement it now. Will update the version tomorrow.

Thanks.

ChenglongMa commented 1 year ago

Hi @esraabdalgani,

I've released the new version.

Please upgrade the library by

pip install skin-tone-classifier --upgrade

And refer to README#9. Used as a library by importing into other projects for usage.

Thanks!

esraabdalgani commented 1 year ago

thank you so much ... I really appreciate your help. one thing I tried to use your library with different pic and offen I got a darker color ... do you suggest I use a specific palette??.. note that I chose pic with really big faces to get accurate results for " skin tone " field .

esraabdalgani commented 1 year ago

cc

for this pic I got

{"filename":"ffff.jpeg","stone_output":"[\n {\n "file": "ffff-NA",\n "image type": "color",\n "face id": "NA",\n "dominant 1": "#AE8E7A",\n "props 1": "0.74",\n "dominant 2": "#83624D",\n "props 2": "0.26",\n "skin tone": "#9D7A54",\n "PERLA": "CF",\n "accuracy(0-100)": "90.15"\n }\n]"}

and all of them have really darker skin color ... can you please suggest a method or specific standard to get more accurate result.??

ChenglongMa commented 1 year ago

Hi @esraabdalgani,

I was just about to reply to you and wanted to ask you for a picture example :)

It is great. I can try to debug the library with your example. I'll give you an update later.

Thanks!

ChenglongMa commented 1 year ago

Hi @esraabdalgani,

I tested your image and got the following result: example

Firstly, it seems you are using an old version of the library.

Please run the following command to upgrade it to version 1.1.0.

pip install skin-tone-classifier --upgrade

I had to pass color to image_type when I tested it:

import stone

result = stone.process('example.jpeg', , image_type='color')

Then the result would be:

{
  "basename": "example",
  "extension": ".jpeg",
  "image_type": "color",
  "faces": [
    {
      "dominant_colors": [
        {
          "color": "#D7B19F",
          "percent": "0.62"
        },
        {
          "color": "#7A4E3B",
          "percent": "0.38"
        }
      ],
      "skin_tone": "#BEA07E",
      "tone_label": "CG",
      "accuracy": 82.27,
      "face_id": 1
    }
  ],
  "report_images": {
    "1": null
  }
}

Could you please check the result and let me know if it is the expected one?

Thanks!

ChenglongMa commented 1 year ago

With no more responses, close the issue for now. We'll be happy to reopen the issue when more information is provided.

esraabdalgani commented 1 year ago

I forgot to say that I thank you. I got busy with my work .. your work is great and your response is fast. I really appreciate your help .. thanks again.

ChenglongMa commented 1 year ago

No problem 😊 I'm glad I could help. Good luck with your work!