justadudewhohacks / face-api.js

JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js
MIT License
16.53k stars 3.69k forks source link

face-api.js ERROR: Based on the provided shape, [256,128], the tensor should have 32768 values but has 29076 #602

Open ingridih opened 4 years ago

ingridih commented 4 years ago

Hello. i have a problem with this API. I dont know why, but localhost work very well, but in production not. I uploaded the files directly to the server

The error says:

tf-core.esm.js:17 Uncaught (in promise) Error: Based on the provided shape, [256,128], the tensor should have 32768 values but has 29076 at g (tf-core.esm.js:17) at kn (tf-core.esm.js:17) at In (tf-core.esm.js:17) at o (tf-core.esm.js:17) at Ph (tf-core.esm.js:17) at tf-core.esm.js:17 at Array.forEach () at tf-core.esm.js:17 at Array.forEach () at tf-core.esm.js:17

i know this error is on side face-api.js, but i don't know how to fix. i use hostgator to server

Best Regards

ngoding commented 4 years ago

Yes, I have the same issue. Works perfectly on local, but not on production.

For some reason, I think the model did not load all of the content. It should load 2MB instead of bytes.

Screen Shot 2020-06-23 at 19 02 59
ingridih commented 4 years ago

i fixed. i changed the save file. I moved Model file to the root folder.

Sorry, i don't know if you understand me, because i'm Brazilian. LOL

ngoding commented 4 years ago

I understand you just fine. I fixed it too, the model wasn't loading correctly because I misconfigure URL settings so it doesn't load the model. It's a bad error message making us think the error comes from the javascript program.

pancatrevisan commented 4 years ago

Hello, if someone got here with the same problem, in my case, it was working on local but not on hosted. So, after a long time, I've found out the problem was on the ftp transfer. We must pay atention to transfer the shard files in binary mode. I am using filezila and it was transfering the shards in text mode. Forcing it to binary solved.

AlexanderMkrtchyan commented 3 years ago

Hello, if someone got here with the same problem, in my case, it was working on local but not on hosted. So, after a long time, I've found out the problem was on the ftp transfer. We must pay atention to transfer the shard files in binary mode. I am using filezila and it was transfering the shards in text mode. Forcing it to binary solved.

You are right!

Sohardh commented 3 years ago

Hello, if someone got here with the same problem, in my case, it was working on local but not on hosted. So, after a long time, I've found out the problem was on the ftp transfer. We must pay atention to transfer the shard files in binary mode. I am using filezila and it was transfering the shards in text mode. Forcing it to binary solved.

How to do that?

pancatrevisan commented 3 years ago

Hello, if someone got here with the same problem, in my case, it was working on local but not on hosted. So, after a long time, I've found out the problem was on the ftp transfer. We must pay atention to transfer the shard files in binary mode. I am using filezila and it was transfering the shards in text mode. Forcing it to binary solved.

How to do that?

Hello, using filezilla client, transfer> transfer type > binary

jagad89 commented 3 years ago

I faced same issue when I loaded models from git repository. To solve this I made archive of models and committed to git. Once I setup I extract the zip to appropriate directory.

nuovoforte commented 3 years ago

I have the same problem with a dotnet SPA React app, deployed in AWS Elastic Beanstalk the json files are there but I get the error ' Error: Based on the provided shape, [1,1,256,24], the tensor should have 6144 values but has 4841'

adityatriand commented 2 years ago

Hello, if someone got here with the same problem, in my case, it was working on local but not on hosted. So, after a long time, I've found out the problem was on the ftp transfer. We must pay atention to transfer the shard files in binary mode. I am using filezila and it was transfering the shards in text mode. Forcing it to binary solved.

thanks, it's worked

JMHeartley commented 2 years ago

Hello,

For me this issue was being caused because the shards had no extension and therefore had no MIME mapping. You can can update the shard files to .bin but you need to update the manifest.json files as well. You can also add a new MIME map for extensionless files to that which would be for binary files but that might be a bit more cumbersome: Solution found here https://github.com/justadudewhohacks/face-api.js/issues/131#issuecomment-561738466

aGORyan commented 1 year ago

I tried:

  1. zipping the files before committing to git, and using amplify build settings to unzip the files during the prebuild frontend stage.
  2. using wget to grab the zip file from S3, then unzipping it, bypassing transfer to git
  3. giving the shard files an extension and updated the respective manifest.json files.

No change. Everything works great locally, but for some reason I'm still getting this error once it's hosted...

Uncaught (in promise) Error: Based on the provided shape, [1,1,512,9], the tensor should have 4608 values but has 1288

This is a React.js project with the files located in Public/models

JMHeartley commented 1 year ago

I tried:

  1. zipping the files before committing to git, and using amplify build settings to unzip the files during the prebuild frontend stage.
  2. using wget to grab the zip file from S3, then unzipping it, bypassing transfer to git
  3. giving the shard files an extension and updated the respective manifest.json files.

No change. Everything works great locally, but for some reason I'm still getting this error once it's hosted...

Uncaught (in promise) Error: Based on the provided shape, [1,1,512,9], the tensor should have 4608 values but has 1288

This is a React.js project with the files located in Public/models

Did you try adding the .bin extension to the shard files?

aGORyan commented 1 year ago

I tried:

  1. zipping the files before committing to git, and using amplify build settings to unzip the files during the prebuild frontend stage.
  2. using wget to grab the zip file from S3, then unzipping it, bypassing transfer to git
  3. giving the shard files an extension and updated the respective manifest.json files.

No change. Everything works great locally, but for some reason I'm still getting this error once it's hosted... Uncaught (in promise) Error: Based on the provided shape, [1,1,512,9], the tensor should have 4608 values but has 1288 This is a React.js project with the files located in Public/models

Did you try adding the .bin extension to the shard files?

I had tried adding a .shard extension, but I just tried adding the .bin (and updating the respective JSON), but unfortunately no change.

I also confirmed the file sizes of everything in "models" (both the JSON and the shards) were the same before/after build.

pancatrevisan commented 1 year ago

I solved transfering the shard files forcing the ftp transfer to use binary mode.

aGORyan commented 1 year ago

I tried:

  1. zipping the files before committing to git, and using amplify build settings to unzip the files during the prebuild frontend stage.
  2. using wget to grab the zip file from S3, then unzipping it, bypassing transfer to git
  3. giving the shard files an extension and updated the respective manifest.json files.

No change. Everything works great locally, but for some reason I'm still getting this error once it's hosted... Uncaught (in promise) Error: Based on the provided shape, [1,1,512,9], the tensor should have 4608 values but has 1288 This is a React.js project with the files located in Public/models

Did you try adding the .bin extension to the shard files?

I had tried adding a .shard extension, but I just tried adding the .bin (and updating the respective JSON), but unfortunately no change.

I also confirmed the file sizes of everything in "models" (both the JSON and the shards) were the same before/after build.

I'm thrilled to say I must have made a stupid mistake; a second set of eyes trying the same thing (add .shard extension, update JSON, place in unzipped S3 bucket, wget during prebuild) got it working!

Attaching my working models for the next person to find themselves here, so they don't make the same mistake.

models.zip

akinzeman commented 1 year ago

Hello, if someone got here with the same problem, in my case, it was working on local but not on hosted. So, after a long time, I've found out the problem was on the ftp transfer. We must pay atention to transfer the shard files in binary mode. I am using filezila and it was transfering the shards in text mode. Forcing it to binary solved.

Congs.., How did you achive to find out that? :)

pancatrevisan commented 1 year ago

Hello, if someone got here with the same problem, in my case, it was working on local but not on hosted. So, after a long time, I've found out the problem was on the ftp transfer. We must pay atention to transfer the shard files in binary mode. I am using filezila and it was transfering the shards in text mode. Forcing it to binary solved.

Congs.., How did you achive to find out that? :)

Wow. I really don't remember :D

imdkbj commented 1 year ago

I tried:

  1. zipping the files before committing to git, and using amplify build settings to unzip the files during the prebuild frontend stage.
  2. using wget to grab the zip file from S3, then unzipping it, bypassing transfer to git
  3. giving the shard files an extension and updated the respective manifest.json files.

No change. Everything works great locally, but for some reason I'm still getting this error once it's hosted... Uncaught (in promise) Error: Based on the provided shape, [1,1,512,9], the tensor should have 4608 values but has 1288 This is a React.js project with the files located in Public/models

Did you try adding the .bin extension to the shard files?

I had tried adding a .shard extension, but I just tried adding the .bin (and updating the respective JSON), but unfortunately no change. I also confirmed the file sizes of everything in "models" (both the JSON and the shards) were the same before/after build.

I'm thrilled to say I must have made a stupid mistake; a second set of eyes trying the same thing (add .shard extension, update JSON, place in unzipped S3 bucket, wget during prebuild) got it working!

Attaching my working models for the next person to find themselves here, so they don't make the same mistake.

models.zip

Hey! Can you pls share the amplify build settings. (Must sanitise...)

imanimulele commented 1 year ago

I tried:

  1. zipping the files before committing to git, and using amplify build settings to unzip the files during the prebuild frontend stage.
  2. using wget to grab the zip file from S3, then unzipping it, bypassing transfer to git
  3. giving the shard files an extension and updated the respective manifest.json files.

No change. Everything works great locally, but for some reason I'm still getting this error once it's hosted... Uncaught (in promise) Error: Based on the provided shape, [1,1,512,9], the tensor should have 4608 values but has 1288 This is a React.js project with the files located in Public/models

Did you try adding the .bin extension to the shard files?

I had tried adding a .shard extension, but I just tried adding the .bin (and updating the respective JSON), but unfortunately no change. I also confirmed the file sizes of everything in "models" (both the JSON and the shards) were the same before/after build.

I'm thrilled to say I must have made a stupid mistake; a second set of eyes trying the same thing (add .shard extension, update JSON, place in unzipped S3 bucket, wget during prebuild) got it working! Attaching my working models for the next person to find themselves here, so they don't make the same mistake. models.zip

Hey! Can you pls share the amplify build settings. (Must sanitise...)

imanimulele commented 1 year ago

These models worked perfect , thanks

Matthew-Gu commented 1 year ago

i have the same problem and i don't know how to fix it,i use iis to server,even i use others working models,still not working

joelost commented 11 months ago

I solved transfering the shard files forcing the ftp transfer to use binary mode.

We have the similar avatar.

vitorlui commented 8 months ago

Hello, if someone got here with the same problem, in my case, it was working on local but not on hosted. So, after a long time, I've found out the problem was on the ftp transfer. We must pay atention to transfer the shard files in binary mode. I am using filezila and it was transfering the shards in text mode. Forcing it to binary solved.

How to do that?

Hello, using filezilla client, transfer> transfer type > binary

Worked for me, thanks!

Imamkhoirijelfi commented 4 months ago

I tried:

  1. zipping the files before committing to git, and using amplify build settings to unzip the files during the prebuild frontend stage.
  2. using wget to grab the zip file from S3, then unzipping it, bypassing transfer to git
  3. giving the shard files an extension and updated the respective manifest.json files.

No change. Everything works great locally, but for some reason I'm still getting this error once it's hosted... Uncaught (in promise) Error: Based on the provided shape, [1,1,512,9], the tensor should have 4608 values but has 1288 This is a React.js project with the files located in Public/models

Did you try adding the .bin extension to the shard files?

I had tried adding a .shard extension, but I just tried adding the .bin (and updating the respective JSON), but unfortunately no change. I also confirmed the file sizes of everything in "models" (both the JSON and the shards) were the same before/after build.

I'm thrilled to say I must have made a stupid mistake; a second set of eyes trying the same thing (add .shard extension, update JSON, place in unzipped S3 bucket, wget during prebuild) got it working!

Attaching my working models for the next person to find themselves here, so they don't make the same mistake.

models.zip

worked for me thankssss

nhinhninhbinh commented 1 month ago

I tried:

  1. zipping the files before committing to git, and using amplify build settings to unzip the files during the prebuild frontend stage.
  2. using wget to grab the zip file from S3, then unzipping it, bypassing transfer to git
  3. giving the shard files an extension and updated the respective manifest.json files.

No change. Everything works great locally, but for some reason I'm still getting this error once it's hosted... Uncaught (in promise) Error: Based on the provided shape, [1,1,512,9], the tensor should have 4608 values but has 1288 This is a React.js project with the files located in Public/models

Did you try adding the .bin extension to the shard files?

I had tried adding a .shard extension, but I just tried adding the .bin (and updating the respective JSON), but unfortunately no change. I also confirmed the file sizes of everything in "models" (both the JSON and the shards) were the same before/after build.

I'm thrilled to say I must have made a stupid mistake; a second set of eyes trying the same thing (add .shard extension, update JSON, place in unzipped S3 bucket, wget during prebuild) got it working!

Attaching my working models for the next person to find themselves here, so they don't make the same mistake.

models.zip

Thank you very much! It worked for me.