cellmap_flow.finetune.finetuned_model_templates
Templates for generating finetuned model YAML configurations.
This module provides functions to auto-generate the YAML config for serving finetuned models using FinetuneModelConfig (type: finetune).
Attributes
Functions
|
Generate .yaml configuration for serving a finetuned model. |
|
Build YAML text snapshotting the dashboard's current live server config |
Module Contents
- cellmap_flow.finetune.finetuned_model_templates.logger
- cellmap_flow.finetune.finetuned_model_templates.FINETUNED_MODEL_YAML_MARKER = 'FINETUNED_MODEL_YAML:'
- cellmap_flow.finetune.finetuned_model_templates.PLACEHOLDER_DATA_PATHS
- cellmap_flow.finetune.finetuned_model_templates.generate_finetuned_model_yaml(lora_adapter_path: str = None, base_model_dict: dict = None, model_name: str = None, output_path: pathlib.Path = None, data_path: str = None, queue: str = None, charge_group: str = None, json_data: dict = None, scale: str = None, weights_path: str = None, resample: bool = False, input_voxel_size=None, output_voxel_size=None) pathlib.Path
Generate .yaml configuration for serving a finetuned model.
The generated YAML uses type: finetune, which delegates to FinetuneModelConfig. This loads the base model via its own ModelConfig, applies the LoRA adapter, and serves the result.
- Parameters:
lora_adapter_path – Path to the saved LoRA adapter directory
weights_path – Instead of an adapter, a full state dict from a –lora-r 0 (full finetune) run. Exactly one of the two.
base_model_dict – Dict describing the base model (from model_config.to_dict())
model_name – Name of the finetuned model
output_path – Where to write the .yaml file
data_path – Path to actual dataset (REQUIRED - no placeholders)
queue – LSF queue name; None is the site’s default queue
charge_group – LSF charge group; None is the site’s default one
json_data – Optional dict with input_norm and postprocess from base model
scale – The level of a multiscale
data_pathto serve (“s1”), or None for none. With none, the server picks the level by the model’s input voxel size, which is how the trainer read the samedata_path. This was always “s0”, so a model trained on s1 of a multiscale group was served s0.resample – the model was trained on the raw resampled to its voxel size (its volume’s
resample), so serve it that way tooinput_voxel_size – the voxel sizes the finetune was trained at, when not the base model’s (run_outputs); the served model declares them
output_voxel_size – the voxel sizes the finetune was trained at, when not the base model’s (run_outputs); the served model declares them
- Returns:
Path to the generated YAML file
- cellmap_flow.finetune.finetuned_model_templates.generate_current_config_yaml(models: list, data_path: str, queue: str = None, charge_group: str = None, walltime: str = None, json_data: dict = None, resample: bool = False) str
Build YAML text snapshotting the dashboard’s current live server config (whatever models/normalization/postprocessing/queue are active right now), so it can be handed back to cellmap_flow yaml later.
Unlike generate_finetuned_model_yaml (which describes one specific finetune job), this is a general “export what’s currently running” dump – it doesn’t write to disk itself, callers decide where the result goes (a download response, a file, etc).
- Parameters:
models – list of model entry dicts (each from ModelConfig.to_dict())
data_path – current dataset path
queue – LSF queue name; None is the site’s default queue
charge_group – LSF charge group; None is the site’s default one
walltime – LSF run limit (“HH:MM” or minutes); omitted when unset, so the reloaded config falls back to the built-in default
json_data – dict with “input_norm”/”postprocess” keys reflecting the currently active normalization/postprocessing, if any
resample – the dashboard’s Resample setting, written either way
- Returns:
YAML text (str) ready to write to a file.