DAM 3B Self Contained
模型概述
該模型通過焦點提示和局部視覺骨幹網絡整合全圖上下文與細粒度局部細節,用於生成圖像的精細化局部描述。
模型特點
精細化局部描述
能夠根據用戶指定的圖像區域生成詳細的局部描述
多模態輸入支持
支持點、框、塗鴉和掩碼等多種形式的區域指定方式
上下文整合
通過焦點提示和門控交叉注意力機制整合全圖上下文與局部細節
模型能力
圖像區域描述生成
多模態輸入處理
精細化視覺理解
使用案例
計算機視覺
圖像標註
為圖像中的特定區域生成詳細描述
提高圖像標註的精確度和細節
視覺輔助
為視障人士提供圖像內容的詳細描述
增強視覺信息的可訪問性
🚀 描述一切:詳細的局部圖像和視頻字幕生成
NVIDIA、加州大學伯克利分校、加州大學舊金山分校聯合推出的模型,可根據用戶指定的圖像區域生成詳細描述,助力圖像和視頻的理解與分析。
🚀 快速開始
以下是使用這個自包含模型進行推理的示例代碼:
# Copyright 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-License-Identifier: Apache-2.0
import torch
import numpy as np
from PIL import Image
from transformers import SamModel, SamProcessor, AutoModel
import cv2
import requests
from io import BytesIO
def apply_sam(image, input_points=None, input_boxes=None, input_labels=None):
inputs = sam_processor(image, input_points=input_points, input_boxes=input_boxes,
input_labels=input_labels, return_tensors="pt").to(device)
with torch.no_grad():
outputs = sam_model(**inputs)
masks = sam_processor.image_processor.post_process_masks(
outputs.pred_masks.cpu(),
inputs["original_sizes"].cpu(),
inputs["reshaped_input_sizes"].cpu()
)[0][0]
scores = outputs.iou_scores[0, 0]
mask_selection_index = scores.argmax()
mask_np = masks[mask_selection_index].numpy()
return mask_np
def add_contour(img, mask, input_points=None, input_boxes=None):
img = img.copy()
mask = mask.astype(np.uint8) * 255
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(img, contours, -1, (1.0, 1.0, 1.0), thickness=6)
if input_points is not None:
for points in input_points:
for x, y in points:
cv2.circle(img, (int(x), int(y)), radius=10, color=(1.0, 0.0, 0.0), thickness=-1)
cv2.circle(img, (int(x), int(y)), radius=10, color=(1.0, 1.0, 1.0), thickness=2)
if input_boxes is not None:
for box_batch in input_boxes:
for box in box_batch:
x1, y1, x2, y2 = map(int, box)
cv2.rectangle(img, (x1, y1), (x2, y2), color=(1.0, 1.0, 1.0), thickness=4)
cv2.rectangle(img, (x1, y1), (x2, y2), color=(1.0, 0.0, 0.0), thickness=2)
return img
def print_streaming(text):
print(text, end="", flush=True)
if __name__ == '__main__':
# Download the image via HTTP
image_url = 'https://github.com/NVlabs/describe-anything/blob/main/images/1.jpg?raw=true'
response = requests.get(image_url)
img = Image.open(BytesIO(response.content)).convert('RGB')
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
sam_model = SamModel.from_pretrained("facebook/sam-vit-huge").to(device)
sam_processor = SamProcessor.from_pretrained("facebook/sam-vit-huge")
image_size = img.size # (width, height)
# Initialize DAM model once
model = AutoModel.from_pretrained(
'nvidia/DAM-3B-Self-Contained',
trust_remote_code=True,
torch_dtype='torch.float16'
).to(device)
dam = model.init_dam(conv_mode='v1', prompt_mode='full+focal_crop')
# Define two runs: one with points, one with box
runs = [
{
'use_box': False,
'points': [[1172, 812], [1572, 800]],
'output_image_path': 'output_visualization_points.png'
},
{
'use_box': True,
'box': [800, 500, 1800, 1000],
'output_image_path': 'output_visualization_box.png'
}
]
for run in runs:
if run['use_box']:
# Prepare box input
coords = run['box']
input_boxes = [[coords]]
print(f"Running inference with input_boxes: {input_boxes}")
mask_np = apply_sam(img, input_boxes=input_boxes)
vis_points = None
vis_boxes = input_boxes
else:
# Prepare point input
pts = run['points']
input_points = [pts]
input_labels = [[1] * len(pts)]
print(f"Running inference with input_points: {input_points}")
mask_np = apply_sam(img, input_points=input_points, input_labels=input_labels)
vis_points = input_points
vis_boxes = None
# Convert mask and describe
mask = Image.fromarray((mask_np * 255).astype(np.uint8))
print("Description:")
for token in dam.get_description(
img,
mask,
'<image>\nDescribe the masked region in detail.',
streaming=True,
temperature=0.2,
top_p=0.5,
num_beams=1,
max_new_tokens=512
):
print_streaming(token)
print() # newline
# Save visualization with contour
img_np = np.asarray(img).astype(float) / 255.0
img_with_contour_np = add_contour(img_np, mask_np,
input_points=vis_points,
input_boxes=vis_boxes)
img_with_contour_pil = Image.fromarray((img_with_contour_np * 255.0).astype(np.uint8))
img_with_contour_pil.save(run['output_image_path'])
print(f"Output image with contour saved as {run['output_image_path']}")
✨ 主要特性
- 精準區域描述:Describe Anything Model 3B(DAM - 3B)能夠接收用戶以點、框、塗鴉或掩碼形式指定的圖像區域,並生成詳細的局部圖像描述。
- 創新架構設計:該模型採用新穎的焦點提示和通過門控交叉注意力增強的局部視覺骨幹網絡,將全圖像上下文與細粒度的局部細節相結合。
- 適用範圍明確:僅用於研究和開發,可進行非商業使用。
📚 詳細文檔
模型卡片
描述
Describe Anything Model 3B(DAM - 3B)接收用戶在圖像中以點、框、塗鴉或掩碼形式指定的區域作為輸入,並生成詳細的局部圖像描述。DAM使用新穎的焦點提示和通過門控交叉注意力增強的局部視覺骨幹網絡,將全圖像上下文與細粒度的局部細節相結合。該模型僅用於研究和開發,可進行非商業使用。
許可證
預期用途
此模型旨在展示和促進對描述任何事物模型的理解和使用。它主要應用於研究和非商業目的。
模型架構
屬性 | 詳情 |
---|---|
架構類型 | Transformer |
網絡架構 | ViT和Llama |
該模型基於VILA - 1.5開發,擁有30億個模型參數。
輸入
屬性 | 詳情 |
---|---|
輸入類型 | 圖像、文本、二進制掩碼 |
輸入格式 | RGB圖像、二進制掩碼 |
輸入參數 | 二維圖像、二維二進制掩碼 |
其他輸入相關屬性 | RGB圖像為3通道,二進制掩碼為1通道。分辨率為384x384 |
輸出
屬性 | 詳情 |
---|---|
輸出類型 | 文本 |
輸出格式 | 字符串 |
輸出參數 | 一維文本 |
其他輸出相關屬性 | 視覺區域的詳細描述 |
支持的硬件微架構兼容性:
- NVIDIA安培
- NVIDIA霍珀
- NVIDIA洛維拉爾
首選/支持的操作系統:
- Linux
訓練數據集
評估數據集
我們在詳細的局部字幕基準測試中評估我們的模型:DLC - Bench
推理
PyTorch
倫理考量
NVIDIA認為可信AI是一項共同責任,我們已經制定了政策和實踐,以支持廣泛的AI應用開發。當根據我們的服務條款下載或使用時,開發者應與他們的內部模型團隊合作,確保該模型滿足相關行業和用例的要求,並解決不可預見的產品濫用問題。
請在此報告安全漏洞或NVIDIA AI相關問題。
📄 許可證
本項目採用NVIDIA非商業許可證。
📖 引用
如果您使用我們的工作或本倉庫中的實現,或者認為它們有幫助,請考慮引用:
@article{lian2025describe,
title={Describe Anything: Detailed Localized Image and Video Captioning},
author={Long Lian and Yifan Ding and Yunhao Ge and Sifei Liu and Hanzi Mao and Boyi Li and Marco Pavone and Ming-Yu Liu and Trevor Darrell and Adam Yala and Yin Cui},
journal={arXiv preprint arXiv:2504.16072},
year={2025}
}
Clip Vit Large Patch14
CLIP是由OpenAI開發的視覺-語言模型,通過對比學習將圖像和文本映射到共享的嵌入空間,支持零樣本圖像分類
圖像生成文本
C
openai
44.7M
1,710
Clip Vit Base Patch32
CLIP是由OpenAI開發的多模態模型,能夠理解圖像和文本之間的關係,支持零樣本圖像分類任務。
圖像生成文本
C
openai
14.0M
666
Siglip So400m Patch14 384
Apache-2.0
SigLIP是基於WebLi數據集預訓練的視覺語言模型,採用改進的sigmoid損失函數,優化了圖像-文本匹配任務。
圖像生成文本
Transformers

S
google
6.1M
526
Clip Vit Base Patch16
CLIP是由OpenAI開發的多模態模型,通過對比學習將圖像和文本映射到共享的嵌入空間,實現零樣本圖像分類能力。
圖像生成文本
C
openai
4.6M
119
Blip Image Captioning Base
Bsd-3-clause
BLIP是一個先進的視覺-語言預訓練模型,擅長圖像描述生成任務,支持條件式和非條件式文本生成。
圖像生成文本
Transformers

B
Salesforce
2.8M
688
Blip Image Captioning Large
Bsd-3-clause
BLIP是一個統一的視覺-語言預訓練框架,擅長圖像描述生成任務,支持條件式和無條件式圖像描述生成。
圖像生成文本
Transformers

B
Salesforce
2.5M
1,312
Openvla 7b
MIT
OpenVLA 7B是一個基於Open X-Embodiment數據集訓練的開源視覺-語言-動作模型,能夠根據語言指令和攝像頭圖像生成機器人動作。
圖像生成文本
Transformers 英語

O
openvla
1.7M
108
Llava V1.5 7b
LLaVA 是一款開源多模態聊天機器人,基於 LLaMA/Vicuna 微調,支持圖文交互。
圖像生成文本
Transformers

L
liuhaotian
1.4M
448
Vit Gpt2 Image Captioning
Apache-2.0
這是一個基於ViT和GPT2架構的圖像描述生成模型,能夠為輸入圖像生成自然語言描述。
圖像生成文本
Transformers

V
nlpconnect
939.88k
887
Blip2 Opt 2.7b
MIT
BLIP-2是一個視覺語言模型,結合了圖像編碼器和大型語言模型,用於圖像到文本的生成任務。
圖像生成文本
Transformers 英語

B
Salesforce
867.78k
359
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98