超
gcw_g59KKkes/CogACT-CogACT-Base
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

CogACT-CogACT-Base · Ascend NPU (昇腾NPU)

CogACT-Base is a 7B vision-language-action (VLA) model that maps a single-view RGB image + a natural-language instruction to the next 16 (7-DoF) robot end-effector delta actions (x, y, z, roll, pitch, yaw, gripper). It is built on a DINOv2 + SigLIP dual vision encoder, a Llama-2-7B text backbone and a DiT-B diffusion action head, pretrained on Open X-Embodiment.

This repository adapts CogACT/CogACT-Base to run on Ascend NPU via torch_npu (Ascend 910B, npu:0, bfloat16). The vendored model source lives in model_code/ (MIT, from microsoft/CogACT), scrubbed of all CUDA device calls.

NPU adaptation

  • Zero CUDA. All .cuda() / torch.cuda / device="cuda" calls were removed; the model and every input tensor live on npu:0.
  • NPU init is wrapped in try-except → on failure a JSON error is printed and the process exits.
  • The 7B model runs in torch.bfloat16 (Ascend 910B natively supports bf16; 64 GB HBM is enough). torch.compile is intentionally skipped.
  • The vision backbone is instantiated with pretrained=False and the LLM scaffold with inference_mode=True — the real weights are loaded from the local CogACT-Base.pt checkpoint, so no HuggingFace / timm weight download happens at inference time.

Weights & cache

  • Cache path: model_weights/CogACT/CogACT-Base/
    • checkpoints/CogACT-Base.pt — full PyTorch checkpoint (~30 GB, bf16 model + optimizer state; only the model key is used)
    • config.json, config.yaml, dataset_statistics.json
    • llama2-tokenizer/ — local Llama-2 tokenizer (config.json, tokenizer.json …)
  • inference.py automatically uses this local cache. If the checkpoint is missing it refuses to start rather than re-downloading.
  • Primary mirror: https://ai.gitcode.com/hf_mirrors/CogACT/CogACT-Base (fallback: https://hf-mirror.com/CogACT/CogACT-Base).

Usage

Install dependencies (torch + torch_npu for Ascend, see requirements.txt):

pip install -r requirements.txt

CLI

ASCEND_RT_VISIBLE_DEVICES=1 python3 inference.py --img examples/demo.jpg \
    --instr "pick up the object" 2>cli.err | tee cli.log

Prints one JSON object to stdout (CANN noise goes to stderr).

FastAPI server

python3 inference.py --mode server --port 8786
  • GET / — minimal dark-terminal HTML upload page.
  • POST /predict — multipart file (robot-view image) + optional instr form field → same JSON result.
curl -s -F file=@examples/demo.jpg -F instr="pick up the object" \
     http://127.0.0.1:8786/predict | python3 -m json.tool

Example input

  • examples/demo.jpg — a 768×768 JPEG crop of the robot image scripts/aml/test_image.png from the official microsoft/CogACT repository (1024×1024 PNG), demonstrating the input format CogACT expects.

Output JSON schema

{
  "model": "CogACT/CogACT-Base",
  "source": "https://ai.gitcode.com/hf_mirrors/CogACT/CogACT-Base",
  "device": "npu:0",
  "status": "success",
  "instruction": "pick up the object",
  "unnorm_key": "fractal20220817_data",
  "cfg_scale": 1.5,
  "ddim_steps": 10,
  "elapsed_ms": 1234.56,
  "action_dim": 7,
  "num_steps": 16,
  "actions": [[x,y,z,roll,pitch,yaw,gripper], ...],
  "normalized_actions": [[...], ...],
  "first_action": [x,y,z,roll,pitch,yaw,gripper]
}
  • actions — 16 rows × 7 cols of denormalized end-effector deltas (unnormalized with the fractal20220817_data dataset statistics; the gripper channel is binarised to 0/1).
  • normalized_actions — the same actions in [-1, 1] before un-normalisation.

Verification

  • assets/agent_workflow.png — NPU environment check + dependency install + launch.
  • assets/npu_device_call.png — real CLI run (2>cli.err | tee cli.log).
  • assets/model_result.png — FastAPI GET / page + real /predict JSON.

License & acknowledgements

  • Model weights / code: MIT (CogACT, Microsoft Research Asia) · paper · project
  • VLA source vendored under model_code/ from microsoft/CogACT (MIT).