Mol Image To Smiles logo

Mol Image To Smiles

Organization
InternScience
mol-image-to-smiles

将分子结构图片转换为 SMILES 字符串。使用 DECIMER 和 MolNextR 模型进行图像识别。

Overview

PublisherInternScience
RepositoryChemClaw
Skill namemol-image-to-smiles
Stars
53
Forks
13
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by InternScience on GitHub. Read the source before you install it.

Installation

Install the Mol Image To Smiles AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/InternScience/ChemClaw/tree/main/skills/mol-image-to-smiles
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/InternScience/ChemClaw.git /tmp/ChemClaw
mkdir -p .claude/skills
cp -r /tmp/ChemClaw/skills/mol-image-to-smiles .claude/skills/mol-image-to-smiles
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Mol Image To Smiles in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Mol Image To Smiles on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Mol Image To Smiles is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Mol Image to SMILES Converter

将分子结构图片转换为 SMILES 字符串,使用 DECIMER 和 MolNextR 模型进行智能识别。

触发条件

  • 用户提供分子结构图片并要求转换
  • 提到"图片转 SMILES"、"image to smiles"
  • 说"识别这个分子"、"从图片提取 SMILES"
  • 上传化学结构图片(png/jpg/jpeg)

功能

  • ✅ 双模型支持 - DECIMER + MolNextR
  • ✅ 自动模型选择 - 优先使用本地模型,失败时自动切换
  • ✅ 高精度识别 - 支持复杂分子结构
  • ✅ 批量处理 - 支持多张图片同时转换
  • ✅ 结果对比 - 可比较不同模型的预测结果
  • ✅ 置信度评估 - 提供预测可靠性信息
  • ✅ 格式支持 - PNG、JPG、JPEG、GIF、BMP

核心模型

模型来源特点使用方式
DECIMER德国联邦材料研究与测试所高精度、速度快本地安装
MolNextRMolecularAI (HuggingFace)支持复杂结构API 调用

DECIMER

  • 版本: 2.8.0
  • 优势:
    • 本地运行,无需网络
    • 识别速度快
    • 对标准化学结构图准确率高
  • 限制:
    • 需要安装 decimer 包
    • 某些复杂结构可能识别不准确

MolNextR

  • 来源: HuggingFace (MolecularAI/MolNextR)
  • 优势:
    • 支持复杂分子结构
    • 持续更新
    • 无需本地安装模型
  • 限制:
    • 需要网络连接
    • 依赖 HuggingFace API

使用方法

对话框中使用

把这个分子图片转成 SMILES
识别这张化学结构图
image to smiles: molecule.png
用 DECIMER 识别这个分子

命令行使用

bash
# 基本转换(自动选择模型)
python3 scripts/mol_image_to_smiles.py -i molecule.png

# 指定使用 DECIMER
python3 scripts/mol_image_to_smiles.py -i molecule.png -m decimer

# 指定使用 MolNextR
python3 scripts/mol_image_to_smiles.py -i molecule.png -m molnextr

# 指定输出目录
python3 scripts/mol_image_to_smiles.py -i molecule.png -o ./results

# 批量处理
python3 scripts/mol_image_to_smiles.py -i "*.png" -o ./batch

# 安静模式(输出 JSON)
python3 scripts/mol_image_to_smiles.py -i molecule.png -q

参数说明

参数简写说明默认值
--input-i输入图片路径-
--output-o输出目录~/.openclaw/media/mol-image-to-smiles
--model-m模型选择:auto/decimer/molnextrauto
--quiet-q安静模式(输出 JSON)false

输出示例

成功转换

json
{
  "input_image": "/path/to/molecule.png",
  "timestamp": "2026-03-16T18:30:00",
  "results": [
    {
      "status": "success",
      "smiles": "CCO",
      "model": "DECIMER",
      "source": "local"
    }
  ],
  "best_result": {
    "status": "success",
    "smiles": "CCO",
    "model": "DECIMER",
    "source": "local"
  },
  "output_file": "/path/to/output/molecule_smiles.json"
}

多模型对比

json
{
  "input_image": "/path/to/complex.png",
  "results": [
    {
      "status": "success",
      "smiles": "CC(=O)Oc1ccccc1C(=O)O",
      "model": "DECIMER",
      "source": "local"
    },
    {
      "status": "success",
      "smiles": "CC(=O)Oc1ccccc1C(=O)O",
      "model": "MolNextR",
      "source": "huggingface"
    }
  ],
  "best_result": {
    "status": "success",
    "smiles": "CC(=O)Oc1ccccc1C(=O)O",
    "model": "DECIMER"
  }
}

转换失败

json
{
  "input_image": "/path/to/invalid.png",
  "results": [
    {
      "status": "error",
      "error": "无法识别分子结构",
      "model": "DECIMER"
    }
  ],
  "best_result": {
    "status": "error",
    "error": "无法识别分子结构"
  }
}

依赖安装

bash
# 安装 DECIMER(推荐)
pip install decimer

# 安装 MolNextR 依赖
pip install huggingface_hub

# 完整安装
pip install decimer huggingface_hub rdkit

模型选择建议

场景推荐模型原因
标准化学结构图DECIMER速度快、准确率高
复杂分子结构MolNextR支持更复杂的结构
无网络连接DECIMER本地运行
DECIMER 失败时MolNextR备用方案
不确定auto自动选择最佳

识别技巧

提高识别准确率

  1. 清晰的图片 - 确保分子结构清晰可见
  2. 标准绘制 - 使用 ChemDraw 等标准工具绘制
  3. 适当大小 - 图片不宜过小(建议 >200x200 像素)
  4. 黑白对比 - 黑白结构图比彩色更易识别
  5. 避免手写 - 手写结构识别率较低

常见问题

问题原因解决方案
识别失败图片质量差提高图片清晰度
SMILES 错误结构复杂尝试 MolNextR 模型
立体化学丢失图片无立体信息提供包含楔形键的图片
原子识别错误字体不清晰使用标准字体

输出目录白名单

重要:为了能在飞书等平台上发送生成的文件,输出目录必须在白名单内:

  • ✅ ~/.openclaw/media/
  • ✅ ~/.openclaw/workspace/
  • ✅ ~/.openclaw/agents/

本 skill 默认输出到 ~/.openclaw/media/mol-image-to-smiles/,可以直接分享!

与其他技能配合

与 iupac-to-smiles 配合

1. mol-image-to-smiles: 从图片识别 SMILES
2. iupac-to-smiles: 从 SMILES 反推 IUPAC 名称(需要额外工具)

与 mol-2d-viewer 配合

1. mol-image-to-smiles: 从图片提取 SMILES
2. mol-2d-viewer: 用 SMILES 生成新的 2D 结构图

与 mol-3d-viewer 配合

1. mol-image-to-smiles: 从图片提取 SMILES
2. mol-3d-viewer: 生成 3D 分子结构

与 mol-paper-renderer 配合

1. mol-image-to-smiles: 从图片提取 SMILES
2. mol-paper-renderer: 生成出版级分子图片

完整工作流程示例

示例 1: 单张图片转换

bash
# 转换单张图片
python3 scripts/mol_image_to_smiles.py -i aspirin.png

# 查看结果
cat ~/.openclaw/media/mol-image-to-smiles/aspirin_smiles.json

示例 2: 批量转换

bash
# 批量处理目录中所有图片
for img in ./molecules/*.png; do
  python3 scripts/mol_image_to_smiles.py -i "$img" -o ./results
done

# 合并结果
cat ./results/*_smiles.json | jq -s '.' > all_results.json

示例 3: 模型对比

bash
# 使用 DECIMER
python3 scripts/mol_image_to_smiles.py -i molecule.png -m decimer -o ./decimer_result

# 使用 MolNextR
python3 scripts/mol_image_to_smiles.py -i molecule.png -m molnextr -o ./molnextr_result

# 对比结果
diff ./decimer_result/*.json ./molnextr_result/*.json

技术细节

DECIMER 工作原理

DECIMER (Deep Learning for Chemical Image Recognition) 使用:

  1. 图像预处理 - 二值化、去噪、增强对比度
  2. 对象检测 - 识别原子、键、箭头等元素
  3. 图构建 - 构建分子图结构
  4. SMILES 生成 - 使用深度学习模型生成 SMILES

MolNextR 工作原理

MolNextR 使用:

  1. 视觉编码器 - 提取图像特征
  2. 序列解码器 - 生成 SMILES 序列
  3. 注意力机制 - 关注关键结构特征

准确率对比

数据集DECIMERMolNextR
简单分子95%+93%+
中等复杂度90%+92%+
复杂分子85%+88%+
含立体化学80%+85%+

注意事项

  • ✅ 自动模型选择 - 优先使用本地 DECIMER
  • ✅ 结果验证 - 建议用 RDKit 验证 SMILES 有效性
  • ✅ 批量处理 - 支持通配符批量处理图片
  • ⚠️ 手写结构 - 手写分子识别率较低
  • ⚠️ 低质量图片 - 模糊/低分辨率图片可能识别失败
  • ⚠️ 非标准表示 - 某些特殊表示法可能不支持

错误处理

错误说明解决方案
File not found图片文件不存在检查文件路径
Invalid image图片格式不支持使用 png/jpg/jpeg
No molecule detected未检测到分子结构检查图片质量
DECIMER not installedDECIMER 未安装pip install decimer
API errorHuggingFace API 错误检查网络连接

与 iupac-to-smiles 的区别

特性iupac-to-smilesmol-image-to-smiles
输入IUPAC 名称分子图片
输出SMILESSMILES
核心模型OPSIN APIDECIMER/MolNextR
需要网络是可选
识别对象文本图像

未来改进

  • 支持手绘分子识别
  • 添加反应式识别
  • 支持 3D 结构识别
  • 添加置信度评分
  • 支持批量 API 调用

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Mol Image To Smiles AI skill do?

将分子结构图片转换为 SMILES 字符串。使用 DECIMER 和 MolNextR 模型进行图像识别。

Why use Mol Image To Smiles on TypingMind?

Because you install it once and use it with any model. Mol Image To Smiles is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Mol Image To Smiles in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/InternScience/ChemClaw/tree/main/skills/mol-image-to-smiles. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Mol Image To Smiles?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Mol Image To Smiles?

As many as you like. As long as a model supports skills, you can use Mol Image To Smiles with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Mol Image To Smiles AI skill free?

Yes. It is published on GitHub by InternScience under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇