Transformers-Tutorials
Hi there!
This repository contains demos I made with the Transformers library by 🤗 HuggingFace. Currently, all of them are implemented in PyTorch.
NOTE: if you are not familiar with HuggingFace and/or Transformers, I highly recommend to check out our free course, which introduces you to several Transformer architectures (such as BERT, GPT-2, T5, BART, etc.), as well as an overview of the HuggingFace libraries, including Transformers, Tokenizers, Datasets, Accelerate and the hub.
For an overview of the ecosystem of HuggingFace for computer vision (June 2022), refer to this notebook with corresponding video.
Currently, it contains the following demos:
- Audio Spectrogram Transformer (paper):
- performing inference with
ASTForAudioClassification to classify audio.
- BERT (paper):
- fine-tuning
BertForTokenClassification on a named entity recognition (NER) dataset.
- fine-tuning
BertForSequenceClassification for multi-label text classification.
- BEiT (paper):
- understanding
BeitForMaskedImageModeling
- CANINE (paper):
- fine-tuning
CanineForSequenceClassification on IMDb
- CLIPSeg (paper):
- performing zero-shot image segmentation with
CLIPSeg
- Conditional DETR (paper):
- performing inference with
ConditionalDetrForObjectDetection
- fine-tuning
ConditionalDetrForObjectDetection on a custom dataset (balloon)
- ConvNeXT (paper):
- fine-tuning (and performing inference with)
ConvNextForImageClassification
- DINO (paper):
- visualize self-attention of Vision Transformers trained using the DINO method
- DETR (paper):
- performing inference with
DetrForObjectDetection
- fine-tuning
DetrForObjectDetection on a custom object detection dataset
- evaluating
DetrForObjectDetection on the COCO detection 2017 validation set
- performing inference with
DetrForSegmentation
- fine-tuning
DetrForSegmentation on COCO panoptic 2017
- DPT (paper):
- performing inference with DPT for monocular depth estimation
- performing inference with DPT for semantic segmentation
- Deformable DETR (paper):
- performing inference with
DeformableDetrForObjectDetection
- DiT (paper):
- performing inference with DiT for document image classification
- Donut (paper):
- performing inference with Donut for document image classification
- fine-tuning Donut for document image classification
- performing inference with Donut for document visual question answering (DocVQA)
- performing inference with Donut for document parsing
- fine-tuning Donut for document parsing with PyTorch Lightning
- GIT (paper):
- performing inference with GIT for image/video captioning and image/video question-answering
- fine-tuning GIT on a custom image captioning dataset
- GLPN (paper):
- performing inference with
GLPNForDepthEstimation to illustrate monocular depth estimation
- GPT-J-6B (repository):
- performing inference with
GPTJForCausalLM to illustrate few-shot learning and code generation
- GroupViT (repository):
- performing inference with
GroupViTModel to illustrate zero-shot semantic segmentation
- ImageGPT (blog post):
- (un)conditional image generation with
ImageGPTForCausalLM
- linear probing with ImageGPT
- LUKE (paper):
- fine-tuning
LukeForEntityPairClassification on a custom relation extraction dataset using PyTorch Lightning
- LayoutLM (paper):
- fine-tuning
LayoutLMForTokenClassification on the FUNSD dataset
- fine-tuning
LayoutLMForSequenceClassification on the RVL-CDIP dataset
- adding image embeddings to LayoutLM during fine-tuning on the FUNSD dataset
- LayoutLMv2 (paper):
- fine-tuning
LayoutLMv2ForSequenceClassification on RVL-CDIP
- fine-tuning
LayoutLMv2ForTokenClassification on FUNSD
- fine-tuning
LayoutLMv2ForTokenClassification on FUNSD using the 🤗 Trainer
- performing inference with
LayoutLMv2ForTokenClassification on FUNSD
- true inference with
LayoutLMv2ForTokenClassification (when no labels are available) + Gradio demo
- fine-tuning
LayoutLMv2ForTokenClassification on CORD
- fine-tuning
LayoutLMv2ForQuestionAnswering on DOCVQA
- LayoutLMv3 (paper):
- fine-tuning
LayoutLMv3ForTokenClassification on the FUNSD dataset
- LayoutXLM (paper):
- fine-tuning LayoutXLM on the XFUND benchmark for token classification
- fine-tuning LayoutXLM on the XFUND benchmark for relation extraction
- MarkupLM (paper):
- inference with MarkupLM to perform question answering on web pages
- fine-tuning
MarkupLMForTokenClassification on a toy dataset for NER on web pages
- Mask2Former (paper):
- performing inference with
Mask2Former for universal image segmentation:
- MaskFormer (paper):
- performing inference with
MaskFormer (both semantic and panoptic segmentation):
- fine-tuning
MaskFormer on a custom dataset for semantic segmentation
- OneFormer (paper):
- performing inference with
OneFormer for universal image segmentation:
- Perceiver IO (paper):
- showcasing masked language modeling and image classification with the Perceiver
- fine-tuning the Perceiver for image classification
- fine-tuning the Perceiver for text classification
- predicting optical flow between a pair of images with
PerceiverForOpticalFlow
- auto-encoding a video (images, audio, labels) with
PerceiverForMultimodalAutoencoding
- SAM (paper):
- performing inference with MedSAM
- fine-tuning
SamModel on a custom dataset
- SegFormer (paper):
- performing inference with
SegformerForSemanticSegmentation
- fine-tuning
SegformerForSemanticSegmentation on custom data using native PyTorch
- T5 (paper):
- fine-tuning
T5ForConditionalGeneration on a Dutch summarization dataset on TPU using HuggingFace Accelerate
- fine-tuning
T5ForConditionalGeneration (CodeT5) for Ruby code summarization using PyTorch Lightning
- TAPAS (paper):
- Table Transformer (paper):
- using the Table Transformer for table detection and table structure recognition
- TrOCR (paper):
- performing inference with
TrOCR to illustrate optical character recognition with Transformers, as well as making a Gradio demo
- fine-tuning
TrOCR on the IAM dataset using the Seq2SeqTrainer
- fine-tuning
TrOCR on the IAM dataset using native PyTorch
- evaluating
TrOCR on the IAM test set
- UPerNet (paper):
- performing inference with
UperNetForSemanticSegmentation
- VideoMAE (paper):
- performing inference with
VideoMAEForVideoClassification
- ViLT (paper):
- fine-tuning
ViLT for visual question answering (VQA)
- performing inference with
ViLT to illustrate visual question answering (VQA)
- masked language modeling (MLM) with a pre-trained
ViLT model
- performing inference with
ViLT for image-text retrieval
- performing inference with
ViLT to illustrate natural language for visual reasoning (NLVR)
- ViTMAE (paper):
- reconstructing pixel values with
ViTMAEForPreTraining
- Vision Transformer (paper):
- performing inference with
ViTForImageClassification
- fine-tuning
ViTForImageClassification on CIFAR-10 using PyTorch Lightning
- fine-tuning
ViTForImageClassification on CIFAR-10 using the 🤗 Trainer
- X-CLIP (paper):
- performing zero-shot video classification with X-CLIP
- zero-shot classifying a YouTube video with X-CLIP