Registry / ai-ml / tf-models-official

tf-models-official

JSON →
library2.20.0pypypi✓ verified 86d ago

TensorFlow Official Models (tf-models-official) is a collection of reference implementations for state-of-the-art TensorFlow models, provided by the TensorFlow team. Current version is 2.20.0, supporting TensorFlow 2.x. It provides a modular library of NLP, vision, and recommendation models with reusable building blocks. Release cadence aligns with TensorFlow releases (usually quarterly).

pip install tf-models-official
INSTALL
IMPORT
SIG · TF-MODELS-OFFICIAL
T
tf-models-official
ai-mlpythonv2.20.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

nlp
from official import nlp
from official.nlp import bert
Common mistake: import from official.nlp directly. Use 'official' as top-level and then access nlp module.
vision
from official import vision
import tensorflow_models as tfm
Importing tensorflow_models is deprecated; use 'from official import vision' instead.

Quick example: import ResNet50 and train on dummy data.

import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import tensorflow as tf from official import vision train_ds = tf.data.Dataset.from_tensor_slices((tf.random.normal([100, 224, 224, 3]), tf.random.uniform([100], maxval=1000, dtype=tf.int64))) model = vision.resnet50() model.compile(optimizer='adam', loss='sparse_categorical_crossentropy') model.fit(train_ds.batch(32), epochs=1)
Debug
Known issues
breakingVersion 2.20.0 requires TensorFlow 2.20.0 or higher. Using an older TensorFlow version will cause import errors.
fix
Update TensorFlow to match: pip install tensorflow>=2.20
affects: >=2.20.0
deprecatedThe 'tensorflow_models' top-level module is deprecated. Use 'official' instead.
fix
Change imports from 'tensorflow_models' to 'official'.
affects: >=2.0.0
gotchaImports from `official.nlp.bert` may not work directly; you need to import the `nlp` module first (e.g., `from official import nlp`).
fix
Use `from official import nlp` then `nlp.bert`.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'official'
Package not installed or environment issue.
fix
Run `pip install tf-models-official` to install the package.
ImportError: cannot import name 'resnet50' from 'official.vision'
Using incorrect import path or the model is not available in that version.
fix
Check available models: `from official import vision; print(dir(vision))` or use `vision.resnet50` (exact name).
AttributeError: module 'official' has no attribute 'nlp'
Trying to import `official.nlp` directly before importing `official`.
fix
Use `from official import nlp` instead of `import official.nlp`.
Upgrade
Version history
2.20.0latest on PyPI · released Feb 11, 2026
Audit
Dependencies
tensorflowrequiredCore dependency; version should match tf-models-official major.minor.
tensorflow-datasetsoptionalUsed for dataset loading in examples.
Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
tf-models-official — pip install tf-models-official · libregistry