CoolFace
Modelpublic

fxmarty/tiny-testing-remote-code

sourceHugging Faceapache-2.0updated 4y agoView on Hugging Face
0likes11downloads
README.md28 linesDownload Raw Back to root
1---2license: apache-2.03---4 5Use at your own risk:6 7```python8from transformers import AutoFeatureExtractor, AutoModelForImageClassification9from datasets import load_dataset10import torch11 12feature_extractor = AutoFeatureExtractor.from_pretrained("fxmarty/tiny-testing-remote-code")13 14model = AutoModelForImageClassification.from_pretrained("fxmarty/tiny-testing-remote-code", trust_remote_code=True)15 16dataset = load_dataset("huggingface/cats-image")17image = dataset["test"]["image"][0]18 19inputs = feature_extractor(image, return_tensors="pt")20 21with torch.no_grad():22    logits = model(**inputs).logits23 24# model predicts one of the 1000 ImageNet classes25predicted_label = logits.argmax(-1).item()26print(model.config.id2label[predicted_label])27```28