Accéder au contenu principal

Covid-19 Detection With Images Analysis And Machine Learning DL4J


In this presentation, you will try learn how to automatically detect COVID-19 in a hand-created X-ray image dataset using Deeplearning4j and talk about And talking about an experiment that I did using the technique of object detection to capture the Covid virus through pictures of infected cells. But it did not produce good results due to the lack of pictures of the affected cells.
Meaning that the two techniques can be applied to technical assistance for health professionals

In this application, we will rely on a database of positive and negative images diagnosed by the doctor Joseph Cohen’s, which has uploaded on github platform. You can view it through the link .
We will rely on DL4J framework to create the neural network according to the following plan:
1-Build the neural network
2- Train the model the net
3- Save & Loading the model of our neural network
4- Test the neural network against unsigned images

1-Buildin The neural Network :

At this point we will count on Datavec image pipeline.we are going to use ParentPathLabelGeneraator to apply labels to a collection of images based upon the directory where there located in our case we have tow directories (for positive and negative Diagnosed X-ray images),and ImagePreProcessingScaler to transform the array pixel to a binary values.

2-Train the net :

Adding MultiLayerNetwork,training the model against our training dataset and testing the model withe the test data set
private static Logger log = LoggerFactory.getLogger(MnistImagePipelineExampleAddNeuralNet.class);

/** Location to save and extract the training/testing data */private static final String DATA_PATH = FilenameUtils.concat(System.getProperty("java.io.tmpdir"), "YourPATHDIR");// create the main class
public static void main(String[] args) throws Exception {
  // image information
  // 100* 100 grayscale this is the case of my croped images 
  // grayscale implies single channel
  int height = 100;
  int width = 100;
  int channels = 1;
  int rngseed = 123;
  Random randNumGen = new Random(rngseed);
  int batchSize = 128;/* we have just two outputs positive and negative according to our directories */ 
  int outputNum = 2;
  int numEpochs = 1;

  /*
  This class downloadData() downloads the data
  stores the data in java's tmpdir 15MB download compressed
  It will take 158MB of space when uncompressed
  The data can be downloaded manually here
  
  // Define the File Paths
  File trainData = new File(DATA_PATH + "/covid-19/training");
  File testData = new File(DATA_PATH + "/covid-19/testing");

  // Define the FileSplit(PATH, ALLOWED FORMATS,random)
  FileSplit train = new FileSplit(trainData, NativeImageLoader.ALLOWED_FORMATS, randNumGen);
  FileSplit test = new FileSplit(testData, NativeImageLoader.ALLOWED_FORMATS, randNumGen);

  // Extract the parent path as the image label
  ParentPathLabelGenerator labelMaker = new ParentPathLabelGenerator();

  ImageRecordReader recordReader = new ImageRecordReader(height, width, channels, labelMaker);

  // Initialize the record reader
  // add a listener, to extract the name
  recordReader.initialize(train);
  //recordReader.setListeners(new LogRecordListener());

  // DataSet Iterator
  DataSetIterator dataIter = new RecordReaderDataSetIterator(recordReader, batchSize, 1, outputNum);

  // Scale pixel values to 0-1
  DataNormalization scaler = new ImagePreProcessingScaler(0, 1);
  scaler.fit(dataIter);
  dataIter.setPreProcessor(scaler);

  // Build Our Neural Network
  log.info("BUILD MODEL");
  MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
      .seed(rngseed)
      .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
      .updater(new Nesterovs(0.006, 0.9))
      .l2(1e-4)
      .list()
      .layer(0, new DenseLayer.Builder()
          .nIn(height * width)
          .nOut(100)
          .activation(Activation.RELU)
          .weightInit(WeightInit.XAVIER)
          .build())
      .layer(1, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
          .nIn(100)
          .nOut(outputNum)
          .activation(Activation.SOFTMAX)
          .weightInit(WeightInit.XAVIER)
          .build())
      .setInputType(InputType.convolutional(height, width, channels))
      .build();

  MultiLayerNetwork model = new MultiLayerNetwork(conf);

  // The Score iteration Listener will log
  // output to show how well the network is training
  model.setListeners(new ScoreIterationListener(10));

  log.info("TRAIN MODEL");
  for (int i = 0; i < numEpochs; i++) {
    model.fit(dataIter);
  }

  log.info("EVALUATE MODEL");
  recordReader.reset();

  // The model trained on the training dataset split
  // now that it has trained we evaluate against the
  // test data of images the network has not seen

  recordReader.initialize(test);
  DataSetIterator testIter = new RecordReaderDataSetIterator(recordReader, batchSize, 1, outputNum);
  scaler.fit(testIter);
  testIter.setPreProcessor(scaler);

  /*
  log the order of the labels for later use
  In previous versions the label order was consistent, but random
  In current verions label order is lexicographic
  preserving the RecordReader Labels order is no
  longer needed left in for demonstration
  purposes
  */
  log.info(recordReader.getLabels().toString());

  // Create Eval object with 10 possible classes
  Evaluation eval = new Evaluation(outputNum);

  // Evaluate the network
  while (testIter.hasNext()) {
    DataSet next = testIter.next();
    INDArray output = model.output(next.getFeatures());
    // Compare the Feature Matrix from the model
    // with the labels from the RecordReader
    eval.eval(next.getLabels(), output);
  }
 // show the evaluation
  log.info(eval.stats());
}ََ
And running the test gave me good resultsAs shown in the picture

4-Test the neural network against unsigned images :

in this one load the saved neural net and launch a test On pictures to perform a conformance test and matching ratio.You will find the source code on the following repo.



Commentaires

Posts les plus consultés de ce blog

PLC with ARDUINO (ATmega 328p)

Contents 1  INTRODUCTION 2  TECHNICAL SPECIFICATIONS 3  CHANGES COMPARED TO THE PREVIOUS VERSION (V4) 4  ELECTRONIC SCHEMATIC 5  PCB BOARD DESIGN - Order now at JLCPCB 6  LIST OF ELECTRONIC COMPONENTS 7  STEPS TO UPLOAD A PROGRAM 8  EXTERNAL PARTS AND CONNECTIONS 9  LIST OF EXTERNAL TERMINALS AND ATMEGA328P-AU 10  TEST CODES 10.1  OUTPUTS 10.2  INPUTS AND OUTPUTS 10.3  ANALOG INPUTS 10.4  SERIAL PLOTER 10.5  REAL TIME CLOCK (RTC) INTRODUCTION At the beginning of this year 2020 a video of the PLC V4 was published.  whose device still had to be improved, therefore, for this version 4.1, a Real Time Clock and a DC DC step down source have been integrated. PLC with arduino (ATmega328p AU) V4.1, is a programmable logic controller that was designed by Electroall, whose circuit is based on the SIEMENS S7 1200 CPU1214c PLC device with relay outputs.  Initially, the current version will have a 24VDC power supply like all industrial devices.  In addition, it includes a  Real Time Clock (RTC).  S

Home

Deep Learning is a  superpower .  With  it you can make a computer  see ,  synthesize novel  art , translate  languages ,  render a medical  diagnosis , or build pieces of a  car that can  drive itself . If that isn’t a  superpower, I don’t know what is. What is deep learning? The field of artificial intelligence is essentially when machines can do tasks that typically require human intelligence. It encompasses machine learning, where machines can learn by experience and acquire skills without human involvement. Deep learning is a subset of machine learning where artificial neural networks, algorithms inspired by the human brain, learn from large amounts of data. Similarly to how we learn from experience, the deep learning algorithm would perform a task repeatedly, each time tweaking it a little to improve the outcome. We refer to ‘deep learning’ because the neural networks have various (deep) layers that enable learning. Just about any problem that require

DL4j Spring Boot

1. Introduction: In this article, we'll create a simple neural network with the  deeplearning4j  (dl4j) library – a modern and powerful tool for machine learning. Before we get started, not that this guide doesn't require a profound knowledge of linear algebra, statistics, machine learning theory and lots of other topics necessary for a well-grounded ML engineer. 2. What Is Deep Learning ? Neural networks are computational models that consist of interconnected layers of nodes. Nodes are neuron-like processors of numeric data. They take data from their inputs, apply some weights and functions to these data and send the results to outputs. Such network can be trained with some examples of the source data. Training essentially is saving some numeric state (weights) in the nodes which later affects the computation. Training examples may contain data items with features and certain known classes of these items (for instance, “this set of 16×16 pixels contains a hand-

Understanding Neural Network

Understanding Neural Network What is a neural network? Figure 1: What is a Neural Network? The neural network is a system that mimics a human brain structure. Figure 1 presents a multi-layer feedforward Neural Network structure, which contains an input layer (green), hidden layers (pink) and an output layer (orange). Each layer contains multiple nodes indicated by a small circle, for example, input nodes are in green, hidden nodes are in pink, and output nodes are in orange. Nodes in different layers can connect to each other, and the connection strength between two nodes is called a weight between these nodes. The connection flow is started from the input layer to hidden layers, and then to the output layer. Each node in a hidden layer can accept input connections from a previously hidden layer or input layer. These input connections will be summed and fed to a special function called activation function to form its node's output. As a result, only hidden la