Convert Figma logo to code with AI

tensorflow logomodels

Models and examples built with TensorFlow

76,949
45,793
76,949
1,251

Top Related Projects

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.

15,955

Datasets, Transforms and Models specific to Computer Vision

61,580

Deep Learning for humans

34,658

DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.

30,129

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.

34,033

Caffe: a fast open framework for deep learning.

Quick Overview

TensorFlow Models is an official repository maintained by the TensorFlow team, containing a collection of state-of-the-art machine learning models implemented in TensorFlow. It serves as a valuable resource for researchers and practitioners, providing reference implementations of various models across different domains such as computer vision, natural language processing, and reinforcement learning.

Pros

  • Offers a wide range of pre-implemented, state-of-the-art models
  • Maintained by the official TensorFlow team, ensuring quality and compatibility
  • Includes detailed documentation and examples for each model
  • Regularly updated with new models and improvements

Cons

  • Some models may have complex dependencies or require specific hardware
  • The large number of models can be overwhelming for beginners
  • Not all models are optimized for production use
  • Some older models may not be compatible with the latest TensorFlow versions

Code Examples

  1. Loading and using a pre-trained MobileNet model for image classification:
import tensorflow as tf
import tensorflow_hub as hub

# Load the MobileNet model
model = tf.keras.Sequential([
    hub.KerasLayer("https://tfhub.dev/google/tf2-preview/mobilenet_v2/classification/4")
])

# Preprocess an image
image = tf.keras.preprocessing.image.load_img("image.jpg", target_size=(224, 224))
image = tf.keras.preprocessing.image.img_to_array(image)
image = tf.expand_dims(image, 0)

# Make a prediction
predictions = model.predict(image)
predicted_class = tf.argmax(predictions[0])
  1. Fine-tuning a BERT model for text classification:
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text as text

# Load the BERT preprocessor and encoder
preprocessor = hub.KerasLayer("https://tfhub.dev/tensorflow/bert_en_uncased_preprocess/3")
encoder = hub.KerasLayer("https://tfhub.dev/tensorflow/bert_en_uncased_L-12_H-768_A-12/4")

# Create a classification model
text_input = tf.keras.layers.Input(shape=(), dtype=tf.string)
preprocessed_text = preprocessor(text_input)
outputs = encoder(preprocessed_text)
pooled_output = outputs["pooled_output"]
classifier = tf.keras.layers.Dense(2, activation="softmax")(pooled_output)

model = tf.keras.Model(text_input, classifier)

# Compile and train the model
model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"])
model.fit(train_data, train_labels, epochs=3)
  1. Using the Object Detection API:
import tensorflow as tf
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as viz_utils

# Load a saved model
detect_fn = tf.saved_model.load("path/to/saved_model")

# Load label map
category_index = label_map_util.create_category_index_from_labelmap("path/to/label_map.pbtxt")

# Perform inference
image_np = ...  # Load your image as a numpy array
input_tensor = tf.convert_to_tensor(image_np)
detections = detect_fn(input_tensor)

# Visualize results
viz_utils.visualize_boxes_and_labels_on_image_array(
    image_np,
    detections['detection_boxes'][0].numpy(),
    detections['detection_classes'][0].numpy().astype(np.int32),
    detections['detection_scores'][0].numpy(),
    category_index,
    use_normalized_coordinates=True,
    max_boxes_to_draw=200,
    min_score_thresh=.30,
    agnostic_mode=False)

Getting Started

To get started with TensorFlow Models:

  1. Clone the repository:

    git clone https://github.com/tensorflow/models.git
    
  2. Install dependencies:

    cd models
    

Competitor Comparisons

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.

Pros of Transformers

  • Easier to use and more accessible for beginners
  • Supports multiple frameworks (PyTorch, TensorFlow, JAX)
  • Extensive documentation and community support

Cons of Transformers

  • More focused on NLP tasks, less versatile for other domains
  • May have slightly lower performance for some specialized tasks

Code Comparison

Models:

# Load and use a pre-trained model
model = tf.keras.applications.ResNet50(weights='imagenet')
predictions = model.predict(img_array)

Transformers:

from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("bert-base-uncased")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
inputs = tokenizer("Hello world!", return_tensors="pt")
outputs = model(**inputs)

Models offers a wide range of pre-trained models for various tasks, while Transformers focuses on state-of-the-art NLP models with a user-friendly API. Models provides more flexibility for custom architectures, but Transformers excels in quick prototyping and fine-tuning for NLP tasks. Both repositories are actively maintained and have strong community support, making them valuable resources for machine learning practitioners.

15,955

Datasets, Transforms and Models specific to Computer Vision

Pros of vision

  • More focused and specialized for computer vision tasks
  • Simpler API and easier to use for beginners
  • Better integration with PyTorch ecosystem

Cons of vision

  • Smaller community and fewer resources compared to models
  • Less comprehensive, covering fewer model architectures
  • Limited support for non-vision tasks

Code Comparison

vision:

import torchvision.models as models
resnet18 = models.resnet18(pretrained=True)

models:

import tensorflow as tf
resnet_model = tf.keras.applications.ResNet50(weights='imagenet')

The vision repository provides a more straightforward approach to loading pre-trained models, while models offers a wider range of options and configurations. vision's code is typically more concise and Pythonic, whereas models often requires more boilerplate code but offers greater flexibility.

Both repositories are actively maintained and provide valuable resources for machine learning practitioners. The choice between them often depends on personal preference, project requirements, and familiarity with the underlying frameworks (PyTorch vs TensorFlow).

61,580

Deep Learning for humans

Pros of Keras

  • Simpler, more intuitive API for rapid prototyping and experimentation
  • Better documentation and user-friendly interface
  • Easier to learn and use for beginners in deep learning

Cons of Keras

  • Less flexibility for advanced customization compared to TensorFlow models
  • Fewer pre-implemented models and research-oriented implementations
  • Limited support for distributed training and deployment

Code Comparison

Keras:

from keras.models import Sequential
from keras.layers import Dense

model = Sequential([
    Dense(64, activation='relu', input_shape=(784,)),
    Dense(10, activation='softmax')
])

TensorFlow models:

import tensorflow as tf

model = tf.keras.Sequential([
    tf.keras.layers.Dense(64, activation='relu', input_shape=(784,)),
    tf.keras.layers.Dense(10, activation='softmax')
])

The code comparison shows that while Keras offers a more concise syntax, TensorFlow models provide similar functionality with slightly more verbose import statements. Both repositories now use the Keras API, but TensorFlow models offer additional low-level control and customization options when needed.

34,658

DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.

Pros of DeepSpeed

  • Optimized for distributed training and large-scale models
  • Supports various optimization techniques like ZeRO, pipeline parallelism, and 3D parallelism
  • Integrates well with PyTorch and offers easy-to-use APIs

Cons of DeepSpeed

  • Limited support for TensorFlow compared to Models
  • Steeper learning curve for beginners due to advanced optimization features
  • Fewer pre-trained models and examples compared to Models

Code Comparison

DeepSpeed:

model_engine, optimizer, _, _ = deepspeed.initialize(
    args=args,
    model=model,
    model_parameters=params
)

Models (TensorFlow):

model = tf.keras.Sequential([
    tf.keras.layers.Dense(64, activation='relu'),
    tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam', loss='categorical_crossentropy')

Summary

DeepSpeed excels in distributed training and large-scale model optimization, making it ideal for advanced users working on massive models. Models, on the other hand, offers a wider range of pre-trained models and examples, making it more accessible for beginners and those working with TensorFlow. The choice between the two depends on the specific requirements of your project and your familiarity with the respective ecosystems.

30,129

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.

Pros of fairseq

  • More focused on sequence-to-sequence models and natural language processing tasks
  • Provides a comprehensive set of pre-trained models for various NLP tasks
  • Easier to customize and extend for specific NLP research needs

Cons of fairseq

  • Smaller community and fewer resources compared to models
  • Less versatile for non-NLP tasks and general machine learning applications
  • Steeper learning curve for beginners due to its specialized nature

Code Comparison

models:

import tensorflow as tf
from official.nlp import modeling
model = modeling.networks.TransformerEncoder(
    vocab_size=10000, num_layers=6, hidden_size=512)

fairseq:

from fairseq.models.transformer import TransformerModel
model = TransformerModel.build_model(args, task)

Both repositories provide implementations of popular deep learning models, but they differ in their focus and scope. models offers a wide range of models for various machine learning tasks, while fairseq specializes in sequence-to-sequence models and NLP tasks. models benefits from TensorFlow's extensive ecosystem and community support, making it more suitable for general-purpose machine learning. fairseq, on the other hand, excels in NLP-specific tasks and offers more flexibility for researchers in this domain.

34,033

Caffe: a fast open framework for deep learning.

Pros of Caffe

  • Faster execution speed for certain types of neural networks
  • Easier to deploy in production environments
  • More mature and stable codebase

Cons of Caffe

  • Less active development and community support
  • Limited flexibility for creating custom architectures
  • Steeper learning curve for beginners

Code Comparison

Caffe (Python):

import caffe
net = caffe.Net('deploy.prototxt', 'model.caffemodel', caffe.TEST)
input_data = ...  # Prepare input data
output = net.forward(data=input_data)

TensorFlow (using models):

import tensorflow as tf
from official.vision.image_classification import resnet_model
model = resnet_model.resnet50(num_classes=1000)
input_data = ...  # Prepare input data
output = model(input_data, training=False)

Summary

Caffe is known for its speed and production-readiness, making it suitable for specific use cases. However, models offers greater flexibility and ongoing development, backed by TensorFlow's extensive ecosystem. The choice between the two depends on project requirements, existing infrastructure, and team expertise.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Python tf-models-official PyPI

Welcome to the Model Garden for TensorFlow

The TensorFlow Model Garden is a repository with a number of different implementations of state-of-the-art (SOTA) models and modeling solutions for TensorFlow users. We aim to demonstrate the best practices for modeling so that TensorFlow users can take full advantage of TensorFlow for their research and product development.

To improve the transparency and reproducibility of our models, training logs on TensorBoard.dev are also provided for models to the extent possible though not all models are suitable.

DirectoryDescription
official• A collection of example implementations for SOTA models using the latest TensorFlow 2's high-level APIs
• Officially maintained, supported, and kept up to date with the latest TensorFlow 2 APIs by TensorFlow
• Reasonably optimized for fast performance while still being easy to read
For more details on the capabilities, check the guide on the Model-garden
research• A collection of research model implementations in TensorFlow 1 or 2 by researchers
• Maintained and supported by researchers
community• A curated list of the GitHub repositories with machine learning models and implementations powered by TensorFlow 2
orbit• A flexible and lightweight library that users can easily use or fork when writing customized training loop code in TensorFlow 2.x. It seamlessly integrates with tf.distribute and supports running on different device types (CPU, GPU, and TPU).

Installation

To install the current release of tensorflow-models, please follow any one of the methods described below.

Method 1: Install the TensorFlow Model Garden pip package

tf-models-official is the stable Model Garden package. Please check out the releases to see what are available modules.

pip3 will install all models and dependencies automatically.

pip3 install tf-models-official

Please check out our examples:

Note that tf-models-official may not include the latest changes in the master branch of this github repo. To include latest changes, you may install tf-models-nightly, which is the nightly Model Garden package created daily automatically.

pip3 install tf-models-nightly

Method 2: Clone the source

  1. Clone the GitHub repository:
git clone https://github.com/tensorflow/models.git
  1. Add the top-level /models folder to the Python path.
export PYTHONPATH=$PYTHONPATH:/path/to/models

If you are using in a Windows environment, you may need to use the following command with PowerShell:

$env:PYTHONPATH += ":\path\to\models"

If you are using a Colab notebook, please set the Python path with os.environ.

import os
os.environ['PYTHONPATH'] += ":/path/to/models"
  1. Install other dependencies
pip3 install --user -r models/official/requirements.txt

Finally, if you are using nlp packages, please also install tensorflow-text-nightly:

pip3 install tensorflow-text-nightly

Announcements

Please check this page for recent announcements.

Contributions

help wanted:paper implementation

If you want to contribute, please review the contribution guidelines.

License

Apache License 2.0

Citing TensorFlow Model Garden

If you use TensorFlow Model Garden in your research, please cite this repository.

@misc{tensorflowmodelgarden2020,
  author = {Hongkun Yu, Chen Chen, Xianzhi Du, Yeqing Li, Abdullah Rashwan, Le Hou, Pengchong Jin, Fan Yang,
            Frederick Liu, Jaeyoun Kim, and Jing Li},
  title = {{TensorFlow Model Garden}},
  howpublished = {\url{https://github.com/tensorflow/models}},
  year = {2020}
}