File size: 771 Bytes
57bdca5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Set trust_remote_code=True to use a model with custom code: from transformers import AutoModelForImageClassification model = AutoModelForImageClassification.from_pretrained("sgugger/custom-resnet50d", trust_remote_code=True) It is also strongly encouraged to pass a commit hash as a revision to make sure the author of the models did not update the code with some malicious new lines (unless you fully trust the authors of the models). py commit_hash = "ed94a7c6247d8aedce4647f00f20de6875b5b292" model = AutoModelForImageClassification.from_pretrained( "sgugger/custom-resnet50d", trust_remote_code=True, revision=commit_hash ) Note that when browsing the commit history of the model repo on the Hub, there is a button to easily copy the commit hash of any commit.. |