Code Monkey home page Code Monkey logo

generating-covid-cxr-using-acgan's Introduction

Generation of Synthetic Chest X-Ray Images and Detection of COVID-19: a Deep Learning based Approach

This is the official implementation of the paper Generation of Synthetic Chest X-Ray Images and Detection of COVID-19: a Deep Learning based Approach.

Usage

Required Directory Structure:

.
+--Train
|  +--.
|  +--COVID
|  +--NORMAL
+--Test
|  +--.
|  +--COVID
|  +--NORMAL

loader.py contains the loading requirements for the dataset.

main.py contains the discriminator, generator, and the acgan function.

trainer.py contains the training methodology for the ACGAN, trained for 1200 epochs.

utils.py has the label smoothing function, the print logs function, the function to generate noise and labels, and the function to plot the loss graph.

generate.py loads the trained generator weights and generates the CXR image.

We have added 50 synthetic images in COVID-19 (Synthetic). Remaining synthetic images are available on request, mail [email protected] .

Training dataset was used from the following:

  1. https://github.com/ieee8023/covid-chestxray-dataset
  2. https://github.com/agchung/Figure1-COVID-chestxray-dataset
  3. https://github.com/agchung/Actualmed-COVID-chestxray-dataset
  4. https://www.kaggle.com/tawsifurrahman/covid19-radiography-database

Model structure

Generated Images

COVID-19 CXR Normal CXR

Citation

@Article{diagnostics11050895,
author = {Karbhari, Yash and Basu, Arpan and Geem, Zong Woo and Han, Gi-Tae and Sarkar, Ram},
title = {Generation of Synthetic Chest X-ray Images and Detection of COVID-19: A Deep Learning Based Approach},
journal = {Diagnostics},
volume = {11},
year = {2021},
ARTICLE-NUMBER = {895}
}

generating-covid-cxr-using-acgan's People

Contributors

yashkarbhari avatar

Stargazers

 avatar Maliheh Tehrani avatar Sina Jahromi avatar

Watchers

Sina Jahromi avatar  avatar

Forkers

anuprulez

generating-covid-cxr-using-acgan's Issues

Reimplementing the ACGAN for Normal and Pneumonia Image Generation and got ValueError

Hi,
I am reimplementing your acgan code for a different X-ray dataset and got the following error.
Could you please help to resolve this issue? Meanwhile, I am compiling the whole code in a single file acgan.py
Much appreciated.

Error log:

Traceback (most recent call last):
File "acgan.py", line 288, in
epoch_disc_loss.append(dis.train_on_batch(X, [y, aux_y]))
File "/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 1348, in train_on_batch
logs = train_function(iterator)
File "/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 580, in call
result = self._call(*args, **kwds)
File "/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 611, in _call
return self._stateless_fn(*args, **kwds) # pylint: disable=not-callable
File "/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 2419, in call
graph_function, args, kwargs = self._maybe_define_function(args, kwargs)
File "/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 2774, in _maybe_define_function
return self._define_function_with_shape_relaxation(args, kwargs)
File "/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 2706, in _define_function_with_shape$
args, kwargs, override_flat_arg_shapes=relaxed_arg_shapes)
File "/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 2667, in _create_graph_function
capture_by_value=self._capture_by_value),
File "/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/framework/func_graph.py", line 981, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File "/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 441, in wrapped_fn
return weak_wrapped_fn().wrapped(*args, **kwds)
File "/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/framework/func_graph.py", line 968, in wrapper
raise e.ag_error_metadata.to_exception(e)
ValueError: in user code:

/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py:571 train_function  *
    outputs = self.distribute_strategy.run(
/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/distribute/distribute_lib.py:951 run  **
    return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/distribute/distribute_lib.py:2290 call_for_each_replica
    return self._call_for_each_replica(fn, args, kwargs)
/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/distribute/distribute_lib.py:2649 _call_for_each_replica
    return fn(*args, **kwargs)
/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py:533 train_step  **
    y, y_pred, sample_weight, regularization_losses=self.losses)
/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/engine/compile_utils.py:205 __call__
    loss_value = loss_obj(y_t, y_p, sample_weight=sw)
/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/losses.py:143 __call__
    losses = self.call(y_true, y_pred)
/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/losses.py:246 call
    return self.fn(y_true, y_pred, **self._fn_kwargs)

/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/losses.py:1595 binary_crossentropy
K.binary_crossentropy(y_true, y_pred, from_logits=from_logits), axis=-1)
/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/keras/backend.py:4692 binary_crossentropy
return nn.sigmoid_cross_entropy_with_logits(labels=target, logits=output)
/cm/shared/apps/tensorflow2-py37-cuda10.1-gcc/2.2.0/lib/python3.7/site-packages/tensorflow/python/ops/nn_impl.py:172 sigmoid_cross_entropy_with_logits
(logits.get_shape(), labels.get_shape()))

ValueError: logits and labels must have the same shape ((50, 1) vs (72, 1))

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.