File size: 1,241 Bytes
344f0b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# test_pipeline.py

from pathlib import Path
from PIL import Image

from pipeline import SmartCBC

def main():
    # 1) Initialize pipeline (loads YOLO + classifier)
    cbc = SmartCBC()

    # 2) Pick a sample FOV image (from your TXL-PBC test set)
    test_dir = Path("/home/enma/Projects/blood_analyzer/TXL-PBC_Dataset/TXL-PBC/images/test")
    image_paths = list(test_dir.glob("*.*"))

    if not image_paths:
        print(f"No images found in {test_dir}")
        return

    sample_path = image_paths[0]
    print(f"Using sample image: {sample_path}")

    img = Image.open(sample_path).convert("RGB")

    # 3) Run analysis
    result = cbc.analyze(
        image=img,
        age=32,        # you can change this
        gender="M",    # or leave None / ""
    )

    # 4) Print key outputs
    print("\n=== Coarse Counts ===")
    print(result.get("coarse_counts"))

    print("\n=== WBC Subtypes ===")
    print(result.get("wbc_subtypes"))

    print("\n=== WBC Percentages ===")
    print(result.get("wbc_percentages"))

    print("\n=== Report Text (first 40 lines) ===")
    report_lines = result.get("report_text", "").splitlines()
    for line in report_lines[:40]:
        print(line)

if __name__ == "__main__":
    main()