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

TypeError: 'NoneType' object is not subscriptable #17

Open
morrowyn opened this issue May 28, 2022 · 4 comments
Open

TypeError: 'NoneType' object is not subscriptable #17

morrowyn opened this issue May 28, 2022 · 4 comments

Comments

@morrowyn
Copy link

Hi,

I have tried running the attendance example. However I run into the following error:
TypeError: 'NoneType' object is not subscriptable

Image faces_detected.jpg written to filesystem:  True
Client created (student_test.py file)
127.0.0.1 - - [28/May/2022 20:04:11] "POST / HTTP/1.1" 500 -
Traceback (most recent call last):
  File "E:\weaviate-examples\attendance-system-example\venv\Lib\site-packages\flask\app.py", line 2091, in __call__
    return self.wsgi_app(environ, start_response)
  File "E:\weaviate-examples\attendance-system-example\venv\Lib\site-packages\flask\app.py", line 2076, in wsgi_app
    response = self.handle_exception(e)
  File "E:\weaviate-examples\attendance-system-example\venv\Lib\site-packages\flask\app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "E:\weaviate-examples\attendance-system-example\venv\Lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "E:\weaviate-examples\attendance-system-example\venv\Lib\site-packages\flask\app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "E:\weaviate-examples\attendance-system-example\venv\Lib\site-packages\flask\app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "E:\weaviate-examples\attendance-system-example\upload_student.py", line 44, in upload_image
    attendance = markAttendance(faces,own=True) #.drop_duplicates()
  File "E:\weaviate-examples\attendance-system-example\mark.py", line 18, in markAttendance
    name = testit(img)
  File "E:\weaviate-examples\attendance-system-example\student_test.py", line 87, in testit
    ans = res['data']['Get']['Students'][0]['labelName']
TypeError: 'NoneType' object is not subscriptable
127.0.0.1 - - [28/May/2022 20:04:11] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
127.0.0.1 - - [28/May/2022 20:04:11] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
127.0.0.1 - - [28/May/2022 20:04:11] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
 * Detected change in 'E:\\weaviate-examples\\attendance-system-example\\upload_student.py', reloading
libpng warning: iCCP: known incorrect sRGB profile
 * Restarting with stat
C:\Program Files\JetBrains\PyCharm Community Edition 2020.2.2\plugins\python-ce\helpers\pydev\pydevd.py:1844: DeprecationWarning: currentThread() is deprecated, use current_thread() instead
  dummy_thread = threading.currentThread()
 * Debugger is active!
 * Debugger PIN: 521-878-846
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [28/May/2022 20:04:59] "GET / HTTP/1.1" 200 -

I used the images from the following directories to test it out:
attendance-system-example\students and attendance-system-example\test

Regards,

@morrowyn
Copy link
Author

morrowyn commented May 28, 2022

And this is the result from student_add.py:

Client created (student_add.py file)
Schema class created
6 Student images from Mbappe added.
7 Student images from Messi added.
7 Student images from Ronaldo added.
Images added

This is the response from res = client.query.get("Students", ["labelName", "_additional {certainty}"]).with_near_vector(nearVector).do()

{'data': {'Get': {'Students': None}}, 'errors': [{'locations': [{'column': 6, 'line': 1}], 'message': "explorer: get class: vector search: object vector search at index students: shard students_YaDbfHtOdSyd: vector search: knn search: distance between entrypint and query node: vector lengths don't match: 2048 vs 128", 'path': ['Get', 'Students']}]}

@bobvanluijt
Copy link
Member

CC: @sky-2002 – can you maybe help out? Thanks :)

@sky-2002
Copy link
Contributor

Sure @bobvanluijt , I will look into this and get back ! Thanks @morrowyn for bringing up the issue.

@sky-2002
Copy link
Contributor

sky-2002 commented May 31, 2022

Hello @morrowyn , as you mentioned, you have used the directories "attendance-system-example\students" and "attendance-system-example\test" to test out the example, I believe that you have used the "/students" directory to add the individual images and you tried to test on test images.

After looking at the response that you have provided,
"{'data': {'Get': {'Students': None}}, 'errors': [{'locations': [{'column': 6, 'line': 1}], 'message': "explorer: get class: vector search: object vector search at index students: shard students_YaDbfHtOdSyd: vector search: knn search: distance between entrypint and query node: vector lengths don't match: 2048 vs 128", 'path': ['Get', 'Students']}]}"

It says that the vector lengths do not match.

Probable reason:
What I believe to be a probable reason for this might be that you are using your own vectors while adding data i.e. you are using the "student_own_add.py" file, which uses OpenCV functions to generate a face vector/embedding of length 128. But while querying, maybe you are using the "testImage" function which uses weaviate module to vectorize the image. And as the weaviate's module generates a vector of length 2048, there is no possibility of finding a dot product between these vectors. And hence the issue. I suggest to use the "testit" function to test images when you are using your own vectors. And the "testImage" function when using modules.

Something else 🤔 ?
If the above is not the case, please do let me know here or reach out via slack.
Though I feel that the above mentioned reason is the cause of this, I am still looking for more places in the code where this can go wrong. I will let you know if I find something else that causes this same issue.

Things learnt from this:
I think I should name the functions so that they are more intuitive, I will definitely fix that, also I am adding some checks to the code which will prevent these kind of issues and raise informative errors so as to make it easy to fix.

Thanks ! 😇

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