SlideShare a Scribd company logo
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.TikaCoreProperties;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.jpeg.JpegParser;
InputStream stream = new BufferedInputStream(new FileInputStream(path.toFile()))
new JpegParser().parse(stream, new DefaultHandler(), metadata, new ParseContext());
String caption = metadata.get(TikaCoreProperties.DESCRIPTION);
wordart.com
https://becominghuman.ai/cheat-sheets-for-ai-neural-networks-machine-learning-deep-learning-big-data-678c51b4b463
https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf
AlexNet model = new AlexNet(numLabels, seed, iterations);
log.info("Loading data from {}...", imagePath);
PathLabelGenerator labelMaker = new ImageDescriptionLabelGenerator("Trail");
BalancedPathFilter pathFilter = new BalancedPathFilter(rand, NativeImageLoader.ALLOWED_FORMATS, labelMaker);
FileSplit fileSplit = new FileSplit(imagePath, NativeImageLoader.ALLOWED_FORMATS, rand);
InputSplit[] inputSplit = fileSplit.sample(pathFilter, splitTrainTest, 1 - splitTrainTest);
InputSplit trainingData = inputSplit[0];
InputSplit testingData = inputSplit[1];
log.info("Building model...");
AlexNet model = new AlexNet(numLabels, seed, iterations);
model.setInputShape(new int[][] {{ channels, width, height }});
MultiLayerNetwork network = model.init();
log.info("Training model using {} samples...", trainingData.length());
ImageRecordReader recordReader = new ImageRecordReader(height, width, channels, labelMaker);
recordReader.initialize(trainingData, null);
DataSetIterator dataIter = new RecordReaderDataSetIterator(recordReader, batchSize, 1, numLabels);
scaler.fit(dataIter);
DataNormalization scaler = new ImagePreProcessingScaler(0, 1);
dataIter.setPreProcessor(scaler);
MultipleEpochsIterator trainIter = new MultipleEpochsIterator(epochs, dataIter);
network.fit(trainIter);
log.info("Evaluating model using {} samples...", testingData.length());
recordReader.initialize(testingData);
dataIter = new RecordReaderDataSetIterator(recordReader, batchSize, 1, numLabels);
scaler.fit(dataIter);
dataIter.setPreProcessor(scaler);
Evaluation eval = network.evaluate(dataIter);
log.info(eval.stats(true));
log.info("Saving model to {}...", modelPath);
ModelSerializer.writeModel(network, modelPath, true);
14:57:44.074 INFO ImageModelBuilder - Loading data from imagesphotos-1000...
14:57:57.518 INFO ImageModelBuilder - Building model...
14:57:57.550 INFO org.nd4j.linalg.factory.Nd4jBackend - Loaded [CpuBackend] backend
14:57:58.398 INFO org.nd4j.nativeblas.NativeOpsHolder - Number of threads used for NativeOps: 2
14:57:58.724 INFO org.nd4j.nativeblas.Nd4jBlas - Number of threads used for BLAS: 2
14:57:58.726 INFO o.n.l.a.o.e.DefaultOpExecutioner - Backend used: [CPU]; OS: [Windows 10]
14:57:58.726 INFO o.n.l.a.o.e.DefaultOpExecutioner - Cores: [4]; Memory: [10.7GB];
14:57:58.726 INFO o.n.l.a.o.e.DefaultOpExecutioner - Blas vendor: [OPENBLAS]
14:58:03.013 INFO o.d.nn.multilayer.MultiLayerNetwork - Starting MultiLayerNetwork with WorkspaceModes
set to [training: SINGLE; inference: SINGLE]
14:58:04.717 INFO ImageModelBuilder - Training model using 354 samples...
14:58:14.191 INFO o.d.d.i.MultipleEpochsIterator - Epoch 1, number of batches completed 2
14:58:18.025 INFO o.d.o.l.ScoreIterationListener - Score at iteration 0 is 0.8973041230682596
14:58:20.517 INFO o.d.d.i.MultipleEpochsIterator - Epoch 2, number of batches completed 2
14:58:20.937 INFO o.d.o.l.ScoreIterationListener - Score at iteration 1 is 1.3137047898462706
14:58:24.958 INFO o.d.o.l.ScoreIterationListener - Score at iteration 2 is 0.8076716838671805
14:58:26.688 INFO o.d.o.l.ScoreIterationListener - Score at iteration 3 is 1.592903741321036
14:58:26.719 INFO o.d.d.i.MultipleEpochsIterator - Epoch 3, number of batches completed 2
14:58:30.798 INFO o.d.o.l.ScoreIterationListener - Score at iteration 4 is 0.8828689747742253
14:58:32.682 INFO o.d.o.l.ScoreIterationListener - Score at iteration 5 is 1.2827695432226482
14:58:33.259 INFO o.d.d.i.MultipleEpochsIterator - Epoch 4, number of batches completed 2
14:58:36.885 INFO o.d.o.l.ScoreIterationListener - Score at iteration 6 is 0.8240061319768378
14:58:38.641 INFO o.d.o.l.ScoreIterationListener - Score at iteration 7 is 1.4599294093575166
14:58:39.405 INFO o.d.d.i.MultipleEpochsIterator - Epoch 5, number of batches completed 2
14:58:42.013 INFO o.d.o.l.ScoreIterationListener - Score at iteration 8 is 0.8207273637625443
14:58:43.364 INFO o.d.o.l.ScoreIterationListener - Score at iteration 9 is 1.3621771943792143
14:59:21.842 INFO ImageModelBuilder - Evaluating model using 88 samples...
14:59:24.084 INFO ImageModelBuilder -
Examples labeled as not_trail classified by model as not_trail: 44 times
Examples labeled as trail classified by model as not_trail: 44 times
==========================Scores========================================
# of classes: 2
Accuracy: 0.5000
Precision: 0.5000
Recall: 0.5000
F1 Score: 0.0000
========================================================================
14:59:24.084 INFO ImageModelBuilder - Saving model to modelsalexnet-1000-dev.net...
==========================Scores========================================
# of classes: 2
Accuracy: 0.5036
Precision: 0.7510
Recall: 0.5030
F1 Score: 0.6685
========================================================================
MultiLayerNetwork network = ModelSerializer.restoreMultiLayerNetwork(modelPath.toFile());
NativeImageLoader loader = new NativeImageLoader(100, 100, 1);
INDArray image = loader.asMatrix(imagePath.toFile());
DataNormalization scaler = new ImagePreProcessingScaler(0, 1);
scaler.transform(image);
INDArray output = network.output(loadImage(imagePath));
log.info("{} -> {}", imagePath, output.getDouble(0));
trail
trail
NOT trail
NOT trail
trail
trail
trail
Image classification with Deeplearning4j
Image classification with Deeplearning4j
Image classification with Deeplearning4j
Image classification with Deeplearning4j

More Related Content

What's hot

Neo4j after 1 year in production
Neo4j after 1 year in productionNeo4j after 1 year in production
Neo4j after 1 year in production
Andrew Nikishaev
 
Machine Learning Model Bakeoff
Machine Learning Model BakeoffMachine Learning Model Bakeoff
Machine Learning Model Bakeoff
mrphilroth
 
[243] turning data into value
[243] turning data into value[243] turning data into value
[243] turning data into value
NAVER D2
 
Streaming Way to Webscale: How We Scale Bitly via Streaming
Streaming Way to Webscale: How We Scale Bitly via StreamingStreaming Way to Webscale: How We Scale Bitly via Streaming
Streaming Way to Webscale: How We Scale Bitly via Streaming
All Things Open
 
[2C1] 아파치 피그를 위한 테즈 연산 엔진 개발하기 최종
[2C1] 아파치 피그를 위한 테즈 연산 엔진 개발하기 최종[2C1] 아파치 피그를 위한 테즈 연산 엔진 개발하기 최종
[2C1] 아파치 피그를 위한 테즈 연산 엔진 개발하기 최종
NAVER D2
 
집단지성 프로그래밍 08-가격모델링
집단지성 프로그래밍 08-가격모델링집단지성 프로그래밍 08-가격모델링
집단지성 프로그래밍 08-가격모델링
Kwang Woo NAM
 

What's hot (6)

Neo4j after 1 year in production
Neo4j after 1 year in productionNeo4j after 1 year in production
Neo4j after 1 year in production
 
Machine Learning Model Bakeoff
Machine Learning Model BakeoffMachine Learning Model Bakeoff
Machine Learning Model Bakeoff
 
[243] turning data into value
[243] turning data into value[243] turning data into value
[243] turning data into value
 
Streaming Way to Webscale: How We Scale Bitly via Streaming
Streaming Way to Webscale: How We Scale Bitly via StreamingStreaming Way to Webscale: How We Scale Bitly via Streaming
Streaming Way to Webscale: How We Scale Bitly via Streaming
 
[2C1] 아파치 피그를 위한 테즈 연산 엔진 개발하기 최종
[2C1] 아파치 피그를 위한 테즈 연산 엔진 개발하기 최종[2C1] 아파치 피그를 위한 테즈 연산 엔진 개발하기 최종
[2C1] 아파치 피그를 위한 테즈 연산 엔진 개발하기 최종
 
집단지성 프로그래밍 08-가격모델링
집단지성 프로그래밍 08-가격모델링집단지성 프로그래밍 08-가격모델링
집단지성 프로그래밍 08-가격모델링
 

Similar to Image classification with Deeplearning4j

FØCAL Boston AiR - Computer Vision Tracing and Hardware Simulation
FØCAL Boston AiR - Computer Vision Tracing and Hardware SimulationFØCAL Boston AiR - Computer Vision Tracing and Hardware Simulation
FØCAL Boston AiR - Computer Vision Tracing and Hardware Simulation
FØCAL
 
Exploring OpenFaaS autoscalability on Kubernetes with the Chaos Toolkit
Exploring OpenFaaS autoscalability on Kubernetes with the Chaos ToolkitExploring OpenFaaS autoscalability on Kubernetes with the Chaos Toolkit
Exploring OpenFaaS autoscalability on Kubernetes with the Chaos Toolkit
Sylvain Hellegouarch
 
Deep learning with kafka
Deep learning with kafkaDeep learning with kafka
Deep learning with kafka
Nitin Kumar
 
計算機性能の限界点とその考え方
計算機性能の限界点とその考え方計算機性能の限界点とその考え方
計算機性能の限界点とその考え方
Naoto MATSUMOTO
 
A Complex SSIS Package
A Complex SSIS PackageA Complex SSIS Package
A Complex SSIS Package
Nitil Dwivedi
 
Pycon Sec
Pycon SecPycon Sec
Pycon Sec
guesta762e4
 
Machine learning in php
Machine learning in phpMachine learning in php
Machine learning in php
Damien Seguy
 
1_chlamydia task completely best.docx
1_chlamydia task completely best.docx1_chlamydia task completely best.docx
1_chlamydia task completely best.docx
RachaelMutheu
 
Easing the Complex with SPBench framework
Easing the Complex with SPBench frameworkEasing the Complex with SPBench framework
Easing the Complex with SPBench framework
adriano1mg
 
Project Jugaad
Project JugaadProject Jugaad
Nagios Conference 2014 - Rodrigo Faria - Developing your Plugin
Nagios Conference 2014 - Rodrigo Faria - Developing your PluginNagios Conference 2014 - Rodrigo Faria - Developing your Plugin
Nagios Conference 2014 - Rodrigo Faria - Developing your Plugin
Nagios
 
Stress your DUT
Stress your DUTStress your DUT
Stress your DUT
Redge Technologies
 
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
PROIDEA
 
PgQ Generic high-performance queue for PostgreSQL
PgQ Generic high-performance queue for PostgreSQLPgQ Generic high-performance queue for PostgreSQL
PgQ Generic high-performance queue for PostgreSQL
elliando dias
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
flyinweb
 
DPDK layer for porting IPS-IDS
DPDK layer for porting IPS-IDSDPDK layer for porting IPS-IDS
DPDK layer for porting IPS-IDS
Vipin Varghese
 
How Automated Vulnerability Analysis Discovered Hundreds of Android 0-days
How Automated Vulnerability Analysis Discovered Hundreds of Android 0-daysHow Automated Vulnerability Analysis Discovered Hundreds of Android 0-days
How Automated Vulnerability Analysis Discovered Hundreds of Android 0-days
Priyanka Aash
 
Cloud Services - Gluecon 2010
Cloud Services - Gluecon 2010Cloud Services - Gluecon 2010
Cloud Services - Gluecon 2010
Oren Teich
 
Building a PII scrubbing layer
Building a PII scrubbing layerBuilding a PII scrubbing layer
Building a PII scrubbing layer
Tilak Patidar
 
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific StatisticsThe Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
Michael Rosenblum
 

Similar to Image classification with Deeplearning4j (20)

FØCAL Boston AiR - Computer Vision Tracing and Hardware Simulation
FØCAL Boston AiR - Computer Vision Tracing and Hardware SimulationFØCAL Boston AiR - Computer Vision Tracing and Hardware Simulation
FØCAL Boston AiR - Computer Vision Tracing and Hardware Simulation
 
Exploring OpenFaaS autoscalability on Kubernetes with the Chaos Toolkit
Exploring OpenFaaS autoscalability on Kubernetes with the Chaos ToolkitExploring OpenFaaS autoscalability on Kubernetes with the Chaos Toolkit
Exploring OpenFaaS autoscalability on Kubernetes with the Chaos Toolkit
 
Deep learning with kafka
Deep learning with kafkaDeep learning with kafka
Deep learning with kafka
 
計算機性能の限界点とその考え方
計算機性能の限界点とその考え方計算機性能の限界点とその考え方
計算機性能の限界点とその考え方
 
A Complex SSIS Package
A Complex SSIS PackageA Complex SSIS Package
A Complex SSIS Package
 
Pycon Sec
Pycon SecPycon Sec
Pycon Sec
 
Machine learning in php
Machine learning in phpMachine learning in php
Machine learning in php
 
1_chlamydia task completely best.docx
1_chlamydia task completely best.docx1_chlamydia task completely best.docx
1_chlamydia task completely best.docx
 
Easing the Complex with SPBench framework
Easing the Complex with SPBench frameworkEasing the Complex with SPBench framework
Easing the Complex with SPBench framework
 
Project Jugaad
Project JugaadProject Jugaad
Project Jugaad
 
Nagios Conference 2014 - Rodrigo Faria - Developing your Plugin
Nagios Conference 2014 - Rodrigo Faria - Developing your PluginNagios Conference 2014 - Rodrigo Faria - Developing your Plugin
Nagios Conference 2014 - Rodrigo Faria - Developing your Plugin
 
Stress your DUT
Stress your DUTStress your DUT
Stress your DUT
 
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
 
PgQ Generic high-performance queue for PostgreSQL
PgQ Generic high-performance queue for PostgreSQLPgQ Generic high-performance queue for PostgreSQL
PgQ Generic high-performance queue for PostgreSQL
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
 
DPDK layer for porting IPS-IDS
DPDK layer for porting IPS-IDSDPDK layer for porting IPS-IDS
DPDK layer for porting IPS-IDS
 
How Automated Vulnerability Analysis Discovered Hundreds of Android 0-days
How Automated Vulnerability Analysis Discovered Hundreds of Android 0-daysHow Automated Vulnerability Analysis Discovered Hundreds of Android 0-days
How Automated Vulnerability Analysis Discovered Hundreds of Android 0-days
 
Cloud Services - Gluecon 2010
Cloud Services - Gluecon 2010Cloud Services - Gluecon 2010
Cloud Services - Gluecon 2010
 
Building a PII scrubbing layer
Building a PII scrubbing layerBuilding a PII scrubbing layer
Building a PII scrubbing layer
 
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific StatisticsThe Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
The Hidden Face of Cost-Based Optimizer: PL/SQL Specific Statistics
 

More from Eric Jain

Combining your data with Zenobase
Combining your data with ZenobaseCombining your data with Zenobase
Combining your data with Zenobase
Eric Jain
 
Java Time Puzzlers
Java Time PuzzlersJava Time Puzzlers
Java Time Puzzlers
Eric Jain
 
OSGi and Eclipse RCP
OSGi and Eclipse RCPOSGi and Eclipse RCP
OSGi and Eclipse RCP
Eric Jain
 
beta.uniprot.org - 5 Lessons Learned
beta.uniprot.org - 5 Lessons Learnedbeta.uniprot.org - 5 Lessons Learned
beta.uniprot.org - 5 Lessons Learned
Eric Jain
 
UniProt REST API
UniProt REST APIUniProt REST API
UniProt REST API
Eric Jain
 
UniProt & Ontologies
UniProt & OntologiesUniProt & Ontologies
UniProt & Ontologies
Eric Jain
 

More from Eric Jain (6)

Combining your data with Zenobase
Combining your data with ZenobaseCombining your data with Zenobase
Combining your data with Zenobase
 
Java Time Puzzlers
Java Time PuzzlersJava Time Puzzlers
Java Time Puzzlers
 
OSGi and Eclipse RCP
OSGi and Eclipse RCPOSGi and Eclipse RCP
OSGi and Eclipse RCP
 
beta.uniprot.org - 5 Lessons Learned
beta.uniprot.org - 5 Lessons Learnedbeta.uniprot.org - 5 Lessons Learned
beta.uniprot.org - 5 Lessons Learned
 
UniProt REST API
UniProt REST APIUniProt REST API
UniProt REST API
 
UniProt & Ontologies
UniProt & OntologiesUniProt & Ontologies
UniProt & Ontologies
 

Recently uploaded

LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
GauravCar
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
MiscAnnoy1
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
architagupta876
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 

Recently uploaded (20)

LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 

Image classification with Deeplearning4j

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. import org.apache.tika.metadata.Metadata; import org.apache.tika.metadata.TikaCoreProperties; import org.apache.tika.parser.ParseContext; import org.apache.tika.parser.jpeg.JpegParser; InputStream stream = new BufferedInputStream(new FileInputStream(path.toFile())) new JpegParser().parse(stream, new DefaultHandler(), metadata, new ParseContext()); String caption = metadata.get(TikaCoreProperties.DESCRIPTION);
  • 10.
  • 11.
  • 14.
  • 15.
  • 16. AlexNet model = new AlexNet(numLabels, seed, iterations);
  • 17. log.info("Loading data from {}...", imagePath); PathLabelGenerator labelMaker = new ImageDescriptionLabelGenerator("Trail"); BalancedPathFilter pathFilter = new BalancedPathFilter(rand, NativeImageLoader.ALLOWED_FORMATS, labelMaker); FileSplit fileSplit = new FileSplit(imagePath, NativeImageLoader.ALLOWED_FORMATS, rand); InputSplit[] inputSplit = fileSplit.sample(pathFilter, splitTrainTest, 1 - splitTrainTest); InputSplit trainingData = inputSplit[0]; InputSplit testingData = inputSplit[1]; log.info("Building model..."); AlexNet model = new AlexNet(numLabels, seed, iterations); model.setInputShape(new int[][] {{ channels, width, height }}); MultiLayerNetwork network = model.init(); log.info("Training model using {} samples...", trainingData.length()); ImageRecordReader recordReader = new ImageRecordReader(height, width, channels, labelMaker); recordReader.initialize(trainingData, null); DataSetIterator dataIter = new RecordReaderDataSetIterator(recordReader, batchSize, 1, numLabels); scaler.fit(dataIter); DataNormalization scaler = new ImagePreProcessingScaler(0, 1); dataIter.setPreProcessor(scaler); MultipleEpochsIterator trainIter = new MultipleEpochsIterator(epochs, dataIter); network.fit(trainIter); log.info("Evaluating model using {} samples...", testingData.length()); recordReader.initialize(testingData); dataIter = new RecordReaderDataSetIterator(recordReader, batchSize, 1, numLabels); scaler.fit(dataIter); dataIter.setPreProcessor(scaler); Evaluation eval = network.evaluate(dataIter); log.info(eval.stats(true)); log.info("Saving model to {}...", modelPath); ModelSerializer.writeModel(network, modelPath, true);
  • 18. 14:57:44.074 INFO ImageModelBuilder - Loading data from imagesphotos-1000... 14:57:57.518 INFO ImageModelBuilder - Building model... 14:57:57.550 INFO org.nd4j.linalg.factory.Nd4jBackend - Loaded [CpuBackend] backend 14:57:58.398 INFO org.nd4j.nativeblas.NativeOpsHolder - Number of threads used for NativeOps: 2 14:57:58.724 INFO org.nd4j.nativeblas.Nd4jBlas - Number of threads used for BLAS: 2 14:57:58.726 INFO o.n.l.a.o.e.DefaultOpExecutioner - Backend used: [CPU]; OS: [Windows 10] 14:57:58.726 INFO o.n.l.a.o.e.DefaultOpExecutioner - Cores: [4]; Memory: [10.7GB]; 14:57:58.726 INFO o.n.l.a.o.e.DefaultOpExecutioner - Blas vendor: [OPENBLAS] 14:58:03.013 INFO o.d.nn.multilayer.MultiLayerNetwork - Starting MultiLayerNetwork with WorkspaceModes set to [training: SINGLE; inference: SINGLE] 14:58:04.717 INFO ImageModelBuilder - Training model using 354 samples... 14:58:14.191 INFO o.d.d.i.MultipleEpochsIterator - Epoch 1, number of batches completed 2 14:58:18.025 INFO o.d.o.l.ScoreIterationListener - Score at iteration 0 is 0.8973041230682596 14:58:20.517 INFO o.d.d.i.MultipleEpochsIterator - Epoch 2, number of batches completed 2 14:58:20.937 INFO o.d.o.l.ScoreIterationListener - Score at iteration 1 is 1.3137047898462706 14:58:24.958 INFO o.d.o.l.ScoreIterationListener - Score at iteration 2 is 0.8076716838671805 14:58:26.688 INFO o.d.o.l.ScoreIterationListener - Score at iteration 3 is 1.592903741321036 14:58:26.719 INFO o.d.d.i.MultipleEpochsIterator - Epoch 3, number of batches completed 2 14:58:30.798 INFO o.d.o.l.ScoreIterationListener - Score at iteration 4 is 0.8828689747742253 14:58:32.682 INFO o.d.o.l.ScoreIterationListener - Score at iteration 5 is 1.2827695432226482 14:58:33.259 INFO o.d.d.i.MultipleEpochsIterator - Epoch 4, number of batches completed 2 14:58:36.885 INFO o.d.o.l.ScoreIterationListener - Score at iteration 6 is 0.8240061319768378 14:58:38.641 INFO o.d.o.l.ScoreIterationListener - Score at iteration 7 is 1.4599294093575166 14:58:39.405 INFO o.d.d.i.MultipleEpochsIterator - Epoch 5, number of batches completed 2 14:58:42.013 INFO o.d.o.l.ScoreIterationListener - Score at iteration 8 is 0.8207273637625443 14:58:43.364 INFO o.d.o.l.ScoreIterationListener - Score at iteration 9 is 1.3621771943792143 14:59:21.842 INFO ImageModelBuilder - Evaluating model using 88 samples... 14:59:24.084 INFO ImageModelBuilder - Examples labeled as not_trail classified by model as not_trail: 44 times Examples labeled as trail classified by model as not_trail: 44 times ==========================Scores======================================== # of classes: 2 Accuracy: 0.5000 Precision: 0.5000 Recall: 0.5000 F1 Score: 0.0000 ======================================================================== 14:59:24.084 INFO ImageModelBuilder - Saving model to modelsalexnet-1000-dev.net...
  • 19. ==========================Scores======================================== # of classes: 2 Accuracy: 0.5036 Precision: 0.7510 Recall: 0.5030 F1 Score: 0.6685 ========================================================================
  • 20.
  • 21.
  • 22. MultiLayerNetwork network = ModelSerializer.restoreMultiLayerNetwork(modelPath.toFile()); NativeImageLoader loader = new NativeImageLoader(100, 100, 1); INDArray image = loader.asMatrix(imagePath.toFile()); DataNormalization scaler = new ImagePreProcessingScaler(0, 1); scaler.transform(image); INDArray output = network.output(loadImage(imagePath)); log.info("{} -> {}", imagePath, output.getDouble(0));
  • 23.
  • 24. trail
  • 25.
  • 26. trail
  • 27.
  • 29.
  • 31.
  • 32. trail
  • 33.
  • 34. trail
  • 35.
  • 36. trail