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

push_to_hub_keras rejected because it contains binary files #825

Closed
nateraw opened this issue Apr 8, 2022 · 4 comments · Fixed by #828
Closed

push_to_hub_keras rejected because it contains binary files #825

nateraw opened this issue Apr 8, 2022 · 4 comments · Fixed by #828

Comments

@nateraw
Copy link
Contributor

nateraw commented Apr 8, 2022

I noticed I can't push the LFS files associated with Keras models anymore. What's interesting is that I'm experiencing the same issue on older versions of huggingface_hub (0.4.0) as well as new versions (0.5.1).

Here is a minimal example to recreate the issue:

import tensorflow as tf
from tensorflow.keras import layers, Sequential

from huggingface_hub import push_to_hub_keras

model = Sequential(
    [
        layers.Dense(1000, activation="relu", name="layer1"),
        layers.Dense(1000, activation="relu", name="layer2"),
        layers.Dense(1000, name="layer3"),
    ]
)
model.build((None, 2))

push_to_hub_keras(model, 'test-save-keras-sequential')

You can also try it yourself in Colab: Open In Colab

When you run the above, you get this...I redacted my token which was being printed here.

remote: -------------------------------------------------------------------------        
remote: Your push was rejected because it contains binary files.        
remote: Please use https://git-lfs.github.com/ to store binary files.        
remote: See also: https://hf.co/docs/hub/adding-a-model#uploading-your-files        
remote: -------------------------------------------------------------------------        
remote: Offending files:        
remote:  - variables/variables.data-00000-of-00001 (ref: refs/heads/main)        
To https://huggingface.co/nateraw/test-save-keras-sequential
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://user:<REDACTED TOKEN>@huggingface.co/nateraw/test-save-keras-sequential'
@LysandreJik
Copy link
Member

Linked to #687

@LysandreJik
Copy link
Member

The issue linked above is due to binary files not being automatically tracked by git-lfs; in this instance, the push was rejected because it contains binary file. I believe having automatic tracking via git-lfs for binary files would solve the issue shown by @nateraw's code sample above.

@LysandreJik
Copy link
Member

@nateraw could you try by checking out this branch to see if it solves your problem? #828

@nateraw
Copy link
Contributor Author

nateraw commented Apr 8, 2022

Solved ✅ thank you!!

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

Successfully merging a pull request may close this issue.

2 participants