Research code for estimating the acute surface-fiber orientation angle of carbon-fiber prepreg from microscopy patches. The model uses a ConvNeXt-Tiny spatial backbone, optionally initialized from DINOv3 self-supervised weights, and combines orientation-aware attention, an annular FFT frequency branch, and heteroscedastic uncertainty estimation.
Sanitized code release. The full raw dataset, label manifests, model weights, experiment outputs, manuscripts, author information, and machine-specific paths are intentionally excluded. A few de-identified sample patches are included under
dataset/samples/for illustration; seedataset/README.md. The repository does not claim benchmark results that cannot be independently verified from the published artifacts.
- Highlights
- Method Overview
- Repository Layout
- Quick Start
- Installation
- Dataset Layout
- Training
- GST Baseline
- Reproducibility Experiments
- Validation
- License
- Parent-image-disjoint train, validation, and test interfaces.
- ConvNeXt-Tiny backbone with optional orientation-aware spatial attention.
- Optional annular FFT feature branch.
- Acute-angle regression with optional heteroscedastic loss.
- Validation-based early stopping, per-epoch metrics, checkpointing, and path-safe prediction exports.
- A Gradient Structure Tensor (GST) classical computer-vision baseline.
- Eight reproducibility protocols (E01–E08): initialization controls, factorial ablation, external-domain evaluation, uncertainty calibration, metrology validation, label efficiency, rotation equivariance, and latency analysis.
A ConvNeXt-Tiny backbone extracts spatial features from microscopy patches. An optional Gabor orientation attention module (inserted after backbone stage 2) learns an orientation-relevant attention map, while an optional annular FFT branch pools frequency content in a ring band around the spectrum center. The two streams are fused and fed to an angle regression head; an optional heteroscedastic head predicts per-sample log-variance to quantify uncertainty.
flowchart LR
P["Patch<br/>(H×W×3)"] --> B["ConvNeXt-Tiny<br/>backbone"]
B --> G["Gabor orientation<br/>attention"]
G --> PF["Adaptive<br/>avg-pool"]
P --> F["Annular FFT<br/>branch"]
F --> C["Fuse"]
PF --> C
C --> MLP["Fusion MLP"]
MLP --> A["Angle head<br/>θ ∈ [0°, 90°]"]
MLP --> U["Log-var head<br/>σ (uncertainty)"]
The target angle is folded into the acute range [0°, 90°] before regression; the predicted angle is recovered as θ = 90° · sigmoid(head).
.
├── dataset/ # De-identified sample patches + dataset README
├── fiber_orientation.py # Training / regression entry point
├── gst_baseline.py # Gradient Structure Tensor baseline
├── thesis_experiment_packages/ # E01–E08 reproducibility protocols
├── tests/ # Release checks (no deep-learning deps)
├── docs/banner.svg # Repository banner
├── .github/workflows/ci.yml # CI pipeline
├── requirements.txt
└── LICENSE
git clone https://github.com/Taxueovo/prepreg-fiber-orientation.git cd prepreg-fiber-orientation python -m venv .venv source .venv/bin/activate python -m pip install --upgrade pip python -m pip install -r requirements.txt python fiber_orientation.py --data-dir /path/to/database --device cuda:0
Python 3.10 or 3.11 is recommended. Install the PyTorch build appropriate for your CUDA, ROCm, or CPU environment, then install the remaining dependencies:
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txtThe full dataset is user-supplied and must not be committed to Git; only a small set of de-identified sample patches is included. The default layout is:
database/
├── train/
│ ├── train.csv
│ └── images/
├── val/
│ ├── val.csv
│ └── images/
└── test/
├── test.csv
└── images/
Each CSV must contain at least:
patch_filename,source_image,angle,x,y sample_0001.jpg,source_001.jpg,45.0,0,0
patch_filename must be a safe path relative to the corresponding images/ directory. angle is folded into the acute range [0°, 90°]. The source_image, x, and y fields support parent-image traceability; the training loader directly consumes patch_filename and angle.
Six de-identified 512×512 sample patches spanning the orientation-angle range (≈41°–88°) are provided under dataset/samples/ so the data appearance and format are visible without downloading the full set. See dataset/README.md for the manifest format and full-dataset statistics.
python fiber_orientation.py \ --data-dir /path/to/database \ --weights /path/to/dinov3_convnext_tiny.pth \ --require-pretrained \ --device cuda:0 \ --epochs 150 \ --batch-size 64
If --weights is omitted, the backbone uses random initialization. For controlled pretraining experiments, also pass --require-pretrained so a missing checkpoint fails explicitly. --device auto selects CUDA when available and otherwise uses CPU; cpu, cuda:0, and mps can also be selected explicitly.
Common paths may be configured with environment variables:
export FIBER_ORIENTATION_DATA_DIR=/path/to/database export FIBER_ORIENTATION_WEIGHTS=/path/to/checkpoint.pth export FIBER_ORIENTATION_RUNS_DIR=/path/to/runs export FIBER_ORIENTATION_DEVICE=cuda:0
Training artifacts are written to runs/ by default and are ignored by Git. Configuration snapshots and prediction exports remove workstation-specific absolute paths.
python gst_baseline.py \ --csv /path/to/test.csv \ --image_root /path/to/test/images \ --output /path/to/gst_predictions.csv
See thesis_experiment_packages/README.md for the eight experiment protocols. Training scripts read from FIBER_ORIENTATION_DATA_DIR or the project-local database/ directory. Generated outputs are written under the ignored thesis_experiment_packages/results/ directory.
The release checks do not require deep-learning dependencies:
PYTHONPYCACHEPREFIX=/tmp/fiber-orientation-pycache python -m compileall -q \ fiber_orientation.py gst_baseline.py thesis_experiment_packages tests python -m unittest discover -s tests -v
Full training requires legally obtained data and a compatible checkpoint. Follow the licenses and usage terms of the dataset, pretrained model, and third-party dependencies.
Distributed under the MIT License. Data, labels, and pretrained checkpoints are not covered by this license.