Showing posts with label tars. Show all posts
Showing posts with label tars. Show all posts

Wednesday, 26 March 2025

UI-TARS 本地部署:手残党福音,自然语言控电脑!- UI-TARS Local Deployment: Natural Language Control for Your Computer!

快速部署 UI-TARS,让你的电脑听懂人话!- Quick deployment of UI-TARS, make your computer understand human language!



UI-TARS本地部署指南(以Mac为例):


一、前置条件

系统:macOS Ventura 或更高版本

Python:3.9+(可通过 Homebrew 安装)


存储:至少 10GB 可用空间


二、部署步骤

1. 安装基础依赖


# 安装 Homebrew(已安装可跳过)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"


# 安装 Python 和 Git(以python3.9为例, 不能低于3.9)

brew install python@3.9 git


# 创建并激活虚拟环境

python3.9 -m venv uitars_env && source uitars_env/bin/activate


2. 安装 PyTorch 和依赖


# 安装适配 Mac M芯片的 PyTorch

pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu


# 克隆仓库

git clone https://github.com/bytedance/UI-TARS.git && cd UI-TARS


# 安装项目依赖

pip install -r requirements.txt huggingface-hub bitsandbytes


3. 下载轻量模型


# 下载 Phi-2 模型(约 5GB), 如果硬件条件好,可以试试phi4

mkdir -p models/phi-2

huggingface-cli download microsoft/phi-2 --local-dir models/phi-2


4. 配置参数文件


# 修改配置文件(尽量只用CPU)

echo 'device: "cpu"\nmodel_path: "models/phi-2"\nquantize: 4bit' > configs/local_config.yaml


三、验证安装


1. 检查模型加载

python3 -c "from transformers import AutoModelForCausalLM; AutoModelForCausalLM.from_pretrained('models/phi-2'); print('✅ 模型加载成功')"


如果输出 模型加载成功!,则说明环境配置正确。


2. 运行示例


# 创建测试图片目录

mkdir test_images && curl -o test_images/demo.png https://example.com/sample-ui.png


# 执行推理

python3 scripts/predict.py --image test_images/demo.png --config configs/local_config.yaml


# 查看结果

cat outputs/demo.json