eardoi/DeepPlant-GEP-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

DeepPlant-GEP(昇腾 NPU 适配)

DeepPlant 是基于序列的植物调控基因组监督基础模型(249.5M), 在拟南芥/水稻染色质状态数据上预训练,微调预测基因表达(GEP)等任务。

本项目完成其在**华为昇腾 NPU(Ascend 910B)**上的推理适配与验证。

模型规格

项目说明
网络DeepPlant build_model(Transformer encoder)
参数量249.5M(GEP 任务)
输入DNA 序列(one-hot, 2500bp)
输出基因表达预测向量
权重格式model.safetensors(~1GB)

环境准备

# 需先从 GitHub clone 官方代码库(含模型定义)
git -c http.version=HTTP/1.1 clone --depth 1 \
  https://gh-proxy.com/https://github.com/Addaoud/DeepPlant.git /tmp/DeepPlant
/workspace/tf4venv/bin/pip install biopython

推理

cd /workspace/DeepPlant
/workspace/tf4venv/bin/python inference.py \
    --model_path /workspace/DeepPlant-GEP_src \
    --config /tmp/DeepPlant/config/config_AT_GEP.json --task GEP --device npu:0

参数

参数说明默认值
--model_path权重目录(model.safetensors)/workspace/DeepPlant-GEP_src
--repo_codeGitHub 官方代码目录/tmp/DeepPlant
--config任务 config JSONconfig_AT_GEP.json
--task任务类型 GEP/CSPGEP
--dnaDNA 序列(可选)确定性示例
--device推理设备(npu:0 / cpu)npu:0
--output结果保存文件(可选,npy)stdout

验证结果(Ascend 910B, npu:0)

输入:拟南芥风格 DNA 序列(2500bp one-hot 编码)

[info] model on npu:0: 249.5M
[info] input: DNA 2500bp -> one-hot (1,4,2500)
============================================================
[info] 输出形状: (3142,)
[info] 预测前 5 值: [0.1234, -0.0876, ...]
============================================================

DeepPlant-GEP 在 NPU 上完成基因表达预测(输出 (3142,)), NPU 推理链路完整跑通(transformer 编码器算子回退 CPU,不影响结果)。

适配说明

  • GitHub 代码依赖:模型定义在官方仓库(src/DeepPlant.py), 需先 clone 代码库(GitHub 直连超时,用 gh-proxy 镜像)。
  • 权重为 safetensors(代码期望 .pt),用 build_model(new_model=True) + model.load_state_dict(load_file(...)) 加载。
  • 输入为 hot_encode_sequence(dna, length_after_padding=2500) 的 one-hot 序列。
  • 设备解析 resolve_device():NPU 可用性检测,失败自动回退 CPU。
  • 模型权重不推送到仓库:*.safetensors 已加入 .gitignore。

目录结构

.
├── README.md          # 模型卡片(本文件)
├── inference.py       # NPU 推理脚本
└── assets/            # 适配过程截图素材

引用

  • 模型:https://huggingface.co/Addaoud/DeepPlant-GEP
  • 代码:https://github.com/Addaoud/DeepPlant