Spaces:
Sleeping
Sleeping
Fixed lungmasking [no ci]
Browse files- lungtumormask/dataprocessing.py +3 -3
- lungtumormask/mask.py +2 -2
lungtumormask/dataprocessing.py
CHANGED
@@ -126,7 +126,7 @@ def process_lung_scan(scan_dict, extremes):
|
|
126 |
|
127 |
return normalized_image, affine
|
128 |
|
129 |
-
def preprocess(image_path):
|
130 |
preprocess_dump = {}
|
131 |
|
132 |
scan_dict = {
|
@@ -139,8 +139,8 @@ def preprocess(image_path):
|
|
139 |
preprocess_dump['org_affine'] = im['image_meta_dict']['affine']
|
140 |
|
141 |
print("Segmenting lungs...")
|
142 |
-
masked_lungs = mask_lung(image_path,
|
143 |
-
preprocess_dump['lungmask'] = masked_lungs
|
144 |
right_lung_extreme = calculate_extremes(masked_lungs[0], 1)
|
145 |
preprocess_dump['right_extremes'] = right_lung_extreme
|
146 |
right_lung_processed = process_lung_scan(scan_dict, right_lung_extreme)
|
|
|
126 |
|
127 |
return normalized_image, affine
|
128 |
|
129 |
+
def preprocess(image_path, batch_size):
|
130 |
preprocess_dump = {}
|
131 |
|
132 |
scan_dict = {
|
|
|
139 |
preprocess_dump['org_affine'] = im['image_meta_dict']['affine']
|
140 |
|
141 |
print("Segmenting lungs...")
|
142 |
+
masked_lungs = mask_lung(image_path, batch_size=batch_size)
|
143 |
+
preprocess_dump['lungmask'] = masked_lungs[0] # first output is binary segmentation of lungs
|
144 |
right_lung_extreme = calculate_extremes(masked_lungs[0], 1)
|
145 |
preprocess_dump['right_extremes'] = right_lung_extreme
|
146 |
right_lung_processed = process_lung_scan(scan_dict, right_lung_extreme)
|
lungtumormask/mask.py
CHANGED
@@ -15,12 +15,12 @@ def load_model():
|
|
15 |
model.eval()
|
16 |
return model
|
17 |
|
18 |
-
def mask(image_path, save_path, lung_filter, threshold, radius):
|
19 |
print("Loading model...")
|
20 |
model = load_model()
|
21 |
|
22 |
print("Preprocessing image...")
|
23 |
-
preprocess_dump = preprocess(image_path)
|
24 |
|
25 |
print("Looking for tumors...")
|
26 |
left = model(preprocess_dump['left_lung']).squeeze(0).squeeze(0).detach().numpy()
|
|
|
15 |
model.eval()
|
16 |
return model
|
17 |
|
18 |
+
def mask(image_path, save_path, lung_filter, threshold, radius, batch_size):
|
19 |
print("Loading model...")
|
20 |
model = load_model()
|
21 |
|
22 |
print("Preprocessing image...")
|
23 |
+
preprocess_dump = preprocess(image_path, batch_size)
|
24 |
|
25 |
print("Looking for tumors...")
|
26 |
left = model(preprocess_dump['left_lung']).squeeze(0).squeeze(0).detach().numpy()
|