deepliif 1.1.8__py3-none-any.whl → 1.1.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deepliif/models/__init__.py +14 -11
- deepliif/postprocessing.py +12 -5
- {deepliif-1.1.8.dist-info → deepliif-1.1.9.dist-info}/METADATA +4 -4
- {deepliif-1.1.8.dist-info → deepliif-1.1.9.dist-info}/RECORD +8 -8
- {deepliif-1.1.8.dist-info → deepliif-1.1.9.dist-info}/LICENSE.md +0 -0
- {deepliif-1.1.8.dist-info → deepliif-1.1.9.dist-info}/WHEEL +0 -0
- {deepliif-1.1.8.dist-info → deepliif-1.1.9.dist-info}/entry_points.txt +0 -0
- {deepliif-1.1.8.dist-info → deepliif-1.1.9.dist-info}/top_level.txt +0 -0
deepliif/models/__init__.py
CHANGED
|
@@ -56,8 +56,11 @@ def get_opt(model_dir, mode='test'):
|
|
|
56
56
|
opt = Options(path_file=os.path.join(model_dir,'test_opt.txt'), mode=mode)
|
|
57
57
|
except:
|
|
58
58
|
opt = Options(path_file=os.path.join(model_dir,'train_opt.txt'), mode=mode)
|
|
59
|
+
opt.use_dp = False
|
|
60
|
+
opt.gpu_ids = list(range(torch.cuda.device_count()))
|
|
59
61
|
return opt
|
|
60
62
|
|
|
63
|
+
|
|
61
64
|
def find_model_using_name(model_name):
|
|
62
65
|
"""Import the module "models/[model_name]_model.py".
|
|
63
66
|
|
|
@@ -148,7 +151,7 @@ def init_nets(model_dir, eager_mode=False, opt=None, phase='test'):
|
|
|
148
151
|
if opt is None:
|
|
149
152
|
opt = get_opt(model_dir, mode=phase)
|
|
150
153
|
opt.use_dp = False
|
|
151
|
-
print_options(opt)
|
|
154
|
+
#print_options(opt)
|
|
152
155
|
|
|
153
156
|
if opt.model == 'DeepLIIF':
|
|
154
157
|
net_groups = [
|
|
@@ -168,7 +171,7 @@ def init_nets(model_dir, eager_mode=False, opt=None, phase='test'):
|
|
|
168
171
|
|
|
169
172
|
number_of_gpus_all = torch.cuda.device_count()
|
|
170
173
|
number_of_gpus = len(opt.gpu_ids)
|
|
171
|
-
print(number_of_gpus)
|
|
174
|
+
#print(number_of_gpus)
|
|
172
175
|
if number_of_gpus > 0:
|
|
173
176
|
mapping_gpu_ids = {i:idx for i,idx in enumerate(opt.gpu_ids)}
|
|
174
177
|
chunks = [itertools.chain.from_iterable(c) for c in chunker(net_groups, number_of_gpus)]
|
|
@@ -351,7 +354,7 @@ def inference(img, tile_size, overlap_size, model_path, use_torchserve=False, ea
|
|
|
351
354
|
color_dapi=False, color_marker=False, opt=None):
|
|
352
355
|
if not opt:
|
|
353
356
|
opt = get_opt(model_path)
|
|
354
|
-
print_options(opt)
|
|
357
|
+
#print_options(opt)
|
|
355
358
|
|
|
356
359
|
if opt.model == 'DeepLIIF':
|
|
357
360
|
rescaled, rows, cols = format_image_for_tiling(img, tile_size, overlap_size)
|
|
@@ -424,18 +427,18 @@ def inference(img, tile_size, overlap_size, model_path, use_torchserve=False, ea
|
|
|
424
427
|
raise Exception(f'inference() not implemented for model {opt.model}')
|
|
425
428
|
|
|
426
429
|
|
|
427
|
-
def postprocess(orig, images, tile_size, seg_thresh=150, size_thresh='
|
|
428
|
-
if
|
|
430
|
+
def postprocess(orig, images, tile_size, model, seg_thresh=150, size_thresh='auto', marker_thresh='auto', size_thresh_upper=None):
|
|
431
|
+
if model == 'DeepLIIF':
|
|
429
432
|
resolution = '40x' if tile_size > 384 else ('20x' if tile_size > 192 else '10x')
|
|
430
433
|
overlay, refined, scoring = compute_results(np.array(orig), np.array(images['Seg']),
|
|
431
|
-
np.array(images['Marker'].convert('L'))
|
|
432
|
-
seg_thresh, size_thresh, marker_thresh, size_thresh_upper)
|
|
434
|
+
np.array(images['Marker'].convert('L')) if 'Marker' in images else None,
|
|
435
|
+
resolution, seg_thresh, size_thresh, marker_thresh, size_thresh_upper)
|
|
433
436
|
processed_images = {}
|
|
434
437
|
processed_images['SegOverlaid'] = Image.fromarray(overlay)
|
|
435
438
|
processed_images['SegRefined'] = Image.fromarray(refined)
|
|
436
439
|
return processed_images, scoring
|
|
437
440
|
|
|
438
|
-
elif
|
|
441
|
+
elif model == 'DeepLIIFExt':
|
|
439
442
|
resolution = '40x' if tile_size > 768 else ('20x' if tile_size > 384 else '10x')
|
|
440
443
|
processed_images = {}
|
|
441
444
|
scoring = {}
|
|
@@ -452,7 +455,7 @@ def postprocess(orig, images, tile_size, seg_thresh=150, size_thresh='default',
|
|
|
452
455
|
return processed_images, scoring
|
|
453
456
|
|
|
454
457
|
else:
|
|
455
|
-
raise Exception(f'postprocess() not implemented for model {
|
|
458
|
+
raise Exception(f'postprocess() not implemented for model {model}')
|
|
456
459
|
|
|
457
460
|
|
|
458
461
|
def infer_modalities(img, tile_size, model_dir, eager_mode=False,
|
|
@@ -467,7 +470,7 @@ def infer_modalities(img, tile_size, model_dir, eager_mode=False,
|
|
|
467
470
|
if opt is None:
|
|
468
471
|
opt = get_opt(model_dir)
|
|
469
472
|
opt.use_dp = False
|
|
470
|
-
print_options(opt)
|
|
473
|
+
#print_options(opt)
|
|
471
474
|
|
|
472
475
|
if not tile_size:
|
|
473
476
|
tile_size = check_multi_scale(Image.open('./images/target.png').convert('L'),
|
|
@@ -486,7 +489,7 @@ def infer_modalities(img, tile_size, model_dir, eager_mode=False,
|
|
|
486
489
|
)
|
|
487
490
|
|
|
488
491
|
if not hasattr(opt,'seg_gen') or (hasattr(opt,'seg_gen') and opt.seg_gen): # the first condition accounts for old settings of deepliif; the second refers to deepliifext models
|
|
489
|
-
post_images, scoring = postprocess(img, images, tile_size, opt
|
|
492
|
+
post_images, scoring = postprocess(img, images, tile_size, opt.model)
|
|
490
493
|
images = {**images, **post_images}
|
|
491
494
|
return images, scoring
|
|
492
495
|
else:
|
deepliif/postprocessing.py
CHANGED
|
@@ -401,23 +401,30 @@ def calc_default_marker_thresh(marker):
|
|
|
401
401
|
return 0
|
|
402
402
|
|
|
403
403
|
|
|
404
|
-
def compute_results(orig, seg, marker, resolution=None, seg_thresh=150, size_thresh='
|
|
404
|
+
def compute_results(orig, seg, marker, resolution=None, seg_thresh=150, size_thresh='auto', marker_thresh='auto', size_thresh_upper=None):
|
|
405
405
|
mask = create_posneg_mask(seg, seg_thresh)
|
|
406
406
|
mark_background(mask)
|
|
407
407
|
|
|
408
|
-
if size_thresh == '
|
|
408
|
+
if size_thresh == 'auto':
|
|
409
409
|
size_thresh = calc_default_size_thresh(mask, resolution)
|
|
410
|
-
if marker_thresh
|
|
410
|
+
if marker_thresh is None:
|
|
411
|
+
marker_thresh = 0
|
|
412
|
+
marker = None
|
|
413
|
+
elif marker_thresh == 'auto':
|
|
411
414
|
marker_thresh = calc_default_marker_thresh(marker)
|
|
412
415
|
|
|
413
|
-
counts = compute_cell_classification(mask, marker, size_thresh, marker_thresh, size_thresh_upper
|
|
416
|
+
counts = compute_cell_classification(mask, marker, size_thresh, marker_thresh, size_thresh_upper)
|
|
414
417
|
enlarge_cell_boundaries(mask)
|
|
415
418
|
|
|
416
419
|
scoring = {
|
|
417
420
|
'num_total': counts['num_total'],
|
|
418
421
|
'num_pos': counts['num_pos'],
|
|
419
422
|
'num_neg': counts['num_neg'],
|
|
420
|
-
'percent_pos': round(counts['num_pos'] / counts['num_total'] * 100, 1) if counts['num_pos'] > 0 else 0
|
|
423
|
+
'percent_pos': round(counts['num_pos'] / counts['num_total'] * 100, 1) if counts['num_pos'] > 0 else 0,
|
|
424
|
+
'prob_thresh': seg_thresh,
|
|
425
|
+
'size_thresh': size_thresh,
|
|
426
|
+
'size_thresh_upper': size_thresh_upper,
|
|
427
|
+
'marker_thresh': marker_thresh if marker is not None else None,
|
|
421
428
|
}
|
|
422
429
|
|
|
423
430
|
overlay = np.copy(orig)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: deepliif
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.9
|
|
4
4
|
Summary: DeepLIIF: Deep-Learning Inferred Multiplex Immunofluorescence for Immunohistochemical Image Quantification
|
|
5
5
|
Home-page: https://github.com/nadeemlab/DeepLIIF
|
|
6
6
|
Author: Parmida93
|
|
@@ -269,7 +269,7 @@ img (required)
|
|
|
269
269
|
file: image to run the models on
|
|
270
270
|
|
|
271
271
|
resolution
|
|
272
|
-
string: resolution used to scan the slide (10x, 20x, 40x), defaults to
|
|
272
|
+
string: resolution used to scan the slide (10x, 20x, 40x), defaults to 40x
|
|
273
273
|
|
|
274
274
|
pil
|
|
275
275
|
boolean: if true, use PIL.Image.open() to load the image, instead of python-bioformats
|
|
@@ -298,9 +298,9 @@ res = requests.post(
|
|
|
298
298
|
files={
|
|
299
299
|
'img': open(f'{images_dir}/{filename}', 'rb')
|
|
300
300
|
},
|
|
301
|
-
# optional param that can be 10x, 20x (default)
|
|
301
|
+
# optional param that can be 10x, 20x, or 40x (default)
|
|
302
302
|
params={
|
|
303
|
-
'resolution': '
|
|
303
|
+
'resolution': '40x'
|
|
304
304
|
}
|
|
305
305
|
)
|
|
306
306
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
cli.py,sha256=elGu-9di_LcUXPsWWknWPevbaTv2r2rpORVPH5lsnAU,39723
|
|
2
2
|
deepliif/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
deepliif/postprocessing.py,sha256=
|
|
3
|
+
deepliif/postprocessing.py,sha256=cM-cYVidY691Sjb1-B8a1jkLq5UR_hTCbuKzuF4765o,17589
|
|
4
4
|
deepliif/train.py,sha256=-ZORL5vQrD0_Jq2Adgr3w8vJ7L1QcAgNTqMnBgtixgk,15757
|
|
5
5
|
deepliif/data/__init__.py,sha256=euf9eUboK4RYR0jvdiyZDgPGozC1Nv7WRqRbTxSZD6A,5281
|
|
6
6
|
deepliif/data/aligned_dataset.py,sha256=bAofVfgMwtb8Exe4EtQ3aP2ZYewBT4N_X8BDWSeFFj0,4405
|
|
@@ -12,7 +12,7 @@ deepliif/data/template_dataset.py,sha256=PCDBnFRzRKReaeWgKUZmW0LrzRByI9adrKDJ6SN
|
|
|
12
12
|
deepliif/data/unaligned_dataset.py,sha256=m7j-CX-hkXbhg96NSEcaCagNVhTuXKkMsBADdMEJDBA,3393
|
|
13
13
|
deepliif/models/DeepLIIFExt_model.py,sha256=Sc60rOfDJuoGrJ1CYe4beAg6as6F0o864AO6ZB7paBY,14527
|
|
14
14
|
deepliif/models/DeepLIIF_model.py,sha256=ECZyM9jzoJAWSgB1ProBoarVuGcbScQMaSkRjSMgt0k,20872
|
|
15
|
-
deepliif/models/__init__.py,sha256=
|
|
15
|
+
deepliif/models/__init__.py,sha256=E2udWyU4eScFnvDO2qtwMeHRz4ihw8hhCoP666QBK4o,22674
|
|
16
16
|
deepliif/models/base_model.py,sha256=HKcUOBHtL-zLs5ZcmeXT-ZV_ubqsSUo4wMCQ0W27YHU,15583
|
|
17
17
|
deepliif/models/networks.py,sha256=bN4yjRdE413efUESq8pvhzPDgFCTwFKXyQOrRqHckWY,32177
|
|
18
18
|
deepliif/options/__init__.py,sha256=nm231wh_hQw1mX0AfXZu7-cx6WZdxURsE-jvnjlHQzE,4581
|
|
@@ -26,9 +26,9 @@ deepliif/util/html.py,sha256=RNAONZ4opP-bViahgmpSbHwOc6jXKQRnWRAVIaeIvac,3309
|
|
|
26
26
|
deepliif/util/image_pool.py,sha256=M89Hc7DblRWroNP71S9mAdRn7h3DrhPFPjqFxxZYSgw,2280
|
|
27
27
|
deepliif/util/util.py,sha256=bTArzuhIMGgGweH0v5rkiHrqBxc24BDv12rssOE9OoI,4636
|
|
28
28
|
deepliif/util/visualizer.py,sha256=5V1lWidHqssJX21jn1P5-bOVgtrEXKVaQgnMWAsMfqg,15636
|
|
29
|
-
deepliif-1.1.
|
|
30
|
-
deepliif-1.1.
|
|
31
|
-
deepliif-1.1.
|
|
32
|
-
deepliif-1.1.
|
|
33
|
-
deepliif-1.1.
|
|
34
|
-
deepliif-1.1.
|
|
29
|
+
deepliif-1.1.9.dist-info/LICENSE.md,sha256=HlZw_UPS6EtJimJ_Ci7xKh-S5Iubs0Z8y8E6EZ3ZNyE,956
|
|
30
|
+
deepliif-1.1.9.dist-info/METADATA,sha256=CBgGs3wxeg1Hewt7lbAFUEH4Sbm5jV6jt4F3q59gvzM,25076
|
|
31
|
+
deepliif-1.1.9.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
|
32
|
+
deepliif-1.1.9.dist-info/entry_points.txt,sha256=f70-10j2q68o_rDlsE3hspnv4ejlDnXwwGZ9JJ-3yF4,37
|
|
33
|
+
deepliif-1.1.9.dist-info/top_level.txt,sha256=vLDK5YKmDz08E7PywuvEjAo7dM5rnIpsjR4c0ubQCnc,13
|
|
34
|
+
deepliif-1.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|