Create publication-quality scientific diagrams using Nano Banana Pro AI with smart iterative refinement. Uses Gemini 3 Pro for quality review. Only regenerates if quality is below threshold for your document type. Specialized in neural network architectures, system diagrams, flowcharts, biological pathways, and complex scientific visualizations.
Generate any scientific diagram by describing it in natural language.
Nano Banana Pro creates publication-quality diagrams automatically - no coding, no templates, no manual drawing required.
# Set your OpenRouter API key
export OPENROUTER_API_KEY='your_api_key_here'
# Generate any scientific diagram
python scripts/generate_schematic.py "CONSORT participant flow diagram" -o figures/consort.png
# Neural network architecture
python scripts/generate_schematic.py "Transformer encoder-decoder architecture" -o figures/transformer.png
# Biological pathway
python scripts/generate_schematic.py "MAPK signaling pathway" -o figures/pathway.png
All diagrams automatically follow:
# Get OpenRouter API key
# Visit: https://openrouter.ai/keys
# Set environment variable
export OPENROUTER_API_KEY='sk-or-v1-...'
# Or add to .env file
echo "OPENROUTER_API_KEY=sk-or-v1-..." >> .env
# Install Python dependencies (if not already installed)
pip install requests
python scripts/generate_schematic.py \
"CONSORT participant flow diagram for RCT. \
Assessed for eligibility (n=500). \
Excluded (n=150): age<18 (n=80), declined (n=50), other (n=20). \
Randomized (n=350) into Treatment (n=175) and Control (n=175). \
Lost to follow-up: 15 and 10 respectively. \
Final analysis: 160 and 165." \
-o figures/consort.png
Output:
figures/consort_v1.png - Initial generationfigures/consort_v2.png - After first reviewfigures/consort_v3.png - Final versionfigures/consort.png - Copy of final versionfigures/consort_review_log.json - Detailed review logpython scripts/generate_schematic.py \
"Transformer architecture with encoder on left (input embedding, \
positional encoding, multi-head attention, feed-forward) and \
decoder on right (masked attention, cross-attention, feed-forward). \
Show cross-attention connection from encoder to decoder." \
-o figures/transformer.png \
--iterations 2
python scripts/generate_schematic.py \
"MAPK signaling pathway: EGFR receptor → RAS → RAF → MEK → ERK → nucleus. \
Label each step with phosphorylation. Use different colors for each kinase." \
-o figures/mapk.png
python scripts/generate_schematic.py \
"IoT system block diagram: sensors (bottom) → microcontroller → \
WiFi module and display (middle) → cloud server → mobile app (top). \
Label all connections with protocols." \
-o figures/iot_system.png
python scripts/generate_schematic.py [OPTIONS] "description" -o output.png
Options:
--iterations N Number of AI refinement iterations (default: 2, max: 2)
--api-key KEY OpenRouter API key (or use env var)
-v, --verbose Verbose output
-h, --help Show help message
from scripts.generate_schematic_ai import ScientificSchematicGenerator
# Initialize
generator = ScientificSchematicGenerator(
api_key="your_key",
verbose=True
)
# Generate with iterative refinement
results = generator.generate_iterative(
user_prompt="CONSORT flowchart",
output_path="figures/consort.png",
iterations=2
)
# Access results
print(f"Final score: {results['final_score']}/10")
print(f"Final image: {results['final_image']}")
# Review iterations
for iteration in results['iterations']:
print(f"Iteration {iteration['iteration']}: {iteration['score']}/10")
print(f"Critique: {iteration['critique']}")
✓ "Flowchart with vertical flow, top to bottom"
✓ "Architecture diagram with encoder on left, decoder on right"
✗ "Make a diagram" (too vague)
✓ "Neural network: input (784), hidden (128), output (10)"
✓ "Flowchart: n=500 screened, n=150 excluded, n=350 randomized"
✗ "Some numbers" (not specific)
✓ "Minimalist block diagram with clean lines"
✓ "Detailed biological pathway with protein structures"
✓ "Technical schematic with engineering notation"
✓ "Label all arrows with activation/inhibition"
✓ "Include layer dimensions in each box"
✓ "Show time progression with timestamps"
✓ "Use colorblind-friendly colors"
✓ "Grayscale-compatible design"
✓ "Color-code by function: blue=input, green=processing, red=output"
Each generation produces a JSON review log:
{
"user_prompt": "CONSORT participant flow diagram...",
"iterations": [
{
"iteration": 1,
"image_path": "figures/consort_v1.png",
"prompt": "Full generation prompt...",
"critique": "Score: 7/10. Issues: font too small...",
"score": 7.0,
"success": true
},
{
"iteration": 2,
"image_path": "figures/consort_v2.png",
"score": 8.5,
"critique": "Much improved. Remaining issues..."
},
{
"iteration": 3,
"image_path": "figures/consort_v3.png",
"score": 9.5,
"critique": "Excellent. Publication ready."
}
],
"final_image": "figures/consort_v3.png",
"final_score": 9.5,
"success": true
}
Simply describe what you want - Nano Banana Pro creates it:
Just describe your diagram, and it's generated automatically.
# Check if key is set
echo $OPENROUTER_API_KEY
# Set temporarily
export OPENROUTER_API_KEY='your_key'
# Set permanently (add to ~/.bashrc or ~/.zshrc)
echo 'export OPENROUTER_API_KEY="your_key"' >> ~/.bashrc
# Install requests library
pip install requests
# Or use the package manager
pip install -r requirements.txt
# Use verbose mode to see detailed errors
python scripts/generate_schematic.py "diagram" -o out.png -v
# Check API status
curl https://openrouter.ai/api/v1/models
If iterations consistently score below 7/10:
--iterations 2Run verification tests:
python test_ai_generation.py
This tests:
OpenRouter pricing for models used:
Typical costs per diagram:
See the full SKILL.md for extensive examples including:
For issues or questions:
Part of the scientific-writer package. See main repository for license information.
npx skills add davila7/scientific-schematics下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Category:science-education