| | """ |
| | Simple example of using Sybil for lung cancer risk prediction |
| | """ |
| |
|
| | import sys |
| | import os |
| |
|
| | |
| | |
| |
|
| | |
| | from modeling_sybil_wrapper import SybilHFWrapper |
| | from configuration_sybil import SybilConfig |
| |
|
| | def predict_cancer_risk(dicom_paths): |
| | """ |
| | Predict lung cancer risk from DICOM files. |
| | |
| | Args: |
| | dicom_paths: List of paths to DICOM files from a CT scan |
| | |
| | Returns: |
| | Risk scores for years 1-6 |
| | """ |
| | |
| | print("Loading Sybil model...") |
| | config = SybilConfig() |
| | model = SybilHFWrapper.from_pretrained("Lab-Rasool/sybil") |
| |
|
| | |
| | print(f"Processing {len(dicom_paths)} DICOM files...") |
| | output = model(dicom_paths=dicom_paths, return_attentions=False) |
| |
|
| | |
| | risk_scores = output.risk_scores.numpy() |
| |
|
| | return risk_scores |
| |
|
| |
|
| | def main(): |
| | |
| | |
| | demo_dicom_paths = [ |
| | "path/to/slice001.dcm", |
| | "path/to/slice002.dcm", |
| | |
| | ] |
| |
|
| | |
| | |
| |
|
| | print("=" * 50) |
| | print("Sybil Lung Cancer Risk Prediction") |
| | print("=" * 50) |
| |
|
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | print("\nNote: This example requires actual DICOM files.") |
| | print("Please provide paths to LDCT scan DICOM files.") |
| | print("\nFor more information:") |
| | print("- Original paper: https://doi.org/10.1200/JCO.22.01345") |
| | print("- GitHub: https://github.com/reginabarzilaygroup/Sybil") |
| |
|
| |
|
| | if __name__ == "__main__": |
| | main() |