Skip to content

Commit 63e3dbf

Browse files
committed
docs: Update readme and cleanup
1 parent 0f59c1f commit 63e3dbf

4 files changed

Lines changed: 72 additions & 28 deletions

File tree

README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,31 @@ OpenAlphaDiffract is an open-source implementation of the AlphaDiffract research
44
- Create a dataset from the Materials Project
55
- Simulate powder diffraction patterns from those structures
66
- Train and evaluate models on the generated dataset
7+
- Run an inference web app to try out the model
78

8-
For ease of use, a HF endpoint exists [TODO].
9-
10-
## Inference Quickstart
11-
[TODO]: (probably hosting on HF)
12-
[TODO]: Minimal local install with the trainer container
139

1410
## Dataset Pipeline Overview
1511

16-
1. Acquire CIFs (Downloader Container)
12+
1. Acquire CIFs (downloader.Dockerfile)
1713
- Uses the Materials Project API to fetch crystal structures as CIF files
1814
- Configurable via `configs/download.yaml`
1915
- Filters structures by checking conventional cell consistency across multiple angle tolerances. This filters ~4.4% of MP structures as of 10/22/2025.
2016

21-
2. GSAS-II XRD Simulation (Simulator Container)
17+
2. GSAS-II XRD Simulation (simulator.Dockerfile)
2218
- Generates synthetic powder diffraction patterns from CIFs
2319
- Configurable via `configs/simulator.yaml` (e.g., instrument file, noise ranges, job parallelism)
2420
- Creates .npy files with simulated pattern and metadata ready to be consumed by the training system
2521

26-
3. TODO: Training
22+
3. Open Alpha Diffract Training (trainer.Dockerfile)
23+
- Trains the multi-task AlphaDiffract model on the generated dataset
24+
- Configurable via `configs/trainer.docker.yaml` or `configs/trainer.local.yaml`
25+
- Logs checkpoints and metrics (CSV and optional MLflow)
26+
27+
4. XRD Inference Web App (ui.Dockerfile)
28+
- FastAPI service for model inference with a React frontend
29+
- Accepts processed XRD patterns and returns predictions via `/api/predict`
30+
- Serves the built frontend from the same container
31+
2732

2833
## Training from Scratch Quickstart
2934

@@ -45,14 +50,22 @@ Setup:
4550
- Optionally set `UID` and `GID` so the containers write files as your user.
4651

4752
2. Download CIFs:
48-
- `scripts/download.sh`
53+
- `scripts/download.sh` (or docker compose run --rm trainer)
4954
- CIFs will be written to `./data/raw_cif`
5055

5156
3. Simulate diffraction patterns:
52-
- `scripts/simulate.sh`
57+
- `scripts/simulate.sh` (or docker compose run --rm simulator)
5358
- Patterns will be written to `./data/dataset`
5459
- Errors (if any) go to `./data/error_logs`
5560

61+
4. Train the model:
62+
- `docker compose run --rm trainer`
63+
- Checkpoints and logs will be written to `./outputs`
64+
65+
5. Run the inference UI:
66+
- Move a model checkpoint to `./src/ui/models/xrd_model.ckpt`
67+
- `docker compose up ui`
68+
5669
Notes:
5770
- You can pass extra CLI args to the simulator via `scripts/simulate.sh`, e.g. `--sims_per_file 1 --parallel_jobs 4`
5871
- The default container commands and mounts are defined in `compose.yaml`
@@ -66,12 +79,12 @@ OpenAlphaDiffract/
6679
├── scripts/ - User-facing scripts
6780
├── src/ - Source code for pipeline components
6881
│ ├── downloader/
69-
│ └── simulator/
70-
82+
│ ├── simulator/
83+
│ ├── trainer/
84+
│ └── ui/
7185
```
7286

7387

74-
7588
## Citation
7689

77-
We hope this code was helpful to your work! If you use our code or extend our work, please consider citing our paper:
90+
We hope this code was helpful to your work! If you use our code or extend our work, please consider citing our paper. (Will be added once released!)

configs/download.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,16 @@ skip_existing: true
1414

1515
# Lattice reduction tolerances (Niggli reduction of conventional standard structure)
1616
representation:
17-
# Symmetry tolerance parameters used by SpacegroupAnalyzer (paper defaults)
18-
symprec: 0.01 # Distance tolerance (Angstroms)
19-
angle_tolerance: 5.0 # Angle tolerance (degrees)
17+
symprec: 0.01
18+
angle_tolerance: 5.0
2019

2120
# Initial structural filters (applied to standardized structure)
2221
filters:
23-
# Maximum allowed atoms per unit cell (paper default)
2422
max_atoms: 500
2523

26-
# Unit cell volume bounds (Angstrom^3). Set None to disable a bound.
2724
min_volume:
2825
max_volume: 100000
2926

30-
# - require_spacegroup_stability: verify space group is stable across a grid of tolerances
31-
# - symprecs / angle_tolerances: tolerance grid to test (defaults match staging/tools)
32-
# - check_reduced_cell_consistency: verify Niggli-reduced cell matches crystal-system symmetry
33-
# - rtol: absolute tolerance for length/angle equalities in reduced cell checks
3427
require_spacegroup_stability: true
3528
symprecs: [0.01, 0.05, 0.1]
3629
angle_tolerances: [0.1, 1.0, 2.5, 5.0]

configs/simulator.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ worker_base_dir: "/data/workers"
1414
# --- Execution Control ---
1515
parallel_jobs: 256
1616
sims_per_file: 100
17-
master_seed: 42 # Reproducible parameter sampling
17+
master_seed: 42
1818
cleanup_worker_dirs: true
1919
progress_step_pct: 0.1 # Progress logging interval in percent
20-
log_to_console: false # Useful in HPC settings
20+
log_to_console: false
2121

2222
# If true, read SG from "# _original_symmetry_space_group_name_H-M" comment in CIF
2323
# If using custom CIFs without this comment, set to false to use standard tags
2424
parse_from_comment: true
2525

2626
# --- Simulation Parameter Ranges ---
27-
# The format is ALWAYS (smaller_number, larger_number)
2827
strain_range: [500, 10000]
2928
size_range: [0.1, 1.0]
3029
U_range: [0.0, 3.0]
@@ -37,7 +36,5 @@ scaler_range: [1.0, 1.0]
3736
wl_range: [0.6199, 0.6199]
3837

3938
# --- Noise Parameter Ranges ---
40-
# Proportional noise is (intensity * random_factor)
4139
proportional_noise_range: [0.002, 0.02]
42-
# Constant noise is (intensity + random_count)
4340
constant_noise_range: [2, 5]

scripts/ui_dev_setup.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# Development startup script for XRD Analysis Tool
3+
4+
set -e
5+
6+
echo "=== XRD Analysis Tool - Development Setup ==="
7+
8+
cd src/ui
9+
10+
# Install frontend dependencies
11+
echo ""
12+
echo "Installing frontend dependencies..."
13+
cd src/ui/frontend
14+
if [ ! -d "node_modules" ]; then
15+
npm install
16+
else
17+
echo "Frontend dependencies already installed"
18+
fi
19+
20+
# Install Python dependencies
21+
echo ""
22+
echo "Installing Python dependencies..."
23+
cd ../..
24+
25+
# Check if uv is installed
26+
if ! command -v uv &> /dev/null; then
27+
echo "⚠️ uv not found. Installing uv..."
28+
curl -LsSf https://astral.sh/uv/install.sh | sh
29+
export PATH="$HOME/.cargo/bin:$PATH"
30+
fi
31+
32+
echo "Installing Python dependencies with uv..."
33+
uv env
34+
uv pip install -r requirements.txt
35+
36+
echo ""
37+
echo "Setup complete!"
38+
echo ""
39+
echo "To start development:"
40+
echo " 1. Backend in src/ui: uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000"
41+
echo " 2. Frontend in src/ui/frontend: npm run dev"

0 commit comments

Comments
 (0)