from transformers import T5Model
model = T5Model.from_pretrained("./path/to/local/directory", local_files_only=True)

Fetch models and tokenizers to use offline
Another option for using 🤗 Transformers offline is to download the files ahead of time, and then point to their local path when you need to use them offline. There are three ways to do this:

Download a file through the user interface on the Model Hub by clicking on the ↓ icon.