Skip to content

【MetaCLIP】添加MetaCLIP模型paddle版本#3403

Open
ssstuding wants to merge 5 commits into
PaddlePaddle:developfrom
ssstuding:add_metaclip_model
Open

【MetaCLIP】添加MetaCLIP模型paddle版本#3403
ssstuding wants to merge 5 commits into
PaddlePaddle:developfrom
ssstuding:add_metaclip_model

Conversation

@ssstuding

@ssstuding ssstuding commented Mar 24, 2026

Copy link
Copy Markdown

【MetaCLIP】添加MetaCLIP模型复现

模型介绍

添加 MetaCLIP 模型的 PaddlePaddle 实现。
MetaCLIP 是基于 CLIP 的视觉编码器,通过元数据驱动的数据管理策略,在 CLIP 训练中实现了更好的数据质量和模型性能。

权重文件

MetaCLIP权重已上传至 AI Studio 星河社区:

https://aistudio.baidu.com/modelsdetail/51427/space

其中包括:

  • metaclip_b16.pdparams:转换后的 PaddlePaddle 权重,可用于 PaddleClas 加载。
  • metaclip_b16.safetensors:原始 PyTorch/timm 权重,用于转换参考。

验证内容

  • 前向对齐验证:与 PyTorch 版本输出对齐,误差 < 1e-4
  • 可训练性验证:Loss 可正常下降
  • 性能验证:静态图加速达标

复现精度

前向对齐验证

验证项 结果 说明
Max Absolute Diff < 1e-4 与 PyTorch 版本对齐
Avg Absolute Diff < 1e-6 与 PyTorch 版本对齐
对齐状态 ✅ 通过 前向输出一致

可训练性验证

验证项 结果 说明
初始 Loss 正常 模型初始化正确
Loss 下降 ✅ 正常 梯度回传正常
训练稳定性 ✅ 稳定 无 NaN/Inf

性能验证

验证项 结果 说明
动态图推理 ✅ 正常 -
静态图推理 ✅ 正常 -
静态图加速 > 10% 达标

验证结果的截图:

1BD33894E59BE5A208F4ADEA436E0D35

文件变更

文件 说明
ppcls/arch/backbone/model_zoo/metaclip.py 模型实现
ppcls/configs/MetaCLIP/metaclip_base.yaml 配置文件
docs/zh_CN/models/MetaCLIP/metaclip_base.md 模型文档

- 添加MetaCLIP PaddlePaddle实现
- 包含前向对齐验证
- 包含可训练性验证
- 包含性能验证
@paddle-bot

paddle-bot Bot commented Mar 24, 2026

Copy link
Copy Markdown

Thanks for your contribution!

@CLAassistant

CLAassistant commented Mar 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

- 添加前向对齐验证脚本
- 添加可训练性验证脚本
- 添加性能验证脚本
- 移动模型文件到 model_zoo 目录
- 移动验证脚本到 model_zoo 目录
- 添加模型文档
@@ -0,0 +1,10 @@
Arch:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

配置文件需要写完整,包括数据部分,学习率部分,支持完整的训练流程。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已补全 metaclip_base.yaml,增加 Global、AMP、Loss、Optimizer、DataLoader、Infer、Metric 等完整训练/验证/推理配置,并补充预训练权重和数据路径说明。

@@ -0,0 +1,108 @@
import paddle

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

该模型权重链接需要添加,把权重发给负责人,负责人上传后提供链接

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已将权重上传至 AI Studio 星河社区:
https://aistudio.baidu.com/modelsdetail/51427/space

其中包含转换后的 PaddlePaddle 权重 metaclip_b16.pdparams 和原始 PyTorch/timm 权重 metaclip_b16.safetensors。

import paddle.nn.functional as F
from functools import partial

print("🔍 metaclip_paddle.py is being loaded...")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉没必要的注释

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已清理 metaclip.py 中不必要的调试输出、无用 import 和注释。

@@ -0,0 +1,228 @@
import torch

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metaclip_verify文件夹可以额外提供,但是不要提交pr

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已移除 metaclip_verify 验证脚本目录,不再提交到 PR。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants