是的,图片通过编码器编码为 token 后,插入的位置就是 <image> 标记的位置。
占位符替换:在 Qwen2VLPlugin.process_messages 中(第 1630-1640 行):
python展开代码while IMAGE_PLACEHOLDER in content:
    image_seqlen = image_grid_thw[num_image_tokens].prod() // merge_length if self.expand_mm_tokens else 1
    content = content.replace(
        IMAGE_PLACEHOLDER, f"<|vision_start|>{self.image_token * image_seqlen}<|vision_end|>", 1
    )
    num_image_tokens += 1
Token 替换:在 Qwen2VLProcessor.__call__ 中(第 150-170 行):
python展开代码while self.image_token in text[i]:
    num_image_tokens = image_grid_thw[index].prod() // merge_length
    text[i] = text[i].replace(self.image_token, "<|placeholder|>" * num_image_tokens, 1)
    index += 1
text[i] = text[i].replace("<|placeholder|>", self.image_token)
你提供的数据格式:
json展开代码{
    "image": "000443568.jpg",
    "width": 700,
    "height": 700,
    "conversations": [
        {
            "from": "human",
            "value": "Write a detailed description of this image..."
        },
        {
            "from": "gpt",
            "value": "The image is of a pair of silver earrings..."
        }
    ]
}
问题分析:
<image> 标记:在 conversations 中没有 <image> 占位符image 字段是单个字符串,但需要与对话中的 <image> 标记对应width 和 height 字段在 LLaMA-Factory 中不会被使用在 tmux 中,默认的鼠标滚轮行为是进入 复制模式(copy-mode) 来查看历史输出(终端日志)。如果你希望 鼠标滚轮向上 直接滚动查看之前的终端日志(而不是触发其他操作),可以这样优化配置:
~/.tmux.conf(如果不存在就新建)bash展开代码nano ~/.tmux.conf  # 或者用 vim
sh展开代码# 启用鼠标支持(包括滚轮、窗格选择)
set -g mouse on
# 鼠标滚轮向上:进入复制模式并向上滚动(查看历史日志)
bind -n WheelUpPane {
    if -F "#{pane_in_mode}" {
        send-keys -M  # 如果已在复制模式,继续滚动
    } {
        copy-mode -e  # 进入复制模式
        send-keys -M  # 模拟向上滚动
    }
}
# 鼠标滚轮向下:退出复制模式或向下滚动
bind -n WheelDownPane {
    if -F "#{pane_in_mode}" {
        send-keys -M  # 如果已在复制模式,继续滚动
    } {
        send-keys -M  # 否则直接发送滚轮事件(可能被终端处理)
    }
}
# 左键拖动:选择文本或调整窗格(根据上下文自动判断)
bind -n MouseDrag1Pane if -F "#{mouse_any_flag}" {
    if -F "#{pane_in_mode}" {
        # 在复制模式中:继续选择文本
        send-keys -M
    } {
        # 不在复制模式:调整窗格大小或交互
        select-pane -M
    }
}
# 左键单击:激活窗格或开始选择
bind -n MouseDown1Pane select-pane -M \; send-keys -M
# 确保终端兼容性(防止鼠标事件被拦截)
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
这个指令看zip文件里的文件数量,最后一行显示就是:
bash展开代码unzip -l img.zip | tail -n 10
比如显示:
bash展开代码--------- ------- 228209166917 1031993 files
解压后,假如解压到img目录,这个指令查看img目录下多少个文件:
bash展开代码find img -type f | wc -l
比如显示:
bash展开代码1031992
这是对的,举例来说因为里面有父目录信息:
bash展开代码root@gpu-a800-0051:~# unzip -l test.zip | tail -n 10
Archive:  test.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2025-07-19 01:23   test/
        0  2025-07-19 01:23   test/1
        0  2025-07-19 01:23   test/2
---------                     -------
        0                     3 files
下载模型:
bash展开代码modelscope download Qwen/Qwen2.5-VL-7B-Instruct --local_dir ./Qwen/Qwen2.5-VL-7B-Instruct
模型位置:
bash展开代码/mnt/jfs/model/Qwen/Qwen2.5-VL-7B-Instruct-train2-28488x/train2-28488x
开启api:
bash展开代码python -m vllm.entrypoints.openai.api_server \ --model /mnt/jfs/model/Qwen/Qwen2.5-VL-7B-Instruct-train2-28488x/train2-28488x \ --gpu_memory_utilization 0.9 \ --data-parallel-size 2 \ --tensor_parallel_size 1 \ --served-model-name gpt \ --port 8000
重启大法好。
powershell:
bash展开代码wsl --shutdown
bash展开代码wsl
JuiceFS 是一款高性能分布式文件系统,专为云环境设计,核心特点是将对象存储与缓存层结合,提供接近本地文件系统的性能体验。
展开代码[客户端应用] ← POSIX/FUSE接口 → [JuiceFS 客户端] ↓ [元数据引擎 (Redis/MySQL等)] ↓ [对象存储 (S3/OSS/HDFS等)]
去https://platform.stepfun.com/account-info 得到密钥:
xxx
请求代码:
bash展开代码from openai import OpenAI
import os
import base64
 
API_KEY= "xxx"
client = OpenAI(api_key=API_KEY, base_url="https://api.stepfun.com/v1")
# 读取本地图片并转换为base64
def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode('utf-8')
# 编码本地图片
base64_image = encode_image("image.png")
 
completion = client.chat.completions.create(
  model="step-1o-turbo-vision",
  messages=[
      {
          "role": "system",
          "content": "你是一个超可爱的台湾妹子AI助手!说话要像台湾女生一样活泼可爱,用一些台湾腔调,比如'哇塞'、'真的假的'、'超棒的'、'好厉害哦'这样的词汇。回复要简短有趣,就像跟朋友聊天一样轻松自然。看到图片要像台湾女生一样兴奋地描述,用一些可爱的语气词。记住要保持台湾女生的那种活泼开朗的个性哦。回复需要是简体中文回复。",
      },
      # 在对话中传入图片,来实现基于图片的理解
      {
          "role": "user",
          "content": [
              {
                  "type": "text",
                  "text": "用优雅的语言描述这张图片",
              },
              {
                  "type": "image_url",
                  "image_url": {
                      "url": f"data:image/png;base64,{base64_image}"
                  },
              },
          ],
      },
  ],
)
 
print(completion.model_dump_json(indent=3))