This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update && \ | |
sudo apt-get install -y software-properties-common && \ | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test && \ | |
sudo apt-get update && \ | |
sudo apt-get install -y gcc-7 g++-7 && \ | |
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 60 && \ | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final class MyTranslator implements Translator<BufferedImage, Classifications> { | |
private static final List<String> CLASSES = Arrays.asList("Normal", "Pneumonia"); | |
@Override | |
public NDList processInput(TranslatorContext ctx, BufferedImage input) { | |
NDArray array = | |
BufferedImageUtils.toNDArray( | |
ctx.getNDManager(), input, NDImageUtils.Flag.COLOR); | |
array = NDImageUtils.resize(array, 224).div(255.0f); | |
return new NDList(array); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Criteria<BufferedImage, Classifications> criteria = | |
Criteria.builder() | |
.setTypes(BufferedImage.class, Classifications.class) | |
.optTranslator(new MyTranslator()) | |
.build(); | |
try (ZooModel<BufferedImage, Classifications> model = ModelZoo.loadModel(criteria)) { | |
try (Predictor<BufferedImage, Classifications> predictor = model.newPredictor()) { | |
Classifications result = predictor.predict(image); | |
logger.info("Diagnose: {}", result); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Criteria<BufferedImage, Classifications> criteria = | |
Criteria.builder() | |
.setTypes(BufferedImage.class, Classifications.class) | |
.optTranslator(new MyTranslator()) | |
.build(); | |
try (ZooModel<BufferedImage, Classifications> model = ModelZoo.loadModel(criteria)) { | |
try (Predictor<BufferedImage, Classifications> predictor = model.newPredictor()) { | |
Classifications result = predictor.predict(image); | |
logger.info("Diagnose:" + result.toString()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repositories { | |
jcenter() | |
} | |
dependencies { | |
implementation "ai.djl:api:0.5.0" | |
implementation "ai.djl.tensorflow:tensorflow-api:0.5.0" | |
implementation "ai.djl.tensorflow:tensorflow-engine:0.5.0" | |
runtimeOnly "ai.djl.tensorflow:tensorflow-native-auto:2.1.0" | |
runtimeOnly "org.slf4j:slf4j-simple:1.7.29" | |
testImplementation "junit:junit:4.12" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[main] INFO com.examples.PneumoniaDetection - Diagnose: [ | |
class: "Pneumonia", probability: 0.99310 | |
class: "Normal", probability: 0.00689 | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./gradlew run -Dai.djl.repository.zoo.location=models/saved_model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python build_covid_dataset.py --covid covid-chestxray-dataset --output dataset/covid | |
python sample_kaggle_dataset.py --kaggle chest_xray --output dataset/normal | |
python train_covid19.py --dataset dataset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Epoch 1.4.1 Duration(ms) 1.5.0 Duration(ms) | |
0 230.757866 236.492851 | |
1 222.984238 210.10698 | |
2 201.988141 216.398906 | |
3 180.265748 193.985564 | |
4 186.75808 184.309184 | |
5 175.55141 189.248856 | |
6 176.789087 181.657551 | |
7 175.327701 178.745348 | |
8 170.667204 177.222914 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Gluon Estimator example on MNIST dataset with simple CNN""" | |
import sys | |
import os | |
import time | |
import mxnet as mx | |
from mxnet import gluon, nd, autograd | |
from mxnet import metric | |
from mxnet.gluon import nn, data | |
from mxnet.gluon.contrib.estimator import Estimator |
NewerOlder