Update README.md
Browse files
README.md
CHANGED
|
@@ -44,30 +44,41 @@ pip install huggingface-hub torch torchvision pydicom
|
|
| 44 |
```python
|
| 45 |
from huggingface_hub import snapshot_download
|
| 46 |
import sys
|
|
|
|
| 47 |
|
| 48 |
# Download model
|
| 49 |
model_path = snapshot_download(repo_id="Lab-Rasool/sybil")
|
| 50 |
sys.path.append(model_path)
|
| 51 |
|
| 52 |
# Import model
|
| 53 |
-
from
|
| 54 |
from configuration_sybil import SybilConfig
|
| 55 |
|
| 56 |
# Initialize
|
| 57 |
config = SybilConfig()
|
| 58 |
model = SybilHFWrapper(config)
|
| 59 |
|
| 60 |
-
|
| 61 |
-
dicom_paths = [
|
|
|
|
|
|
|
| 62 |
|
| 63 |
# Get predictions
|
| 64 |
output = model(dicom_paths=dicom_paths)
|
| 65 |
risk_scores = output.risk_scores.numpy()
|
| 66 |
|
| 67 |
# Display results
|
| 68 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
for i, score in enumerate(risk_scores):
|
| 70 |
-
print(f"Year {i+1}: {score
|
|
|
|
| 71 |
```
|
| 72 |
|
| 73 |
## π Example with Demo Data
|
|
@@ -121,17 +132,7 @@ output = model(dicom_paths=dicom_files)
|
|
| 121 |
|
| 122 |
# Show results
|
| 123 |
for i, score in enumerate(output.risk_scores.numpy()):
|
| 124 |
-
print(f"Year {i+1}: {score
|
| 125 |
-
```
|
| 126 |
-
|
| 127 |
-
Expected output for demo data:
|
| 128 |
-
```
|
| 129 |
-
Year 1: 2.2% risk
|
| 130 |
-
Year 2: 4.5% risk
|
| 131 |
-
Year 3: 7.2% risk
|
| 132 |
-
Year 4: 7.9% risk
|
| 133 |
-
Year 5: 9.6% risk
|
| 134 |
-
Year 6: 13.6% risk
|
| 135 |
```
|
| 136 |
|
| 137 |
## π Performance Metrics
|
|
|
|
| 44 |
```python
|
| 45 |
from huggingface_hub import snapshot_download
|
| 46 |
import sys
|
| 47 |
+
import os
|
| 48 |
|
| 49 |
# Download model
|
| 50 |
model_path = snapshot_download(repo_id="Lab-Rasool/sybil")
|
| 51 |
sys.path.append(model_path)
|
| 52 |
|
| 53 |
# Import model
|
| 54 |
+
from modeling_sybil_hf import SybilHFWrapper
|
| 55 |
from configuration_sybil import SybilConfig
|
| 56 |
|
| 57 |
# Initialize
|
| 58 |
config = SybilConfig()
|
| 59 |
model = SybilHFWrapper(config)
|
| 60 |
|
| 61 |
+
dicom_dir = "path/to/volume"
|
| 62 |
+
dicom_paths = [os.path.join(dicom_dir, f) for f in os.listdir(dicom_dir) if f.endswith('.dcm')]
|
| 63 |
+
|
| 64 |
+
print(f"Found {len(dicom_paths)} DICOM files for prediction.")
|
| 65 |
|
| 66 |
# Get predictions
|
| 67 |
output = model(dicom_paths=dicom_paths)
|
| 68 |
risk_scores = output.risk_scores.numpy()
|
| 69 |
|
| 70 |
# Display results
|
| 71 |
+
print("\nLung Cancer Risk Predictions:")
|
| 72 |
+
print(f"Risk scores shape: {risk_scores.shape}")
|
| 73 |
+
|
| 74 |
+
# Handle both single and batch predictions
|
| 75 |
+
if risk_scores.ndim == 2:
|
| 76 |
+
# Batch predictions - take first sample
|
| 77 |
+
risk_scores = risk_scores[0]
|
| 78 |
+
|
| 79 |
for i, score in enumerate(risk_scores):
|
| 80 |
+
print(f"Year {i+1}: {float(score)}")
|
| 81 |
+
|
| 82 |
```
|
| 83 |
|
| 84 |
## π Example with Demo Data
|
|
|
|
| 132 |
|
| 133 |
# Show results
|
| 134 |
for i, score in enumerate(output.risk_scores.numpy()):
|
| 135 |
+
print(f"Year {i+1}: {float(score)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
```
|
| 137 |
|
| 138 |
## π Performance Metrics
|