deepliif 1.1.8__tar.gz → 1.1.9__tar.gz

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.
Files changed (43) hide show
  1. {deepliif-1.1.8/deepliif.egg-info → deepliif-1.1.9}/PKG-INFO +4 -4
  2. {deepliif-1.1.8 → deepliif-1.1.9}/README.md +3 -3
  3. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/models/__init__.py +14 -11
  4. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/postprocessing.py +12 -5
  5. {deepliif-1.1.8 → deepliif-1.1.9/deepliif.egg-info}/PKG-INFO +4 -4
  6. {deepliif-1.1.8 → deepliif-1.1.9}/setup.cfg +1 -1
  7. {deepliif-1.1.8 → deepliif-1.1.9}/setup.py +1 -1
  8. {deepliif-1.1.8 → deepliif-1.1.9}/LICENSE.md +0 -0
  9. {deepliif-1.1.8 → deepliif-1.1.9}/cli.py +0 -0
  10. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/__init__.py +0 -0
  11. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/data/__init__.py +0 -0
  12. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/data/aligned_dataset.py +0 -0
  13. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/data/base_dataset.py +0 -0
  14. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/data/colorization_dataset.py +0 -0
  15. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/data/image_folder.py +0 -0
  16. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/data/single_dataset.py +0 -0
  17. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/data/template_dataset.py +0 -0
  18. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/data/unaligned_dataset.py +0 -0
  19. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/models/DeepLIIFExt_model.py +0 -0
  20. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/models/DeepLIIF_model.py +0 -0
  21. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/models/base_model.py +0 -0
  22. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/models/networks.py +0 -0
  23. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/options/__init__.py +0 -0
  24. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/options/base_options.py +0 -0
  25. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/options/processing_options.py +0 -0
  26. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/options/test_options.py +0 -0
  27. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/options/train_options.py +0 -0
  28. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/train.py +0 -0
  29. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/util/__init__.py +0 -0
  30. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/util/get_data.py +0 -0
  31. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/util/html.py +0 -0
  32. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/util/image_pool.py +0 -0
  33. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/util/util.py +0 -0
  34. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif/util/visualizer.py +0 -0
  35. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif.egg-info/SOURCES.txt +0 -0
  36. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif.egg-info/dependency_links.txt +0 -0
  37. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif.egg-info/entry_points.txt +0 -0
  38. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif.egg-info/requires.txt +0 -0
  39. {deepliif-1.1.8 → deepliif-1.1.9}/deepliif.egg-info/top_level.txt +0 -0
  40. {deepliif-1.1.8 → deepliif-1.1.9}/tests/test_args.py +0 -0
  41. {deepliif-1.1.8 → deepliif-1.1.9}/tests/test_cli_inference.py +0 -0
  42. {deepliif-1.1.8 → deepliif-1.1.9}/tests/test_cli_serialize.py +0 -0
  43. {deepliif-1.1.8 → deepliif-1.1.9}/tests/test_cli_train.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: deepliif
3
- Version: 1.1.8
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
@@ -259,7 +259,7 @@ img (required)
259
259
  file: image to run the models on
260
260
 
261
261
  resolution
262
- string: resolution used to scan the slide (10x, 20x, 40x), defaults to 20x
262
+ string: resolution used to scan the slide (10x, 20x, 40x), defaults to 40x
263
263
 
264
264
  pil
265
265
  boolean: if true, use PIL.Image.open() to load the image, instead of python-bioformats
@@ -288,9 +288,9 @@ res = requests.post(
288
288
  files={
289
289
  'img': open(f'{images_dir}/{filename}', 'rb')
290
290
  },
291
- # optional param that can be 10x, 20x (default) or 40x
291
+ # optional param that can be 10x, 20x, or 40x (default)
292
292
  params={
293
- 'resolution': '20x'
293
+ 'resolution': '40x'
294
294
  }
295
295
  )
296
296
 
@@ -248,7 +248,7 @@ img (required)
248
248
  file: image to run the models on
249
249
 
250
250
  resolution
251
- string: resolution used to scan the slide (10x, 20x, 40x), defaults to 20x
251
+ string: resolution used to scan the slide (10x, 20x, 40x), defaults to 40x
252
252
 
253
253
  pil
254
254
  boolean: if true, use PIL.Image.open() to load the image, instead of python-bioformats
@@ -277,9 +277,9 @@ res = requests.post(
277
277
  files={
278
278
  'img': open(f'{images_dir}/{filename}', 'rb')
279
279
  },
280
- # optional param that can be 10x, 20x (default) or 40x
280
+ # optional param that can be 10x, 20x, or 40x (default)
281
281
  params={
282
- 'resolution': '20x'
282
+ 'resolution': '40x'
283
283
  }
284
284
  )
285
285
 
@@ -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='default', marker_thresh='default', size_thresh_upper=None, opt=None):
428
- if opt.model == 'DeepLIIF':
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')), resolution,
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 opt.model == 'DeepLIIFExt':
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 {opt.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=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:
@@ -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='default', marker_thresh='default', size_thresh_upper=None):
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 == 'default':
408
+ if size_thresh == 'auto':
409
409
  size_thresh = calc_default_size_thresh(mask, resolution)
410
- if marker_thresh == 'default':
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=None)
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.8
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
@@ -259,7 +259,7 @@ img (required)
259
259
  file: image to run the models on
260
260
 
261
261
  resolution
262
- string: resolution used to scan the slide (10x, 20x, 40x), defaults to 20x
262
+ string: resolution used to scan the slide (10x, 20x, 40x), defaults to 40x
263
263
 
264
264
  pil
265
265
  boolean: if true, use PIL.Image.open() to load the image, instead of python-bioformats
@@ -288,9 +288,9 @@ res = requests.post(
288
288
  files={
289
289
  'img': open(f'{images_dir}/{filename}', 'rb')
290
290
  },
291
- # optional param that can be 10x, 20x (default) or 40x
291
+ # optional param that can be 10x, 20x, or 40x (default)
292
292
  params={
293
- 'resolution': '20x'
293
+ 'resolution': '40x'
294
294
  }
295
295
  )
296
296
 
@@ -3,7 +3,7 @@ name = deepliif
3
3
  description_file = README.md
4
4
  author = Parmida93
5
5
  author_email = ghahremani.parmida@gmail.com
6
- version = 1.1.8
6
+ version = 1.1.9
7
7
  url = https://github.com/nadeemlab/DeepLIIF
8
8
 
9
9
  [egg_info]
@@ -6,7 +6,7 @@ README = (HERE / "README.md").read_text()
6
6
 
7
7
  setup(
8
8
  name='deepliif',
9
- version='1.1.8',
9
+ version='1.1.9',
10
10
  packages=['deepliif', 'deepliif.data', 'deepliif.models', 'deepliif.util', 'deepliif.options'],
11
11
 
12
12
  description='DeepLIIF: Deep-Learning Inferred Multiplex Immunofluorescence for Immunohistochemical Image Quantification',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes