cell-data-loader 0.0.4__tar.gz → 0.0.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: cell_data_loader
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Converts general images of cells into formats and labels for deep learning pipelines
5
5
  Project-URL: Homepage, https://github.com/mleming/CellDataLoader
6
6
  Author-email: Matt Leming <mleming@mgh.harvard.edu>
@@ -48,7 +48,7 @@ def example_torch(gpu_ids = None,verbose=True):
48
48
  dtype="torch",
49
49
  verbose=False, gpu_ids=gpu_ids)
50
50
  if verbose: print("Beginning training")
51
- n_epochs = 500
51
+ n_epochs = 0
52
52
  for epoch in range(n_epochs):
53
53
  l = 0
54
54
  c = 0
@@ -65,7 +65,7 @@ def example_torch(gpu_ids = None,verbose=True):
65
65
  if verbose:
66
66
  print(
67
67
  "Epoch {epoch:d}/{n_epochs:d}: loss: {loss:.5f}".format(
68
- epoch=epoch,n_epochs=e_epochs,loss=l/c)
68
+ epoch=epoch,n_epochs=n_epochs,loss=l/c)
69
69
  )
70
70
  # Test
71
71
 
@@ -3,7 +3,7 @@
3
3
  #git init
4
4
  git add README.md example_numpy.py example_torch.py src tests requirements.txt pyproject.toml
5
5
  #git rm src/cell_data_loader/slice_images_out.py src/cell_data_loader/cell_segmenter.py
6
- git commit -m "Updated example torch, added toml"
6
+ git commit -m "Added augmentation"
7
7
  git branch -M main
8
8
  #git remote add origin https://github.com/mleming/CellDataLoader.git
9
9
  git push -u origin main
@@ -2,7 +2,7 @@
2
2
 
3
3
  name = "cell_data_loader"
4
4
 
5
- version = "0.0.4"
5
+ version = "0.0.5"
6
6
 
7
7
  dependencies = [
8
8
  "numpy",
@@ -220,6 +220,20 @@ class CellDataloader():#BaseDataset):
220
220
  self.dtype = dtype
221
221
  self.n_channels = n_channels
222
222
  self.channels_first = channels_first
223
+ self.augment_image = augment_image
224
+ if self.augment_image and self.dtype == "torch":
225
+ from torchvision import transforms
226
+
227
+ self.augment = transforms.Compose([
228
+ #transforms.ElasticTransform(),
229
+ transforms.RandomHorizontalFlip(0.5),
230
+ transforms.RandomVerticalFlip(0.5),
231
+ transforms.GaussianBlur(5),
232
+ transforms.ColorJitter(brightness=(0.5,1.5),
233
+ contrast=(1), saturation=(0.5,1.5), hue=(-0.1,0.1)),
234
+ transforms.RandomResizedCrop((self.dim))])#,
235
+ #transforms.Normalize((0.5,0.5,0.5),(0.5,0.5,0.5))])
236
+
223
237
  """
224
238
  If true, outputs given labels equally. This may repeat images if the
225
239
  counts of each don't line up.
@@ -457,6 +471,8 @@ class CellDataloader():#BaseDataset):
457
471
  self.im_index = 0
458
472
  self.index += 1
459
473
  if self.index >= len(self.image_objects): break
474
+ if self.augment_image and self.dtype == "torch":
475
+ im = self.augment(im)
460
476
  if self.return_labels():
461
477
  return im,label
462
478
  else: