Instructions to use Jacques7103/Food-Recognition with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Jacques7103/Food-Recognition with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="Jacques7103/Food-Recognition") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("Jacques7103/Food-Recognition") model = AutoModelForImageClassification.from_pretrained("Jacques7103/Food-Recognition") - Notebooks
- Google Colab
- Kaggle
| license: apache-2.0 | |
| base_model: google/vit-base-patch16-224-in21k | |
| tags: | |
| - generated_from_trainer | |
| metrics: | |
| - accuracy | |
| model-index: | |
| - name: food-recognition | |
| results: [] | |
| <!-- This model card has been generated automatically according to the information the Trainer had access to. You | |
| should probably proofread and complete it, then remove this comment. --> | |
| # food-recognition | |
| This model is a fine-tuned version of [google/vit-base-patch16-224-in21k](https://huggingface.co/google/vit-base-patch16-224-in21k) on an unknown dataset. | |
| It achieves the following results on the evaluation set: | |
| - Loss: 0.2610 | |
| - Accuracy: 0.9324 | |
| ## Model description | |
| The Vision Transformer (ViT) is a transformer encoder model (BERT-like) pretrained on a large collection of images in a supervised fashion, namely ImageNet-21k, at a resolution of 224x224 pixels. | |
| Images are presented to the model as a sequence of fixed-size patches (resolution 16x16), which are linearly embedded. One also adds a [CLS] token to the beginning of a sequence to use it for classification tasks. One also adds absolute position embeddings before feeding the sequence to the layers of the Transformer encoder. | |
| Note that this model does not provide any fine-tuned heads, as these were zero'd by Google researchers. However, the model does include the pre-trained pooler, which can be used for downstream tasks (such as image classification). | |
| By pre-training the model, it learns an inner representation of images that can then be used to extract features useful for downstream tasks: if you have a dataset of labeled images for instance, you can train a standard classifier by placing a linear layer on top of the pre-trained encoder. One typically places a linear layer on top of the [CLS] token, as the last hidden state of this token can be seen as a representation of an entire image. | |
| ## Intended uses & limitations | |
| You can use the raw model for image classification. See the model hub to look for fine-tuned versions on a task that interests you. | |
| ## Training procedure | |
| ### Training hyperparameters | |
| The following hyperparameters were used during training: | |
| - learning_rate: 0.0002 | |
| - train_batch_size: 16 | |
| - eval_batch_size: 8 | |
| - seed: 42 | |
| - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08 | |
| - lr_scheduler_type: linear | |
| - num_epochs: 4 | |
| ### Training results | |
| | Training Loss | Epoch | Step | Validation Loss | Accuracy | | |
| |:-------------:|:-----:|:----:|:---------------:|:--------:| | |
| | 0.5974 | 0.21 | 100 | 0.6096 | 0.8292 | | |
| | 0.5911 | 0.43 | 200 | 0.5204 | 0.8476 | | |
| | 0.7085 | 0.64 | 300 | 0.4329 | 0.8708 | | |
| | 0.5302 | 0.85 | 400 | 0.4843 | 0.8428 | | |
| | 0.2436 | 1.07 | 500 | 0.3767 | 0.886 | | |
| | 0.2355 | 1.28 | 600 | 0.3344 | 0.8956 | | |
| | 0.1497 | 1.49 | 700 | 0.3447 | 0.8932 | | |
| | 0.2213 | 1.71 | 800 | 0.3082 | 0.9072 | | |
| | 0.2197 | 1.92 | 900 | 0.3169 | 0.902 | | |
| | 0.0719 | 2.13 | 1000 | 0.2977 | 0.9136 | | |
| | 0.0526 | 2.35 | 1100 | 0.3455 | 0.9084 | | |
| | 0.0926 | 2.56 | 1200 | 0.3140 | 0.9208 | | |
| | 0.0427 | 2.77 | 1300 | 0.3307 | 0.9128 | | |
| | 0.0716 | 2.99 | 1400 | 0.3007 | 0.9204 | | |
| | 0.0151 | 3.2 | 1500 | 0.2791 | 0.9292 | | |
| | 0.032 | 3.41 | 1600 | 0.2737 | 0.9296 | | |
| | 0.0611 | 3.62 | 1700 | 0.2620 | 0.9336 | | |
| | 0.0175 | 3.84 | 1800 | 0.2610 | 0.9324 | | |
| ### Framework versions | |
| - Transformers 4.36.0 | |
| - Pytorch 2.1.1+cpu | |
| - Datasets 2.15.0 | |
| - Tokenizers 0.15.0 | |