Coder Social home page Coder Social logo

adalbertocq / pathology-gan Goto Github PK

View Code? Open in Web Editor NEW
92.0 8.0 21.0 560.4 MB

Corresponding code of 'Quiros A.C., Murray-Smith R., Yuan K. Pathology GAN: Learning deep representations of cancer tissue. Proceedings of The 3rd International Conference on Medical Imaging with Deep Learning (MIDL) 2020'

Python 99.37% R 0.63%
gans generative-adversarial-network representation-learning pathology-gan digital-pathology histopathology

pathology-gan's People

Contributors

adalbertocq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pathology-gan's Issues

generate_fake_samples.py generates empty folder

Hello!

I trained the model on my own images and trying to generate fake samples. However the generated_images/ is empty after running generate_fake_samples.py. Do you have any idea how to generate fake samples?

Could not open ckpt/PathologyGAN.ckt.data-00000-of-00001 when running generate_fake_samples.py (Wrong tensorflow version?)

2020-09-21 13:11:42.705754: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open ckpt/PathologyGAN.ckt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?

I think the issue might be the tensorflow version. The code imported tf.compat.v1 as tensorflow, but I changed it to import tensorflow since I have tf 1.12.0 installed per the documentation. Is the code actually in TF 2.0 now? If so which version in particular?

How to generate hdf5 inputs for "find_nearest_neighbors.py"

Hi -

First, thanks a lot for sharing your code!
I've been trying to run the different commands on the main page but had trouble with the last one, find_nearest_neighbors.py.
It is unclear what the input hdf5 files should be. Looking at the code, it looks like it expects 4 hdf5 files (2 for real, 2 for "generated" and for each, one "image" and one "features" hdf5).
However, it is unclear how to obtain these hdf5 files. It looks like even for the real one, it's different from the input training or test set, and the "generated" one is also different from the one obtained from the format obtained out of the "generate_fake_samples.py" algorithm.
Could you please clarify the use of that function?

Thanks,
Best,
Nicolas

Choice of channel size progression

Regarding the progression of channel size through the synthesising network, you have chosen a non-geometric progression of 256 > 512 > 256 > 128 > 64 > 32 > 3 channels.

Aside from the practical implications of outputting to 7 x 7 x 1024 channels on the second dense layer, is there any other rationale to this choice? Or conversely, is there any downside to this decision?

Info about input data

Hi;
I'd like to apply your method to my personal histopathological images in order to generate fake images and improve the dimension of my training dataset (I have generated patches of 512x512 starting from WSI 40x). Could you give me some info about how the input data should be provided to use your generate_fake_samples.py code?
Thanks

The last commit seems to be causing errors on restoring the checkpoint.

Running the "generate_fake_samples.py" with the provided checkpoint file is producing no images with following error messages.

NotFoundError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Key generator/attention_block_2/conv_layer_1/bias not found in checkpoint
	 [[node save/RestoreV2 (defined at /home/user1/Pathology-GAN/models/evaluation/features.py:196)  = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]

I managed to fix these errors by reversing the changes from the last commit. (Fix typo on layer # for attention.)

Temporary fix - Simply change the following line which appears twice in "models/generative/generator.py":

net = attention_block(net, spectral=True, init=init, regularizer=regularizer, scope=layer)
-> net = attention_block(net, spectral=True, init=init, regularizer=regularizer, scope=layers)

ModuleNotFoundError

Hi Adalberto!
When I run generate_fake_samples.py script, I had the following error message.

" import tensorflow.compat.v1 as tf
ModuleNotFoundError: No module named 'tensorflow.compat.v1"

I double checked and the conda environment version is correct.
Do you have any insights about how to fix this problem?
Thank you.

AttributeError: 'Data' object has no attribute 'patch_h'

I'm getting this exception trying to run generate_fake_samples:

python3 generate_fake_samples.py --checkpoint ckpt/PathologyGAN.ckt.data-00000-of-00001 --num_samples 5 --z_dim 200 --main_path .
Traceback (most recent call last):
  File "generate_fake_samples.py", line 66, in <module>
    gen_hdf5_path = generate_samples_from_checkpoint(model=pathgan, data=data, data_out_path=main_path, checkpoint=checkpoint, num_samples=num_samples, batches=batch_size)
  File "/home/john/dev/Pathology-GAN-master/models/evaluation/features.py", line 165, in generate_samples_from_checkpoint
    res = 'h%s_w%s_n%s_zdim%s' % (data.patch_h, data.patch_w, data.n_channels, model.z_dim)
AttributeError: 'Data' object has no attribute 'patch_h'

I'm using the checkpoint and data files from the readme (generate_fake_samples wouldn't run without the data files).
checkpoint: https://figshare.com/s/0a311b5418f21ab2ebd4
data: https://drive.google.com/file/d/1LpgW85CVA48C8LnpmsDMdHqeCGHKsAxw/view

The only changes I made to the code is to change the import for tensorflow from tf.compat.v1 to tensorflow (with tensorflow 1.12.0 per the readme). Any help would be appreciated.

H&E breast cancer databases - Information on the labels

Hi,
I'm looking at the preprocessed dataset of the H&E breast cancer, that you kindly provided. You mentioned, that there are labels assassinated with each patch:
https://github.com/AdalbertoCq/Learning-a-low-dimensional-manifold-of-realcancer-tissue/blob/master/README.md?plain=1#L62

I could find them in the HDF. Can you please provide some information on those labels. I assume index 1 are the survival times (5y) according to Beck et al., because they are binary then the other one is the estrogen receptor information. Is that correct. I was also going though the Beck et al. paper and the supplementary material, but I could not find the labels there. I was there fore wondering where these values are coming from.

Thanks,
Wolfgang

typo on scope label for attention layer in generator.py

While it does not affect functionality, I believe that the scope argument for attention_block inside the for layer in range(layers) loop of both generator_resnet_style and generator_resnet in generator.py should be scope=layer rather than scope=layers.

This was confusing when trying to follow the order of operations by looking at the variable scopes in the checkpoint file, as it makes it seem that the attention block is reached after the central block of resnet and conv layers, rather than midway through.

# Attention layer. 
			if attention is not None and net.shape.as_list()[1]==attention:
				net = attention_block(net, spectral=True, init=init, regularizer=regularizer, scope=layers)

Training data resolution?

I'm trying to build my own training set for the model. What was the magnification ratio for the training dataset (40x, 20x, 10x)? I wasn't able to find this in the paper or documentation.

Restore pretrained models error

I see this has been brought up in previous issues, but it is still an issue for me. I am unable to restore the pre-trained breast cancer model.

(I can, however, restore the CRC model.)

I get the following error when I run this command:
python generate_fake_samples.py --checkpoint ./pretrained_models/breast_cancer/PathologyGAN.ckt --z_dim 200 --batch_size 64

NotFoundError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Key generator/attention_block_2/conv_layer_1/bias not found in checkpoint
         [[node save/RestoreV2 (defined at /home/blansdell/projects/comet/Pathology-GAN/models/evaluation/features.py:196)  = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]

I'm using the code in the most recent commit (00b0736), which I see includes the fix suggested by issue (#10). Tensorflow version 1.12.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.