image-to-sbgn is a web-service with a demo application that leverages Large Language Models (LLMs) to automatically convert hand-drawn biological network diagrams drawn in SBGN into machine-readable SBGNML files. This tool bridges the gap between sketching biological pathways on paper and creating formal, standardized digital representations.
Try the live demo: https://dev.sciluna.com/image2sbgn/
- Node.js (v20.14.0 or higher)
- npm or yarn package manager
- Clone the repository:
git clone https://github.com/sciluna/image-to-sbgn.git
cd image-to-sbgn- Install dependencies:
npm install- Configure environment variables:
Create a .env file in the root directory with the following variables:
PORT=4000
# API Key for OpenAI
OPENAI_API_KEY=your_openai_key
GEMINI_API_KEY=your_gemini_key- Build the client bundle:
npm run build- Start the service:
npm startThe service and the demo application will be available at http://localhost:4000
Build and run using Docker:
# Build the Docker image
docker build -t image-to-sbgn .
# Run the container
docker run -p 4000:4000 \
-e OPENAI_API_KEY=your_openai_key \
-e GEMINI_API_KEY=your_gemini_key \
image-to-sbgn-
Upload or Select a Sample:
- Upload your hand-drawn SBGN diagram (PNG format recommended)
- Or select one of the provided sample diagrams
-
Choose SBGN Language:
- Process Description (PD): For molecular interaction maps
- Activity Flow (AF): For high-level regulatory networks
-
Select AI Model Provider:
- Gemini (Gemini 3.1 Pro)
- OpenAI (GPT-5.2)
-
Add Optional Comments: Provide additional context or instructions for the AI
-
Generate: Click the "Process Data" button to process your diagram
-
Review and Edit:
- View the converted network in the interactive editor
- Make adjustments if needed
- Ground biological entities using the annotation feature
-
Export: Download the SBGNML file for use in other tools
You can also convert images without the web UI:
OPENAI_API_KEY=your_openai_key node src/cli.js --image ./diagram.png --language PD --model gpt-5.2 --output ./diagram.sbgnOr, after installing dependencies:
OPENAI_API_KEY=your_openai_key npm run cli -- --image ./diagram.png --language PD --model gpt-5.2 --output ./diagram.sbgnGlobal install from a local checkout:
npm install -g /path/to/image-to-sbgn
image-to-sbgn --image ./diagram.png --language PD --output ./diagram.sbgnNotes:
--imageaccepts a local file path or a URL.--outputis optional; omit it to print SBGNML to stdout.--languagesupportsPDandAF(default:PD).
The following SBGN elements are currently not supported:
- Submap
- Ports
Convert hand-drawn SBGN image to SBGNML format.
Request Body:
{
"image": "base64_encoded_image_or_url",
"language": "PD", // or "AF"
"model": "gpt-5.2", // or another OpenAI model
"context:": "Optional additional instructions"
"annotate": false // whether to annotate with identifiers
}Response:
{
"answer": "SBGNML content as string"
}Edit given SBGNML content.
Request Body:
{
"sbgnml": "SBGNML content as string",
"language": "PD", // or "AF"
"model": "gpt-5.2", // or another OpenAI model
"instructions:": "Instructions to edit SBGNML content"
}Response:
{
"answer": "SBGNML content as string"
}Ground biological entities using INDRA service.
Request Body:
[
{
"text": "Entity name"
}
]Response:
[
{
"term": {
"id": "database_id",
"db": "database_name",
"entry_name": "entity_name"
}
}
]Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure your PR:
- Follows the existing code style
- Includes appropriate documentation
- Has been tested with multiple SBGN diagrams
For questions or support, please open an issue on GitHub.
Hasan Balci and Augustin Luna of Luna Lab