scenic

google-researchApache-2.0活跃维护

基于 JAX 的计算机视觉研究库,提供注意力机制、Transformer 和 Vision Transformer 等模型实现,方便快速搭建和复现视觉研究实验。

Scenic: A Jax Library for Computer Vision Research and Beyond

暂无版本3,848star +1 / 7 天482fork同步于 2026-11-10 17:41 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/google-research/scenic.git
cd scenic
pip install .
硬件要求按 README 说明

README 未说明具体显存或 GPU 型号要求,仅提到面向多设备、多主机的大规模视觉模型训练

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

基于 JAX/Flax 的视觉注意力模型研究代码库,提供可复用的训练与评估基础设施

基于 JAX 的计算机视觉研究库,提供注意力机制、Transformer 和 Vision Transformer 等模型实现,方便快速搭建和复现视觉研究实验。

核心能力

  • 提供启动实验、日志、profiling 等样板代码
  • 内置优化过的训练/评估循环、损失、指标与二分匹配器
  • 提供常见视觉数据集的输入流水线,支持多机多卡
  • 包含 ViT、DETR、CLIP、SAM 等复现基线模型
  • 库级代码与项目级代码分层,便于 fork 定制

容易踩的坑

需要 Python 3.9 或更高版本;具体项目或基线可能需按各自 README 或 requirements.txt 额外安装依赖;训练示例需自行准备 ImageNet 数据

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Scenic

    Scenic is a codebase with a focus on research around attention-based models for computer vision. Scenic has been successfully used to develop classification, segmentation, and detection models for multiple modalities including images, video, audio, and multimodal combinations of them.

    More precisely, Scenic is a (i) set of shared light-weight libraries solving tasks commonly encountered tasks when training large-scale (i.e. multi-device, multi-host) vision models; and (ii) several projects containing fully fleshed out problem-specific training and evaluation loops using these libraries.

    Scenic is developed in JAX and uses Flax.

    Contents

    What we offer

    Among others Scenic provides

    • Boilerplate code for launching experiments, summary writing, logging, profiling, etc;
    • Optimized training and evaluation loops, losses, metrics, bi-partite matchers, etc;
    • Input-pipelines for popular vision datasets;
    • Baseline models, including strong non-attentional baselines.

    SOTA models and baselines in Scenic

    There are some SOTA models and baselines in Scenic which were either developed using Scenic, or have been reimplemented in Scenic:

    Projects that were developed in Scenic or used it for their experiments:

    More information can be found in projects.

    Baselines that were reproduced in Scenic:

    More information can be found in baseline models.

    Philosophy

    Scenic aims to facilitate rapid prototyping of large-scale vision models. To keep the code simple to understand and extend we prefer forking and copy-pasting over adding complexity or increasing abstraction. Only when functionality proves to be widely useful across many models and tasks it may be upstreamed to Scenic's shared libraries.

    Getting started

    • See projects/baselines/README.md for a walk-through baseline models and instructions on how to run the code.
    • If you would like to contribute to Scenic, please check out the Philisophy, Code structure and Contributing sections. Should your contribution be a part of the shared libraries, please send us a pull request!

    Quickstart

    You will need Python 3.9 or later. Download the code from GitHub

    $ git clone https://github.com/google-research/scenic.git
    $ cd scenic
    $ pip install .
    

    and run training for ViT on ImageNet:

    $ python scenic/main.py -- \
      --config=scenic/projects/baselines/configs/imagenet/imagenet_vit_config.py \
      --workdir=./
    

    Note that for specific projects and baselines, you might need to install extra packages that are mentioned in their README.md or requirements.txt files.

    Here is also a minimal colab to train a simple feed-forward model using Scenic.

    Scenic component design

    Scenic is designed to propose different levels of abstraction, to support hosting projects that only require changing hyper-parameters by defining config files, to those that need customization on the input pipeline, model architecture, losses and metrics, and the training loop. To make this happen, the code in Scenic is organized as either project-level code, which refers to customized code for specific projects or baselines or library-level code, which refers to common functionalities and general patterns that are adapted by the majority of projects. The project-level code lives in the projects directory.

    Library-level code

    The goal is to keep the library-level code minimal and well-tested and to avoid introducing extra abstractions to support minor use-cases. Shared libraries provided by Scenic are split into:

    • dataset_lib: Implements IO pipelines for loading and pre-processing data for common Computer Vision tasks and benchmarks (see "Tasks and Datasets" section). All pipelines are designed to be scalable and support multi-host and multi-device setups, taking care dividing data among multiple hosts, incomplete batches, caching, pre-fetching, etc.
    • model_lib : Provides
      • several abstract model interfaces (e.g. ClassificationModel or SegmentationModel in model_lib.base_models) with task-specific losses and metrics;
      • neural network layers in model_lib.layers, focusing on efficient implementation of attention and transformer layers;
      • accelerator-friendly implementations of bipartite matching algorithms in model_lib.matchers.
    • train_lib: Provides tools for constructing training loops and implements several optimized trainers (classification trainer and segmentation trainer) that can be forked for customization.
    • common_lib: General utilities, like logging and debugging modules, functionalities for processing raw data, etc.

    Project-level code

    Scenic supports the development of customized solutions for customized tasks and data via the concept of "project". There is no one-fits-all recipe for how much code should be re-used by a project. Projects can consist of only configs and use the common models, trainers, task/data that live in library-level code, or they can simply fork any of the mentioned functionalities and redefine, layers, losses, metrics, logging methods, tasks, architectures, as well as training and evaluation loops. The modularity of library-level code makes it flexible for projects to fall placed on any spot in the "run-as-is" to "fully customized" spectrum.

    Common baselines such as a ResNet and Vision Transformer (ViT) are implemented in the projects/baselines project. Forking models in this directory is a good starting point for new projects.

    Citing Scenic

    If you use Scenic, you can cite our white paper. Here is an example BibTeX entry:

    @InProceedings{dehghani2021scenic,
        author    = {Dehghani, Mostafa and Gritsenko, Alexey and Arnab, Anurag and Minderer, Matthias and Tay, Yi},
        title     = {Scenic: A JAX Library for Computer Vision Research and Beyond},
        booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
        year      = {2022},
        pages     = {21393-21398}
    }
    

    Disclaimer: This is not an official Google product.