Markdown Converter
Agent skill for markdown-converter
> **Guide for AI Agents working on the FRAME project**
Sign in to like and favorite skills
Guide for AI Agents working on the FRAME project
FRAME is a tool suite for refining multimodal measurements through materials digital twins. The project combines generative models with virtual instrumentation to help researchers and scientists better characterize material structures.
This is a uv workspace with three core packages:
frame/ ├── apps/ # Runnable CLIs/services ├── config/ # Workspace configuration │ └── config.toml # FRAME core configuration ├── packages/ │ ├── frame-core/ # Data models, storage, experiment management, unified CLI │ ├── frame-geo/ # Stochastic geometry ("cartoon generator") │ └── frame-twin/ # Diffusion model (training & inference) ├── frame_data/ # Default data root (libraries and experiments) │ ├── libraries/ # UUID-tracked data libraries │ └── experiments/ # UUID-tracked experiments and checkpoints ├── dev/ # Local development sandbox (gitignored) ├── scripts/ # Utility scripts ├── docs/ # MkDocs documentation ├── tests/ # Cross-package E2E tests └── pyproject.toml # Workspace configuration
IMPORTANT:
frame-voxel was deprecated as of commit 8634814. All voxel functionality has been fully integrated into frame-core. Always import from frame.* instead of frame_voxel.*.
frame-core ✅ IMPLEMENTEDPurpose: Foundation for data representation, I/O, and experiment management
Base Data Model: Multi-channel 3D voxel grids
VoxelGrid class with shape (C, D, H, W)Data Management:
LibraryManager - UUID-based library tracking and managementExperimentManager - Experiment tracking with checkpoint managementCheckpointManager - Model checkpoint versioningStorage & I/O:
VoxelGrid data model with validation and metadataVoxelLibrary for Zarr-based storage with lazy loadingVoxelDataset for PyTorch training integrationVisualization:
visualize_napari.py - Interactive 3D viewervisualize_pyvista.py - High-quality 3D renderingvisualize_batch.py - Batch visualization utilitiesUnified CLI:
uv run frame - Central command integrating all packageslist, show, search, tag, untaglist, show, tag, untag, stoplist, show, set-bestview - Interactive napari visualizationMigration Tools:
Module:
from frame import ... (not frame_core)
frame-geo ✅ IMPLEMENTEDPurpose: Stochastic geometry generator for training data
frame-geo generate, validate-config, list-typesframe-twin ✅ IMPLEMENTEDPurpose: Diffusion-based digital twin for 3D voxel structure generation
frame.VoxelLibrary (formerly frame-voxel)packages/Memory and compute are precious.
torch.no_grad() for inference, etc.)typing, numpy.typing, etc.)All computational experiments MUST be tracked with
.ExperimentManager
frame-twin: ✅ Fully integrated
frame-geo: ⚠️ Partially integrated (LibraryManager only)
Best practices:
ExperimentManager.create_experiment() for new runslibrary_uuidContinuing training (as of 2025-10-27):
uv run frame twin continue <exp_uuid> --config <modified.toml> to continue from a checkpointuv run frame experiment show <exp_uuid>uvAlways use
for all package and environment operations.uv
# Add dependencies to a package cd frame/packages/frame-core uv add numpy torch # Add dev dependencies uv add --dev pytest pytest-cov # Sync workspace cd frame/ uv sync # Run commands in the environment uv run pytest uv run python scripts/train.py
pytestpytest as the test frameworktests/packages/<name>/tests/hypothesis)Unified CLI (
frame replaces individual package CLIs):
# Library management uv run frame library list uv run frame library show <uuid> uv run frame library search --tag production # Experiment management uv run frame experiment list --model-type vae uv run frame experiment show <uuid> uv run frame tensorboard <experiment_uuid> # Migration uv run frame migrate output/lnp_5k_10ch --tags production,lnp,10ch # Geometry generation (frame-geo integration) uv run frame geo generate config.toml uv run frame geo list-types # Twin training (frame-twin integration) uv run frame twin train-vae config.toml uv run frame twin train-ddpm config.toml uv run frame twin generate config.toml
Legacy CLIs (still available):
# Individual package CLIs still work uv run frame-geo generate config.toml uv run frame-twin train-vae config.toml
Testing:
# Run tests uv run pytest # Run tests with coverage uv run pytest --cov=frame --cov=frame_geo --cov=frame_twin # Format/lint (configure in root pyproject.toml) uv run ruff check . uv run ruff format . # Type checking uv run mypy packages/
torch.cuda.empty_cache() when appropriatefloat16 or quantization for storageframe-geo and frame-coreframe-geo before voxelizationframe-core has no dependencies on frame-geo or frame-twin ✅frame-geo uses PyTorch tensors compatible with frame-core VoxelGrid ✅frame-twin will depend on frame-core for data models (when implemented)Current Dependency Graph:
frame-core (standalone) ↑ │ (uses compatible tensor format) │ frame-geo (PyTorch, PyMC, Zarr, PyVista) ↑ │ (will consume voxel libraries) │ frame-twin (not yet implemented)
frame/pyproject.tomlframe/packages/*/pyproject.tomlframe/tests/ (E2E), frame/packages/*/tests/ (unit)frame/docs/frame/dev/ (gitignored)frame-core:
torch>=2.0 - PyTorch tensors for voxel gridsnumpy>=1.24 - array operationszarr>=2.16 - efficient array storagenapari>=0.4 - interactive visualizationpyvista>=0.42 - 3D renderingmatplotlib>=3.7 - plottingpandas>=2.0 - parameter tablespytest>=8.4 - testingframe-geo:
torch>=2.0 - PyTorch tensorspymc>=5.0 - probabilistic modelingpytensor>=2.0 - PyMC backendnumpy>=1.24 - numerical operationszarr>=2.16 - storagepyvista>=0.42 - 3D visualizationmatplotlib>=3.7 - 2D cross-sectionspandas>=2.0 - parameter exporttomli>=2.0 - TOML parsingtqdm>=4.65 - progress barspytest>=8.4 - testingFuture (for frame-twin and virtual instruments):
diffusers - diffusion model componentsscipy - scattering calculationsCurrently Implemented (Steps 1-2):
✅ Generate cartoons:
uv run frame-geo generate config.toml
✅ Load and visualize:
from frame_core.storage import VoxelLibrary lib = VoxelLibrary("output/lnp_example/voxels.zarr") grid = lib[0] # Load first structure
Future Steps (Not Yet Implemented): 3. 🚧 Train twin:
frame-twin learns distribution from voxelized cartoons
4. 🚧 Generate ensemble: Sample from trained diffusion model
5. 🚧 Compute virtual data: Virtual instruments compute SAXS/SANS/cryo-EM
6. 🚧 Refine: Adjust ensemble to match experimental data
Two packages are fully implemented and ready to use:
from frame_core.voxel_grid import VoxelGrid from frame_core.storage import VoxelLibrary from frame_core.dataset import VoxelDataset import torch # Create a voxel grid data = torch.zeros(10, 128, 128, 128) # 10 channels grid = VoxelGrid( data=data, voxel_size=1.0, # nanometers channels={'shell1_head': 0, 'shell1_tail': 1, ...}, metadata={'structure_id': 'lnp_001'} ) # Open a voxel library library = VoxelLibrary("path/to/library.zarr", mode='r') n_structures = len(library) single_grid = library[0] # Lazy load # Filter by parameters filtered = library.filter(lambda p: p['shell1_radius_nm'] > 50.0) # PyTorch dataset for training dataset = VoxelDataset(library, device='cuda') loader = torch.utils.data.DataLoader(dataset, batch_size=16)
# 1. Create a configuration file (see examples/lnp_example_config.toml) # 2. Generate structures uv run frame-geo generate config.toml # 3. Check output ls output/lnp_example/ # structures.zarr/ - Parametric representations # voxels.zarr/ - Voxelized grids # parameters.csv - All sampled parameters # statistics.json - Summary statistics # validation_log.json - Rejection tracking
Python API:
from frame_geo import generate_from_config from frame_geo.config import FrameGeoConfig from frame_geo.generator import StructureGenerator # High-level API generate_from_config("config.toml") # Or use advanced API for control config = FrameGeoConfig.from_toml("config.toml") config.validate() generator = StructureGenerator(config) generator.generate_batch() # Access statistics print(f"Accepted: {generator.validation_stats['total_accepted']}") print(f"Rejected: {generator.validation_stats['total_attempts'] - generator.validation_stats['total_accepted']}")
Configuration Example (TOML):
[metadata] random_seed = 42 [structure] type = "lnp" [grid] nx = 128 ny = 128 nz = 128 dx_nm = 1.0 dy_nm = 1.0 dz_nm = 1.0 [generation] num_samples = 1000 [output] base_path = "./output/my_lnps" mode = "overwrite" [priors.shell1_radius_nm] distribution = "Uniform" lower = 40.0 upper = 80.0 # ... more priors ... [voxelization.channels] shell1_head = 0 shell1_tail = 1 # ... more channels ...
# 1. Generate training data cd /path/to/FRAME uv run frame-geo generate packages/frame-geo/examples/lnp_example_config.toml # 2. Load and inspect in Python uv run python
from frame_core.storage import VoxelLibrary import pandas as pd import json # Load voxelized structures lib = VoxelLibrary("output/lnp_example/voxels.zarr") print(f"Generated {len(lib)} structures") # Load parameters params = pd.read_csv("output/lnp_example/parameters.csv") print(params.describe()) # Load statistics with open("output/lnp_example/statistics.json") as f: stats = json.load(f) print(f"Mean shell1 radius: {stats['shell1_radius_nm']['mean']:.2f} nm") # Visualize a structure grid = lib[0] print(f"Grid shape: {grid.shape}") print(f"Channels: {grid.n_channels}") print(f"Physical size: {grid.physical_size} nm")
# Run all tests uv run pytest # Run package-specific tests uv run pytest packages/frame-core/tests/ -v uv run pytest packages/frame-geo/tests/ -v # With coverage uv run pytest --cov=frame_core --cov=frame_geo --cov-report=html
The next package to implement will be
frame-twin, which will:
frame-geouv - for all dependency and environment operations| Package | Status | Lines of Code | Tests | Key Features |
|---|---|---|---|---|
| frame-core | ✅ Complete | ~3500 | 0 | VoxelGrid, VoxelLibrary, LibraryManager, ExperimentManager, unified CLI, migration |
| frame-geo | ✅ Complete | ~2000 | 25 | LNP generator, PyMC priors, 7 validators, hybrid voxelization, CLI integration |
| frame-twin | ✅ Complete | ~1500 | 3 | VAE+DDPM models, 3 conditioning strategies, training infrastructure, CLI integration |
| Virtual Instruments | 🚧 Pending | 0 | 0 | Awaiting implementation |
Current Capabilities:
frame command integrating all packagesNext Steps:
Last Updated: 2025-10-13
Workspace Manager:
uvuv run frame (unified command)frame-voxel has been replaced by frame-core with expanded functionality