leolani / cltl-chatbots

Series of chatbots that demonstrate Leolani’s functionalities
Apache License 2.0
0 stars 1 forks source link

Do stuff with image crashes #1

Closed piekvossen closed 2 years ago

piekvossen commented 2 years ago

While running the notebook: lets-chat_with_a_friend.ipynb

2021-11-01 21:19:30.473 INFO face_util - load_binary_image: ../../data/2021-11-01-21:19:09/image/429253.png image loaded!
2021-11-01 21:19:31.285 INFO face_util - run_face_api: got <Response [200]> from server!...
2021-11-01 21:19:31.286 INFO face_util - run_face_api: 1 faces deteced!
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/6w/bw7dqbl9727c48pcjjh32r140000gn/T/ipykernel_38454/3798781907.py in <module>
     18         faces_detected,
     19         det_scores,embeddings,
---> 20     ) = f_util.do_stuff_with_image(imagepath)
     21 
     22     # Here we assume that only one face is in the image

~/PycharmProjects/cltl-chatbots/src/util/face_util.py in do_stuff_with_image(image_path, url_face, url_age_gender)
    288     bboxes, det_scores, landmarks, embeddings = run_face_api(data, url_face)
    289 
--> 290     faces_detected = face_recognition(embeddings)
    291 
    292     ages, genders = run_age_gender_api(embeddings, url_age_gender)

~/PycharmProjects/cltl-chatbots/src/util/face_util.py in face_recognition(embeddings, COSINE_SIMILARITY_THRESHOLD)
    153     logging.debug(f"cosine similarities: {cosine_similarities}")
    154 
--> 155     faces_detected_ = [max(sim, key=sim.get) for sim in cosine_similarities]
    156     faces_detected = []
    157     for uuid_name, sim in zip(faces_detected_, cosine_similarities):

~/PycharmProjects/cltl-chatbots/src/util/face_util.py in <listcomp>(.0)
    153     logging.debug(f"cosine similarities: {cosine_similarities}")
    154 
--> 155     faces_detected_ = [max(sim, key=sim.get) for sim in cosine_similarities]
    156     faces_detected = []
    157     for uuid_name, sim in zip(faces_detected_, cosine_similarities):

ValueError: max() arg is an empty sequence
tae898 commented 2 years ago

Perhaps there are no faces detected? Does this only happen in the notebook file or also in the regular python file?

piekvossen commented 2 years ago

490935

This is image that is loaded according to the code

tae898 commented 2 years ago

Alright I see the problems now.

The directory paths have been changed. The modules can't find each other now.

I suggest following:

  1. Go back to the last commit.
  2. Module names should be more explicit (i.e., src is not a good name for a module. We are coding in python, not c++).
  3. It's always better to make PRs, especially when there are breaking changes.
numblr commented 2 years ago

Hm, but it's not an import error, right? Looks to me like the python path is set correctly.

piekvossen commented 2 years ago

Fixed and code cleanup. I added arguments for setting the paths for the embeddings throughout the code. All logs, data, embeddings are outside the src folder and a chatbots packages was added.