網頁

2024年10月16日 星期三

Jetson Container 使用紀錄,二

因為這次更新到 Jetpack 6.0, 所以測試得很順利

參考 https://jetsonhacks.com/2023/08/07/speech-ai-on-nvidia-jetson-tutorial/
註冊 NGC
生成 API 密鑰
$ ngc config set
$ ngc registry resource download-version nvidia/riva/riva_quickstart_arm64:2.17.0
$ cd riva_quickstart
$ vi config.sh
service_enabled_nlp=false
service_enabled_nmt=false
$ sudo bash riva_init.sh
$ sudo bash riva_start.sh
安裝 https://github.com/nvidia-riva/python-clients.git

### 文字介面
$ jetson-containers run --env HUGGINGFACE_TOKEN=hf_abc123def \
  $(./autotag nano_llm) \
  python3 -m nano_llm.chat --api=mlc \
    --model meta-llama/Llama-2-7b-chat-hf \
    --quantization q4f16_ft

### llamaspeak
$ jetson-containers run --env HUGGINGFACE_TOKEN=hf_xyz123abc456 \
  $(autotag nano_llm) \
  python3 -m nano_llm.agents.web_chat --api=mlc \
    --model meta-llama/Meta-Llama-3-8B-Instruct \
    --asr=riva --language-code=zh-CN --tts=piper --voice=zh_CN-huayan-x_low --web-port 8050

https://IP_ADDRESS:8050
can you describe the image?

##Multimodality
$ jetson-containers run $(autotag nano_llm) \
  python3 -m nano_llm.agents.web_chat --api=mlc \
    --model Efficient-Large-Model/VILA-7b \
    --asr=riva --tts=piper

### Agent Studio
# python3 -m nano_llm.studio
https://IP_ADDRESS:8050

參考 https://ithelp.ithome.com.tw/articles/10347557
輸出的中文語音:修改/opt/NanoLLM/nano_llm/plugins/speech/piper_tts.py,將裡面的en_US-libritts-high模型(有兩處)改成zh_CN-huayan-medium模型。這裡可以選擇的中文模型,可以在/data/models/piper/voices.json裡找到,請用關鍵字zh-CN搜索,會找到zh_CN-huayan-medium與zh_CN-huayan-x_low兩組可用的中文語言

### text-generation-webui
$ jetson-containers run $(autotag text-generation-webui)
http://<IP_ADDRESS>:7860

### ollama (Open WebUI)
$ jetson-containers run --name ollama $(autotag ollama)
# /bin/ollama run llama3
$ docker run -it --rm --network=host --add-host=host.docker.internal:host-gateway ghcr.io/open-webui/open-webui:main
http://JETSON_IP:8080

### Stable Diffusion
$ jetson-containers run $(autotag stable-diffusion-webui)
http://<IP_ADDRESS>:7860
txt2img: a person sitting at an office desk working
img2img: 先放一張圖
1. 右上 Generate 下方有 Interrogate CLIP 和 Interrogate DeepBooru 兩按鈕,可讀取圖片資訊
2. 可修改讀取出的資訊,按 Generate, 重新產生圖
3. 選 Resize and fill, 並配合不同的 Denising strength, 按 Generate, 重新產生圖
4. 選 Just resize, 並配合不同的 Denising strength, 按 Generate, 重新產生圖
5. Inpaint: 在 prompt 上填入 sunglasses, 將圖片上的眼睛位置塗黑, 按 Generate, 重新產生圖

### Stable Diffusion XL
$ CONTAINERS_DIR=`pwd`
$ MODEL_DIR=$CONTAINERS_DIR/data/models/stable-diffusion/models/Stable-diffusion/
$ sudo chown -R $USER $MODEL_DIR
$ wget -P $MODEL_DIR https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors
$ wget -P $MODEL_DIR https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0.safetensors
左上角 Stable Diffusion checkpoint 選擇 sd_xl_base_1.0.safetensors
Generation tab 點選 Refiner 選擇 sd_xl_refiner_1.0.safetensors
改 width/height 到 1024
txt2img: photograph of a friendly robot alongside a person climbing a mountain 

### Jetson Copilot
git clone https://github.com/NVIDIA-AI-IOT/jetson-copilot/
cd jetson-copilot
./setup_environment.sh
./launch_jetson_copilot.sh
http://JETSON_IP:8501


$ virtualenv --system-site-packages tensorrt

$ docker ps -a
$ docker kill wqerqwer

沒有留言:

張貼留言