face-api.js icon indicating copy to clipboard operation
face-api.js copied to clipboard

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

Open ingridih opened this issue 4 years ago • 26 comments

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

ingridih avatar Apr 21 '20 19:04 ingridih

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

ngoding avatar Jun 23 '20 11:06 ngoding

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

ingridih avatar Jun 23 '20 12:06 ingridih

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.

ngoding avatar Jun 23 '20 13:06 ngoding

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.

pancatrevisan avatar Jul 30 '20 12:07 pancatrevisan

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!

AlexanderMkrtchyan avatar Nov 24 '20 21:11 AlexanderMkrtchyan

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?

Sohardh avatar Jan 17 '21 07:01 Sohardh

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

pancatrevisan avatar Jan 17 '21 11:01 pancatrevisan

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.

jagad89 avatar Mar 15 '21 12:03 jagad89

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'

nuovoforte avatar Apr 11 '21 18:04 nuovoforte

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

adityatriand avatar Oct 17 '21 02:10 adityatriand

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

JMHeartley avatar Jan 02 '22 12:01 JMHeartley

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

aGORyan avatar Nov 17 '22 19:11 aGORyan

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?

JMHeartley avatar Nov 17 '22 20:11 JMHeartley

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.

aGORyan avatar Nov 17 '22 20:11 aGORyan

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

pancatrevisan avatar Nov 17 '22 20:11 pancatrevisan

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

aGORyan avatar Nov 18 '22 15:11 aGORyan

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? :)

akinzeman avatar Dec 30 '22 23:12 akinzeman

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

pancatrevisan avatar Dec 30 '22 23:12 pancatrevisan

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...)

imdkbj avatar Feb 22 '23 19:02 imdkbj

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 avatar May 19 '23 13:05 imanimulele

These models worked perfect , thanks

imanimulele avatar May 19 '23 14:05 imanimulele

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

Matthew-Gu avatar May 31 '23 08:05 Matthew-Gu

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

We have the similar avatar.

joelost avatar Oct 20 '23 01:10 joelost

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!

  • using filezilla client, transfer> transfer type > binary

vitorlui avatar Jan 15 '24 09:01 vitorlui