Giter VIP home page Giter VIP logo

face-search's People

Contributors

v-sher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

face-search's Issues

Numpy 1.20.0 error invalid __array_struct__

Thanks a lot for your work Dr. Varshita Sher!

To avoid the issue: Invaliid array_struct , you can easely bypass the filtering function with a try and extracting only the embedding array in the embedding function:

to get only the embeddings array with insight face:

emb_res = app.get(rgb_arr)
res = emb_res[0].embedding

Then the function will be :

def generate_embs(img_fpaths: List[str]):
    embs_set = list()
    embs_label = list()
    for img_fpath in img_fpaths:  
        print('tratamento: ',img_fpath)                    
        # read grayscale img
        img = Image.open(os.path.join(YALE_DIR, img_fpath)) 
        img_arr = np.asarray(img)  
        
        # convert grayscale to rgb
        im = Image.fromarray((img_arr * 255).astype(np.uint8))
        rgb_arr = np.asarray(im.convert('RGB'))       
       
        # generate Insightface embedding
        emb_res = app.get(rgb_arr)
        try:
         res = emb_res[0].embedding
         # append emb to the eval set
         embs_set.append(res)          
         # append label to eval_label set
         embs_label.append(img_fpath.split("_")[0])
        except:
         print('no embedding found for this image')
    return embs_set, embs_label

this way no need for filtering the set is updated only if the embedding exist.

Then replace these 2 lines:

evaluation_embs, evaluation_labels = filter_empty_embs(eval_set, eval_labels)
probe_embs, probe_labels = filter_empty_embs(probe_set, probe_labels)

with

evaluation_embs, evaluation_labels = eval_set, eval_labels
probe_embs, probe_labels = probe_set, probe_labels

or rename the variables name

Check my answer on stackoverflow:

https://stackoverflow.com/questions/69618467/numpy-np-array-valueerror-invalid-array-struct/70909945#70909945

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.