Git Product home page Git Product logo

bci's Introduction

BCI: Breast Cancer Immunohistochemical Image Generation through Pyramid Pix2pix visitors

Project | Arxiv | PWC PWC | Tweet

News

  • ⚡(2022-10-20): We have released the trained model on BCI and LLVIP datasets.
  • ⚡(2022-6-29): We host a competition for breast cancer immunohistochemistry image generation on Grand Challenge
  • ⚡(2022-4-26): We have released BCI dataset and the code of PyramidPix2pix. You can download BCI dataset from the homepage or the-following-link.

datasetview_github


Framework

framework

Setup

1)Envs

  • Linux
  • Python>=3.6
  • CPU or NVIDIA GPU + CUDA CuDNN

Install python packages

git clone https://github.com/bupt-ai-cz/BCI
cd PyramidPix2pix
pip install -r requirements.txt

2)Prepare dataset

  • Download BCI dataset from our homepage.

  • Combine HE and IHC images.

    Project pix2pix provides a python script to generate pix2pix training data in the form of pairs of images {A,B}, where A and B are two different depictions of the same underlying scene, these can be pairs {HE, IHC}. Then we can learn to translate A(HE images) to B(IHC images).

    Create folder /path/to/data with subfolders A and B. A and B should each have their own subfolders train, val, test, etc. In /path/to/data/A/train, put training images in style A. In /path/to/data/B/train, put the corresponding images in style B. Repeat same for other data splits (val, test, etc).

    Corresponding images in a pair {A,B} must be the same size and have the same filename, e.g., /path/to/data/A/train/1.jpg is considered to correspond to /path/to/data/B/train/1.jpg.

    Once the data is formatted this way, call:

    python datasets/combine_A_and_B.py --fold_A /path/to/data/A --fold_B /path/to/data/B --fold_AB /path/to/data
    

    This will combine each pair of images (A,B) into a single image file, ready for training.

  • File structure

    PyramidPix2pix
      ├──datasets
           ├── BCI
                 ├──train
                 |    ├── 00000_train_1+.png
                 |    ├── 00001_train_3+.png
                 |    └── ...
                 └──test
                      ├── 00000_test_1+.png
                      ├── 00001_test_2+.png
                      └── ...
    
    

Train

Train at full resolution(1024*1024):

python train.py --dataroot ./datasets/BCI --gpu_ids 0 --pattern L1_L2_L3_L4

By default, four scales of the pyramid are used for supervision. You can change the option --pattern to use less scales (e.g. --pattern L1_L2_L3).

Train at resolution 512*512 (less GPU memory required):

python train.py --dataroot ./datasets/BCI --preprocess crop --crop_size 512 --gpu_ids 0 --pattern L1_L2_L3_L4

Images are randomly cropped if trained at low resolution.

Test

Test at full resolution(1024*1024):

python test.py --dataroot ./datasets/BCI --gpu_ids 0

Test at resolution 512*512:

python test.py --dataroot ./datasets/BCI --preprocess crop --crop_size 512 --gpu_ids 0

See PyramidPix2pix/options for more train and test options.

Evaluate

Calculate average PSNR and SSIM.

python evaluate.py --result_path ./results/pyramidpix2pix

Trained models

dataset device backbone PSNR SSIM model
BCI Tesla V100-32GB resnet_9 21.16 0.477 download
LLVIP Tesla V100-32GB resnet_9 12.189 0.279 download

Results

visualization

results2 results3
results4 results5

Citation

@InProceedings{Liu_2022_CVPR,
    author    = {Liu, Shengjie and Zhu, Chuang and Xu, Feng and Jia, Xinyu and Shi, Zhongyue and Jin, Mulan},
    title     = {BCI: Breast Cancer Immunohistochemical Image Generation Through Pyramid Pix2pix},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
    month     = {June},
    year      = {2022},
    pages     = {1815-1824}
}

Contact

Shengjie Liu ([email protected])

Chuang Zhu ([email protected])

If you have any questions, you can contact us directly.

bci's People

Contributors

bupt-ai-cz avatar santjay 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bci's Issues

Requst pretrained checkpoints

Hi, I am very interested in your work. Recently, I am reading codes and I want to test some samples. Where can I download those pretrained checkpoints? I would appreciate it if you could provide pretrained weights.

原始数据集下载问题

您好,我在挑战赛官网上注册后,根据主办方提供的数据集下载主页登记了个人信息,但是点击下载按钮的时候无法进行正常下载,提示Error! There is some issue with the server.请问如何获取数据集呢?非常感谢!

如何进行测试呢?

当我使用预训练模型进行推理的时候发生了错误:
torch.nn.modules.module.ModuleAttributeError: 'Sequential' object has no attribute 'model'

AttributeError: 'Sequential' object has no attribute 'model'

I have test images, downloaded BCI pretrained model and use the following command:

!python test.py --dataroot /kaggle/input/bci-img2img/BCI_for_GrandChallenge-20230210T115047Z-001/BCI_for_GrandChallenge/test --gpu_ids 0

However, I get an AttributeError, here is the output:

/bin/bash: /opt/conda/lib/libtinfo.so.6: no version information available (required by /bin/bash)
----------------- Options ---------------
             aspect_ratio: 1.0                           
               batch_size: 2                             
          checkpoints_dir: ./checkpoints                 
                crop_size: 256                           
                 dataroot: /kaggle/input/bci-img2img/BCI_for_GrandChallenge-20230210T115047Z-001/BCI_for_GrandChallenge/test	[default: ./datasets/BCI]
             dataset_mode: aligned                       
                direction: AtoB                          
          display_winsize: 256                           
                    epoch: latest                        
                     eval: False                         
                  gpu_ids: 0                             
                init_gain: 0.02                          
                init_type: normal                        
                 input_nc: 3                             
                  isTrain: False                         	[default: None]
                load_iter: 0                             	[default: 0]
                load_size: 320                           
         max_dataset_size: inf                           
                    model: pix2pix                       
               n_layers_D: 3                             
                     name: pyramidpix2pix                
                      ndf: 64                            
                     netD: basic                         
                     netG: resnet_9blocks                
                      ngf: 64                            
               no_dropout: False                         
                  no_flip: False                         
                     norm: batch                         
                 num_test: 1000                          
              num_threads: 4                             
                output_nc: 3                             
                  pattern: L1_L2_L3_L4                   
                    phase: test                          
               preprocess: scale_width_and_midcrop       
              results_dir: ./results/                    
           serial_batches: False                         
                   suffix:                               
                  verbose: False                         
----------------- End -------------------
dataset [AlignedDataset] was created
initialize network with normal
model [Pix2PixModel] was created
loading the model from ./checkpoints/pyramidpix2pix/latest_net_G.pth
Traceback (most recent call last):
  File "test.py", line 47, in <module>
    model.setup(opt)               # regular setup: load and print networks; create schedulers
  File "/kaggle/working/BCI-main/PyramidPix2pix/models/base_model.py", line 88, in setup
    self.load_networks(load_suffix)
  File "/kaggle/working/BCI-main/PyramidPix2pix/models/base_model.py", line 198, in load_networks
    self.__patch_instance_norm_state_dict(state_dict, net, key.split('.'))
  File "/kaggle/working/BCI-main/PyramidPix2pix/models/base_model.py", line 174, in __patch_instance_norm_state_dict
    self.__patch_instance_norm_state_dict(state_dict, getattr(module, key), keys, i + 1)
  File "/kaggle/working/BCI-main/PyramidPix2pix/models/base_model.py", line 174, in __patch_instance_norm_state_dict
    self.__patch_instance_norm_state_dict(state_dict, getattr(module, key), keys, i + 1)
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1208, in __getattr__
    type(self).__name__, name))
AttributeError: 'Sequential' object has no attribute 'model'

Could someone help me with this? Thank you!

Wrong image extension

I cannot open any image from dataset by double clicking unless I replace .png with .jpg.
I use Ubuntu 20.04.

Which part of the dataset is for validation

    In paper "Breast Cancer Immunohistochemical Image Generation: a Benchmark Dataset and Challenge Review", it is menntioned that "The dataset used in this challenge consists of 3396 pairs of the training set images, 500 pairs of the validation set images", but I can't  find any information for the val set both on the official website https://bci.grand-challenge.org/ and the dataset

    So, which part in the train fold is for validation? Or just split the dataset randomly

evaluate

how to evaluate
here is my result"there is something wrong with 00255_test_0_fake_B.png
there is something wrong with 00256_test_2+_fake_B.png
there is something wrong with 00257_test_1+_fake_B.png
there is something wrong with 00258_test_2+_fake_B.png"

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.