How bansal6003/interpretable_ai_for_zebrafish_phenotyping works
1. Repository shape
This is not a single monolithic application; it is a research/codebase organized into several mostly independent pipelines for zebrafish phenotyping, plus a set of exploratory LLM notebooks/scripts. The core architecture is a data-processing and model-training stack that feeds a separate inference/analysis layer.
2. Primary domain flow
The main end-to-end flow is:
raw zebrafish image/video/time-series data → preprocessing → task-specific model training → inference/measurement outputs → visual validation and reporting.
The repo is centered on extracting biologically meaningful phenotype and behavior signals from larval zebrafish experiments.
3. Preprocessing layer
Preprocessing_Pipeline/ is the ingestion and normalization boundary. It contains two major branches:
- Animal image preprocessing: image subfolder extraction, augmentations, polygon-to-mask conversion, and larva isolation using YOLO.
- Animal behavior data extraction: genotype isolation, gene sequencing mapping, Excel merging, time-series combing, and behavior analysis.
This layer prepares heterogeneous lab outputs into model-ready datasets and structured measurements.
4. Image classification subsystem
Image_Classification_Training/ contains standalone training scripts for RegNetY-16 and ViT-B/16 classifiers. The README indicates the main production-relevant classifier is RegNetY-16 transfer learning. This subsystem is responsible for coarse phenotypic labeling and mutant classification from larval imagery.
5. Image segmentation subsystem
Image_segmentation_Training/ trains DeepLabV3+ with a RegNetY-16 encoder for anatomical segmentation. This is the morphometry branch: it turns images into masks for structures like whole larva, eye, head, yolk sac, and pericardium, enabling downstream measurements such as area and shape-derived traits.
6. Object detection and tracking
Object_Detection_Training/YOLO_ultralytics.py and Object Tracking/ form the detection/tracking side of the vision stack. YOLO is used for localization tasks, while the tracking scripts and metrics suggest a separate pipeline for propagating detections across frames and evaluating tracker quality. This is likely used when individual animals or regions must be followed over time rather than classified per frame.
7. Behavioral time-series subsystem
Time_series_animal_behavior_Pipeline/Time_series_Training_and_Inference.py implements the behavioral modeling path. The README names LSTM and XGBoost as the main behavior models, implying a feature-extraction-to-sequence-model flow for electromechanical stimulus responses and temporal phenotype analysis.
8. Inference and application boundary
Model_Inference/ is the runtime-facing layer. DanioV16_core.py appears to hold the main inference logic, while main_window_Entry_Point.py and related files suggest a GUI-oriented entry point for end users. LLM_based_summariztion.py indicates a reporting/summarization component layered on top of model outputs. This layer consumes trained models and produces human-readable or visual outputs for analysis.
9. Experiment tracking and reproducibility
The README explicitly calls out MLflow logging in the classification work. Architecturally, this means model training is expected to record parameters, metrics, and runs for comparison and reproducibility. That tracking boundary is important because the repo is research-heavy and relies on experiment provenance rather than a single deployed model artifact.
10. Exploratory / non-core AI work
Passive_AI_Learning/ contains notebooks and scripts for unrelated learning exercises: CNN architecture experiments, anomaly detection VAE, ResNet-from-scratch, LangGraph workflows, Streamlit frontends, and RAG examples. These are best treated as a sandbox layer separate from the zebrafish pipeline. They show tooling familiarity but are not part of the main phenotyping architecture.
11. Data products and outputs
The outputs of the core pipelines are not just predictions; they include confusion matrices, accuracy plots, segmentation masks, IoU/Dice curves, clustering visualizations, and morphometric measurements. Sample_work_Processing_and_Visualization/ likely contains example artifacts demonstrating these results. The system is designed to produce interpretable outputs suitable for biologist review.
12. Main architectural boundaries
For diagramming, the clearest boundaries are:
- Preprocessing / data curation
- Image classification
- Segmentation / morphometry
- Detection / tracking
- Behavioral time-series modeling
- Inference/GUI/reporting
- Research sandbox / notebooks
The repo is best understood as a collection of task-specific ML pipelines sharing a biological domain and data sources, rather than as a single service with one shared runtime.
Main entry points: DanioV16_core.py Core infer · Animal_image_preprocessing Image prep · AI_Analysis_Sample_outputs Sample outputs · DeepLabV3Plus_RegNet_y_16_Image_segmentation.py DeepLabV3+
Components 17
Preprocessing
Data curation and normalization for image and behavior inputs.
- Image prep · Subfolder extraction, augmentation, polygon-to-mask conversion, and larva isolation.
Preprocessing_Pipeline/Animal_image_preprocessing - Behavior prep · Genotype isolation, gene mapping, Excel merging, time-series combining, and behavior analysis.
Preprocessing_Pipeline/Animal_behavior_Data_extraction
Vision training
Task-specific model training for image classification, segmentation, and detection.
- RegNetY-16 · Primary phenotypic classifier with transfer learning.
Image_Classification_Training/RegNet_Y_16GF_IMAGENET1K_SWAG_E2E_V1_image_classiifcation.py - ViT-B/16 · Alternative vision transformer classifier with MLflow logging.
Image_Classification_Training/Vit_B_16_Image_classification_model_with_mlflow_logging.py - DeepLabV3+ · Anatomical segmentation for larva, eye, head, yolk sac, and pericardium.
Image_segmentation_Training/DeepLabV3Plus_RegNet_y_16_Image_segmentation.py - YOLO detect · Localization model used for larva or region detection.
Object_Detection_Training/YOLO_ultralytics.py
Tracking
Multi-frame tracking and evaluation around detections.
- Tracker train · Training and configuration for frame-to-frame tracking.
Object Tracking/Object_tracker_training.py - Track predictor · Runs tracking across frames to propagate detections.
Object Tracking/track_predictor.py - Track metrics · Tracker quality and performance evaluation.
Object Tracking/track_predictor_metrics.py
Time series
Behavioral sequence modeling and inference.
- Behavior model · LSTM and XGBoost-based behavioral modeling and inference.
Time_series_animal_behavior_Pipeline/Time_series_Training_and_Inference.py
Inference
Runtime layer for model use, GUI, and summarization.
- Core infer · Main inference logic for the zebrafish application.
Model_Inference/DanioV16_core.py - Main window · User-facing entry point for running analysis and viewing results.
Model_Inference/main_window_Entry_Point.py - LLM summary · Summarizes model outputs into human-readable analysis.
Model_Inference/LLM_based_summariztion.py
Sandbox
Exploratory notebooks and unrelated AI practice work.
- CV sandbox · Standalone computer-vision experiments: CNNs, VAE anomaly detection, and ResNet-from-scratch.
Passive_AI_Learning/Computer_vision_architecture_designing - LangGraph lab · Notebook-based experiments for workflows, persistence, streaming, and fault tolerance.
Passive_AI_Learning/LangGraph Practice - RAG lab · Progressive experiments with simple LLM calls, chains, agents, and RAG variants.
Passive_AI_Learning/RAG Practice
Outputs
Example artifacts and visual validation outputs.
- Sample outputs · Example analysis artifacts and visualization outputs for review.
Sample_work_Processing_and_Visualization/AI_Analysis_Sample_outputs
Connections 23
- Image prep → RegNetY-16: image data · Prepared images feed classifier training.
- Image prep → ViT-B/16: image data · Prepared images feed alternate classifier training.
- Image prep → DeepLabV3+: masks/images · Normalized image assets feed segmentation training.
- Image prep → YOLO detect: localized data · Preprocessed imagery supports detector training.
- Image prep → Tracker train: frames · Prepared image sequences support tracker training.
- Behavior prep → Behavior model: features · Curated behavioral tables and sequences feed time-series modeling.
- Behavior prep → Core infer: structured input · Behavioral preprocessing can feed the runtime analysis core.
- RegNetY-16 → Core infer: classifier · Trained classifier is consumed by runtime inference.
- ViT-B/16 → Core infer: classifier · Alternative classifier can be loaded for inference.
- DeepLabV3+ → Core infer: segmenter · Segmentation model outputs are consumed during analysis.
- YOLO detect → Track predictor: detections · Detector outputs seed tracking across frames.
- Tracker train → Track predictor: tracker · Trained tracking logic is used at inference time.
- Track predictor → Track metrics: scores · Tracking predictions are evaluated by metrics.
- Behavior model → Core infer: behavior model · Time-series predictions flow into the runtime layer.
- Core infer → Main window: results · Core inference powers the GUI entry point.
- Core infer → LLM summary: outputs · Model outputs are summarized into readable reports.
- Core infer → Sample outputs: artifacts · Inference generates example visual and numeric outputs.
- LLM summary → Sample outputs: reports · Summaries and visualizations are collected as sample outputs.
- DeepLabV3+ → Sample outputs: masks/plots · Segmentation produces masks and quality plots.
- Behavior model → Sample outputs: curves · Behavior modeling contributes analysis visualizations.
- YOLO detect → Sample outputs: detections · Detection results can be reviewed as sample artifacts.
- CV sandbox → LangGraph lab: experiments · General AI experimentation spans multiple sandbox areas.
- LangGraph lab → RAG lab: workflow study · LLM workflow practice connects to RAG practice as exploratory work.