Spaces:
Sleeping
Sleeping
Download src/inference/export.py from NMundhra/OCT-Segmentation-Model: direct link, hf CLI and curl.
- Browser
- Download file 692 Bytes
-
https://huggingface.co/spaces/NMundhra/OCT-Segmentation-Model/resolve/main/src/inference/export.py
- Command line
-
hf download hf://spaces/NMundhra/OCT-Segmentation-Model/src/inference/export.py
-
curl -L -o export.py https://huggingface.co/spaces/NMundhra/OCT-Segmentation-Model/resolve/main/src/inference/export.py
692 Bytes
| import json | |
| from pathlib import Path | |
| from src.inference.data_models import OCTScanAnalysis | |
| class InferenceExporter: | |
| def to_json_file(analysis: OCTScanAnalysis, filepath: str) -> None: | |
| """ | |
| Exports the OCTScanAnalysis to a JSON file. | |
| """ | |
| out_path = Path(filepath) | |
| out_path.parent.mkdir(parents=True, exist_ok=True) | |
| with open(out_path, 'w') as f: | |
| f.write(analysis.to_json()) | |
| def to_json_string(analysis: OCTScanAnalysis) -> str: | |
| """ | |
| Exports the OCTScanAnalysis to a JSON string (for direct API responses). | |
| """ | |
| return analysis.to_json() | |