Model reference · open weights
DAM-Self-Contained is an open-weight language model from nvidia. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Released by | NVIDIA |
|---|---|
| Type | Language models |
| Task | Vision + text |
| Runs with | describe-anything |
| Based on | Efficient-Large-Model/VILA1.5-3b |
| Released | 2025-04-21 |
| Popularity | 17k downloads / month |
| Licence | Commercial licence needed |
About
NVIDIA, UC Berkeley, UCSF
Long Lian, Yifan Ding, Yunhao Ge, Sifei Liu, Hanzi Mao, Boyi Li, Marco Pavone, Ming-Yu Liu, Trevor Darrell, Adam Yala, Yin Cui
[Paper] | [Code] | [Project Page] | [Video] | [HuggingFace Demo] | [Model/Benchmark/Datasets] | [Citation]
An example code of inference using this self-contained model:
# 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,
'\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).astFrom the published model card. Full card on the HuggingFace links in the sidebar.
Using it via the API
Once AxForge deploys dam-self-contained for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (dam-self-contained below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/chat/completions \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"dam-self-contained","messages":[{"role":"user","content":"Hello"}]}'
Create an account — your API key is available in the console. 3M free tokens every 30 days with every new account.