Spaces:
Running
Download workflow/docs/REPRODUCTION.md from lauransotomayor/hyperFVC: direct link, hf CLI and curl.
- Browser
- Download file 9.88 kB
-
https://huggingface.co/spaces/lauransotomayor/hyperFVC/resolve/main/workflow/docs/REPRODUCTION.md
- Command line
-
hf download hf://spaces/lauransotomayor/hyperFVC/workflow/docs/REPRODUCTION.md
-
curl -L -o REPRODUCTION.md https://huggingface.co/spaces/lauransotomayor/hyperFVC/resolve/main/workflow/docs/REPRODUCTION.md
Reproduction map
What each driver script in scripts/ does, which phase it belongs to, the Python entry point it calls, and the data it reads and writes.
Every script resolves its locations through configs/paths.yaml via scripts/lib/fvc_env.sh, so none of them contain machine-specific paths. In the tables below:
| Notation | Meaning |
|---|---|
[site1] |
FVC_SITE_SITE1 — Site 1 (site1_1_DD0001) under the data root |
[site2] |
FVC_SITE_SITE2 — Site 2 (site2_2_DD0013) under the data root |
[site1_alt] / [site2_alt] |
Raw capture trees (SASMDD0001 / SASMDD0013) |
[uas] |
FVC_ROOT_UAS — raw UAS captures and random-sampling products |
[qgis] |
FVC_ROOT_QGIS — annotation grids and shapefiles |
Before running anything
mamba activate fvc_function
python utils/fvc_paths.py --check # confirm the drives resolve
--check reports each root as OK, MISSING, or FAIL. Fix that before
launching a long run; every script also fails fast with the same advice if a
required directory is absent.
To run against a different disk or a copy of the dataset, override the root rather than editing scripts:
FVC_DATA_ROOT=/mnt/disk/calperumResearch bash scripts/<script>.sh
Each script keeps its own ${VAR:-default} overrides too (SITE_ROOT,
OUTPUT_ROOT, SRC_IMAGE_DIR, …), so individual steps can be redirected
without touching the config.
Phase 1 — imagery, grids, and tiling
Produces spatially aligned predictor tiles from orthomosaics. Grids come first: every later step inherits tile IDs and extents from them.
| Order | Script | Calls | Reads | Writes |
|---|---|---|---|---|
| 1.1 | build_site1_alignment_grids.sh |
phase_1_image_processing/utils/build_aligned_grid_from_raster.py |
[site1_alt]/…/dual_ortho_05.tif, FX10/FX17 mosaics |
[site1]/inputs/masks/tiles_3072/pv_class/annotations/gridding/grid_annotation_{614,hyspecFX10_307,hyspecFX17_307}.shp |
| 1.2 | regenerate_site1_multispec_5cm_614.sh |
…/2_2_clip_shp_gridAnnotation_MULTISPECTRALsampling_envi.py |
5 cm MicaSense mosaic + 614 grid | [site1]/inputs/predictors/tiles_3072/multispec/res_05/raw/tiles_multispectral_int16_envi_614grid |
| 1.3 | refresh_site1_alignment_and_labels.sh |
phase_1_image_processing/utils/run_hyspec_mosaic_to_256_then_subset.py, utils/stack_fx10_fx17_tiles_envi.py |
FX10/FX17 mosaics | [site1]/inputs/predictors/tiles_3072/hyspec/FX10_FX17_subset_envi_307px |
| 1.4 | reclip_site1_manual_gt_1cm_to_614grid.sh |
…/2_2_clip_shp_gridAnnotation_MULTISPECTRALsampling_256_mask.py |
1 cm manual GT raster | 1 cm labels reclipped onto the 614 grid |
| 1.5 | filter_predictor_tiles_by_id.sh |
(copies files; no Python) | a predictor tile directory | a filtered subset by tile ID |
Site 2 hyperspectral, run in this order:
| Order | Script | Calls | Reads | Writes |
|---|---|---|---|---|
| 1.6 | repair_site2_fx10_fx17_215_trim_scanline_gaps.sh |
inline Python (rasterio) | [site2_alt]/…/FX10_FX17_215_trim_flight5_mosaic…_10cm.dat |
…_scanline_repaired.dat |
| 1.7 | chunk_site2_fx10_fx17_215_trim_304.sh |
…/2_2_clip_shp_gridAnnotation_MULTISPECTRALsampling_256m.py |
the repaired stack + FX10 3072 grid | [site2]/predictors/tiles_304/hyspec/FX10_FX17_215_trim_envi_10cm |
| 1.8 | prepare_site2_s224_hyspec_patches.sh |
inline Python | the 304 tiles from 1.7 | 224×224 patches (_r00_c00 corner crop by default) |
PATCH_ROWS / PATCH_COLS in 1.8 take comma-separated pixel offsets; 0,80
on both axes gives full 304×304 coverage at stride 80.
Phase 2 — reference labels
| Script | Calls | Reads | Writes |
|---|---|---|---|
downsample_site1_labels_low_offset.sh |
phase_2_reference_data/step_5_downsampling_labels/downsampling_labels_majvote.py |
[site1]/inputs/masks/tiles_3072/raw/fvc_class/annotation_raster_1cm_clean |
[site1]/inputs/masks/tiles_3070/raw/fvc_class/downsample_5cm_mode_multispec_614grid |
filter_mask_tiles_by_id.sh |
(copies files; no Python) | a mask tile directory | a filtered subset by tile ID |
Majority-vote downsampling preserves grid alignment, so 5 cm and 10 cm labels stay registered to the predictor tiles produced in Phase 1.
The rest of Phase 2 (LabelMe → shapefile, class merging, water and shadow
masking) is run script-by-script from phase_2_reference_data/step_*/ rather
than through a driver in scripts/. Those files still carry hardcoded paths —
see Known gaps.
Phase 3 — modelling
3a. Patch export (training-set preparation)
Each of these exports non-overlapping patch pairs, then launches training.
| Script | Source tiles | Exported patches |
|---|---|---|
prepare_site1_patch_training.sh |
MicaSense tiles_304_crop608_ov152 |
[site1]/inputs/data/<density> |
prepare_fx10_76_training.sh |
…/hyspec/FX10_10_205_envi_304px |
…/tiles_76/hyspec/FX10_10_205_envi_76px |
prepare_fx17_76_training.sh |
…/hyspec/FX17_3_96_envi_304px |
…/tiles_76/hyspec/FX17_3_96_envi_76px |
prepare_fx10_fx17_76_training.sh |
…/hyspec/FX10_FX17_subset_envi_304px |
…/tiles_76/hyspec/FX10_FX17_subset_envi_76px |
All four call phase_3_models/unet_site_models/dataset/export_nonoverlap_pairs.py
followed by main_site_specific_models.py.
3b. Training
| Script | Purpose |
|---|---|
run_sensor_profiles_in_order.sh |
The main sweep — every sensor profile in sequence (2084 lines; the canonical entry point for reproducing the model set) |
run_mica_shadow_aug_transformer_s304.sh |
MicaSense 304 px, shadow augmentation + spectral transformer |
run_mica_robust_variants_s304.sh |
MicaSense 304 px robustness variants |
run_fx10_fx17_s152_preweights_direct.sh |
FX10+FX17 152 px from pretrained weights |
run_fx10_fx17_s152_preweights_direct_localMachine.sh |
As above, single-machine variant |
run_e4_hsi_transfer.sh |
E4 hyperspectral transfer from a MicaSense body |
All call phase_3_models/unet_site_models/main_site_specific_models.py.
Outputs go to [site1]/outputs_ecosystems/<density>/<run_name>.
Class schema is set by environment variable, not by editing code:
FVC_EXTRA_CLASS_LABELS="SI" # BE=0, NPV=1, PV=2, shadow=3
FVC_EXTRA_CLASS_LABELS="SI,WI" # + water=4
CLASS_WEIGHTS="0.291,2.288,0.421" # one value per class
If FVC_CLASS_LABELS is set without CLASS_WEIGHTS, the three-class default
weights are deliberately not injected — they would be wrong for a four- or
five-class schema.
3c. Inference
| Script | Calls | Notes |
|---|---|---|
run_inference_tile.sh |
phase_3_models/unet_site_models/inference_FVCmapping.py |
Single tile. Requires --image-path and --tile-name |
Whole-orthomosaic streaming inference, uncertainty mapping, and raster→GeoPackage
conversion are run directly from phase_3_models/unet_site_models/inference_*.py.
3d. Post-hoc analysis
| Script | Calls | Writes |
|---|---|---|
run_senescence_profiles_in_order.sh |
phase_3_models/unet_site_models/run_senescence_analysis.py |
[site1]/outputs_ecosystems/medium |
3e. Export / deployment
| Script | Calls | Status |
|---|---|---|
export_mica_best_onnx_docker.sh |
phase_3_models/unet_site_models/export_checkpoint_to_onnx.py |
Broken — see below |
export_hyspec_best_onnx_docker.sh |
phase_3_models/unet_site_models/export_checkpoint_to_onnx.py |
Broken — see below |
Both run inside docker-compose.gpu.yml (or directly when already in a
container), and feed the Jetson Orin AGX benchmarks in jetsonOrinAGX/.
Known gaps
export_checkpoint_to_onnx.py does not exist. Both ONNX export scripts
invoke phase_3_models/unet_site_models/export_checkpoint_to_onnx.py, in the
local branch and the Docker branch. The file is absent from the working tree
and from the entire git history, so both scripts fail once they get past their
directory checks. The ONNX → TensorRT path in jetsonOrinAGX/ depends on this
step.
Phase 2 step scripts still carry hardcoded paths. The scripts/ drivers and
phase_3_models/unet_site_models/config_param.py now resolve through
configs/paths.yaml; the phase_2_reference_data/step_*/ and
phase_1_image_processing/step_*/ modules do not. Highest-density files:
| File | Hardcoded paths |
|---|---|
phase_2_reference_data/step_2_fvc_classes_combined/2_6_spectrum.py |
186 |
phase_2_reference_data/step_1_be_class/1_3_be_class_msavi_ndvi.py |
86 |
phase_2_reference_data/step_2_fvc_classes_combined/2_4_5c_gettingMultipleClasses.py |
68 |
phase_2_reference_data/step_2_fvc_classes_combined/2_2_concat_beClass_otherClasses.py |
54 |
They migrate the same way: import utils.fvc_paths, define a site anchor, and
substitute the literal prefix.
QGIS steps run outside this environment.
phase_1_image_processing/step_2_orthomosaic_to_tiling/a_qgis/ is executed from
the QGIS Python console, so it is not covered by requirements.txt.
Writing a new driver script
#!/usr/bin/env bash
set -euo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/fvc_env.sh"
IMAGE_DIR="${IMAGE_DIR:-$(fvc_layout predictors site=site1 grid=3072)}"
OUT_DIR="${OUT_DIR:-$(fvc_layout outputs site=site1 density=medium)}"
fvc_require_dir "${IMAGE_DIR}" "predictor tiles"
"${PYTHON_BIN}" "${FVC_REPO_ROOT}/phase_3_models/unet_site_models/main_site_specific_models.py" \
--image-folder "${IMAGE_DIR}"
fvc_env.sh provides FVC_REPO_ROOT, PYTHON_BIN, FVC_ROOT_*, FVC_SITE_*,
fvc_layout, fvc_require_dir, and fvc_require_file. Keep the
${VAR:-default} form so every path stays overridable from the command line.