CLIP convnext base w laion2B s13B b82K augreg
简介
核心亮点
- 基于 ConvNeXt 纯卷积架构,图像处理更稳健
- LAION-2B 海量数据预训练,语义理解力强
- 极佳的图文对齐能力,适用于高效以文搜图
- 支持零样本识别,可作为强力视觉特征提取器
使用方法
# 安装 Hugging Face transformers
pip install transformers torch
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg")
tokenizer = AutoTokenizer.from_pretrained("laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg")
Hugging Face 下载
我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 huggingface_hub:
pip install -U huggingface_hub
命令行下载
下载完整模型库
huggingface-cli download laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg
下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg config.json --local-dir ./dir
SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://huggingface.co/laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg
如果您希望跳过 lfs 大文件下载,可以使用如下命令
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg
模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。
PyTorch / Transformers 使用
安装 Transformers
pip install -U transformers torch
模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg')
tokenizer = AutoTokenizer.from_pretrained('laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg')
模型下载
我们推荐使用命令行或者 ModelScope SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 ModelScope:
pip install modelscope
命令行下载
下载完整模型库
modelscope download --model laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg
下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)
modelscope download --model laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg README.md --local_dir ./dir
SDK 下载
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://www.modelscope.cn/laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg.git
如果您希望跳过 lfs 大文件下载,可以使用如下命令
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg.git
ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。
Notebook 快速开发
下载并安装 ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
模型加载和推理
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
p = pipeline('text-generation', 'laion/CLIP-convnext_base_w-laion2B-s13B-b82K-augreg')
完整文档
---
license: mit
pipeline_tag: zero-shot-image-classification
library_name: open_clip
tags:
- clip
---
Model Card for CLIP-convnext_base_w.laion2B-s13B-b82k-augreg
Table of Contents
1. Model Details
2. Uses
3. Training Details
4. Evaluation
5. Acknowledgements
6. Citation
Model Details
Model Description
A series of CLIP ConvNeXt-Base (w/ wide embed dim) models trained on subsets LAION-5B (https://laion.ai/blog/laion-5b/) using OpenCLIP (https://github.com/mlfoundations/open_clip).
Goals:
* Explore an alternative to ViT and ResNet (w/ AttentionPooling) CLIP models that scales well with model size and image resolution
Firsts:
* First known ConvNeXt CLIP models trained at scale in the range of CLIP ViT-B/16 and RN50x4 models
* First released model weights exploring increase of augmentation + regularization for image tower via adding (greater scale range of RRC, random erasing, stochastic depth)
The models utilize the timm ConvNeXt-Base model (convnext_base) as the image tower, and the same text tower as the RN50x4 (depth 12, embed dim 640) model from OpenAI CLIP. The base models are trained at 256x256 image resolution and roughly match the RN50x4 models on FLOPs and activation counts. The models with 320 in the name are trained at 320x320.
All models in this series were trained for 13B samples and have ImageNet Zero-Shot top-1 of >= 70.8%. Comparing to ViT-B/16 at 34B SS with zero-shot of 70.2% (68.1% for 13B SS) this suggests the ConvNeXt architecture may be more sample efficient in this range of model scale. More experiments needed to confirm.
| Model | Dataset | Resolution | AugReg | Top-1 ImageNet Zero-Shot (%) |
| ----- | ------- | ---------- | ------------ | --------- |
| convnext_base_w.laion2b_s13b_b82k | LAION-2B | 256x256 | RRC (0.9, 1.0) | 70.8 |
| convnext_base_w.laion2b_s13b_b82k_augreg | LAION-2B | 256x256 | RRC (0.33, 1.0), RE (0.35), SD (0.1) | 71.5 |
| convnext_base_w.laion_aesthetic_s13b_b82k | LAION-A | 256x256 | RRC (0.9, 1.0) | 71.0 |
| convnext_base_w_320.laion_aesthetic_s13b_b82k | LAION-A | 320x320 | RRC (0.9, 1.0) | 71.7 |
| convnext_base_w_320.laion_aesthetic_s13b_b82k_augreg | LAION-A | 320x320 | RRC (0.33, 1.0), RE (0.35), SD (0.1) | 71.3 |
RRC = Random Resize Crop (crop pcts), RE = Random Erasing (prob), SD = Stochastic Depth (prob) -- image tower only
LAION-A = LAION Aesthetic, an ~900M sample subset of LAION-2B with pHash dedupe and asthetic score filtering.
Model training done by Ross Wightman across both the stability.ai cluster and the JUWELS Booster supercomputer. See acknowledgements below.
Uses
As per the original OpenAI CLIP model card, this model is intended as a research output for research communities. We hope that this model will enable researchers to better understand and explore zero-shot, arbitrary image classification. We also hope it can be used for interdisciplinary studies of the potential impact of such model.
The OpenAI CLIP paper includes a discussion of potential downstream impacts to provide an example for this sort of analysis. Additionally, the LAION-5B blog (https://laion.ai/blog/laion-5b/) and upcoming paper include additional discussion as it relates specifically to the training dataset.
Direct Use
Zero-shot image classification, image and text retrieval, among others.
Downstream Use
Image classification and other image task fine-tuning, linear probe image classification, image generation guiding and conditioning, among others.
Out-of-Scope Use
As per the OpenAI models,
Any deployed use case of the model - whether commercial or not - is currently out of scope. Non-deployed use cases such as image search in a constrained environment, are also not recommended unless there is thorough in-domain testing of the model with a specific, fixed class taxonomy. This is because our safety assessment demonstrated a high need for task specific testing especially given the variability of CLIP’s performance with different class taxonomies. This makes untested and unconstrained deployment of the model in any use case currently potentially harmful.
Certain use cases which would fall under the domain of surveillance and facial recognition are always out-of-scope regardless of performance of the model. This is because the use of artificial intelligence for tasks such as these can be premature currently given the lack of testing norms and checks to ensure its fair use.
Since the model has not been purposefully trained in or evaluated on any languages other than English, its use should be limited to English language use cases.
Further the above notice, the LAION-5B dataset used in training of these models has additional considerations, see below.
Training Details
Training Data
This model was trained with one of (see table in intro):
- LAION-2B - A 2 billion sample English subset of LAION-5B (https://laion.ai/blog/laion-5b/).
- LAION-Aesthetic - A 900M sample subset of LAION-2B with pHash dedupe and asthetic score filtering
IMPORTANT NOTE: The motivation behind dataset creation is to democratize research and experimentation around large-scale multi-modal model training and handling of uncurated, large-scale datasets crawled from publically available internet. Our recommendation is therefore to use the dataset for research purposes. Be aware that this large-scale dataset is uncurated. Keep in mind that the uncurated nature of the dataset means that collected links may lead to strongly discomforting and disturbing content for a human viewer. Therefore, please use the demo links with caution and at your own risk. It is possible to extract a “safe” subset by filtering out samples based on the safety tags (using a customized trained NSFW classifier that we built). While this strongly reduces the chance for encountering potentially harmful content when viewing, we cannot entirely exclude the possibility for harmful content being still present in safe mode, so that the warning holds also there. We think that providing the dataset openly to broad research and other interested communities will allow for transparent investigation of benefits that come along with training large-scale models as well as pitfalls and dangers that may stay unreported or unnoticed when working with closed large datasets that remain restricted to a small community. Providing our dataset openly, we however do not recommend using it for creating ready-to-go industrial products, as the basic research about general properties and safety of such large-scale models, which we would like to encourage with this release, is still in progress.
Training Procedure
All models were trained with a global batch size of 81920 for 64 checkpoint intervals of 203.7M samples for a total of ~13B samples seen over training.
For 256x256 models, a slurm script w/ srun below was used on 20 8-GPU (A100 40GB) nodes (Stability), switching to 40 4-GPU nodes for time on JUWELS.
```
/opt/slurm/sbin/srun --cpu_bind=v --accel-bind=gn python -m training.main \
--save-frequency 1 \
--name "convnext_256" \
--resume 'latest' \
--train-data="pipe:aws s3 cp s3://mybucket/path/{laion{00000..xxxxx}.tar -" \
--train-num-samples