-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.py
41 lines (31 loc) · 1.07 KB
/
process.py
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
from user.inference import Model
from util import gcio
from util.constants import (
GC_CELL_FPATH,
GC_DETECTION_OUTPUT_PATH,
GC_METADATA_FPATH,
GC_TISSUE_FPATH,
)
def process() -> None:
"""Process a test patches. This involves iterating over samples,
inferring and write the cell predictions
"""
# Initialize the data loader
loader = gcio.DataLoader(GC_CELL_FPATH, GC_TISSUE_FPATH)
# Cell detection writer
writer = gcio.DetectionWriter(GC_DETECTION_OUTPUT_PATH)
# Loading metadata
meta_dataset = gcio.read_json(GC_METADATA_FPATH)
# Instantiate the inferring model
model = Model(meta_dataset)
# NOTE: Batch size is 1
for cell_patch, tissue_patch, pair_id in loader:
print(f"Processing sample pair {pair_id}")
# Cell-tissue patch pair inference
cell_classification = model(cell_patch, tissue_patch, pair_id)
# Updating predictions
writer.add_points(cell_classification, pair_id)
# Export the prediction into a json file
writer.save()
if __name__ == "__main__":
process()