HFValidationError when loading the model
See original GitHub issueHi there! I am trying to load a model I have stored at Google Drive for inferencing:
# Load SetFit model
tuned_model = SetFitModel.from_pretrained("/content/drive/My Drive/models/tuned-model")
# Run inference
tuned_model(["i didnt feel humiliated", "i feel romantic too", "im grabbing a minute to post i feel greedy wrong"])
But I get the following error:
HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': '/content/drive/My Drive/models /tuned-model'. Use repo_type argument if needed.
it works however when I load it from the same script in which I have saved it, by:
# Save trained model to disk
trainer.model.save_pretrained("/content/drive/My Drive/models/tuned-model")
What can be the problem? Can’t just I save/load from pretrained to Google Drive?
Many thanks in advance for your support and terrific work.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Raise a validation error in a model's save method in Django
It's fine to put validation in your model by using validators or writing a clean() method. All I was saying is that the...
Read more >error when loading config for pretraining · Issue #7289 - GitHub
I'm working on pretraining a tok2vec model in spacy v3, and I set up my config file with python -m spacy init fill-config...
Read more >Model validation error and test error - Cross Validated
No. First, there is always residual variance, so even if the model with the lowest validation error has the lowest expected prediction error ......
Read more >Validators - Django documentation
A validator is a callable that takes a value and raises a ValidationError if it doesn't meet some criteria. Validators can be useful...
Read more >Backbone.js model.validationError() - Javatpoint
The Backbone.js validationError model returns values by using validate() method. It displays validation error in two cases :.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I saved a trained model on local path. I can’t see anything wrong when loading the model using
from_pretrained
with correct path.This error appears when you try to load a model from a nonexistent local path which have more than 1 backslash
\
withlocal_files_only=True
.ModelHubMixin.from_pretrained
will throwFileNotFoundError
.ModelHubMixin.from_pretrained
will throw aHFValidationError
because the path does not exist locally and is not in the expected hub form.OSError: /path/to/your/model does not appear to have a file named config.json
SetFitModel._from_pretrained
throwsHFValidationError
not catched by try/except. Since the expected behaviour in SetFit_from_pretrained
classmethod is to initialise classification head with random weights when the MODEL_HEAD_NAME is not found, this can be considered as a bug.@pdhall99 's suggestion looks fixing the issue and follows the same logic in the
ModelHubMixin.from_pretrained
:model_head_file = os.path.join(model_id, MODEL_HEAD_NAME)
elseNone
=> initialise classification head with random weightshf_hub_download
.I get the same error. When I try to load a locally saved model:
I get
I think this could be solved by changing these lines from
to something like