-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImage_Classification.html
1466 lines (1427 loc) · 85.8 KB
/
Image_Classification.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.3.433">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Image Classification - Happy or Sad</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
</style>
<script src="Image_Classification_files/libs/clipboard/clipboard.min.js"></script>
<script src="Image_Classification_files/libs/quarto-html/quarto.js"></script>
<script src="Image_Classification_files/libs/quarto-html/popper.min.js"></script>
<script src="Image_Classification_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="Image_Classification_files/libs/quarto-html/anchor.min.js"></script>
<link href="Image_Classification_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="Image_Classification_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="Image_Classification_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="Image_Classification_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="Image_Classification_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script src="Image_Classification_files/libs/quarto-diagram/mermaid.min.js"></script>
<script src="Image_Classification_files/libs/quarto-diagram/mermaid-init.js"></script>
<link href="Image_Classification_files/libs/quarto-diagram/mermaid.css" rel="stylesheet">
</head>
<body class="fullcontent">
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Image Classification - Happy or Sad</h1>
</div>
<div class="quarto-title-meta">
</div>
</header>
<p>This notebook demonstrates the process of building and training a Convolutional Neural Network (CNN) model to classify images as “happy” or “sad.” We will use TensorFlow and Keras for model creation and training.</p>
<div class="cell">
<div class="cell-output-display">
<div>
<div>
<pre class="mermaid mermaid-js">graph LR
A[Input Layer] --> B[Convolutional Layer 1]
B --> C[MaxPooling Layer 1]
C --> D[Convolutional Layer 2]
D --> E[MaxPooling Layer 2]
E --> F[Convolutional Layer 3]
F --> G[MaxPooling Layer 3]
G --> H[Flatten Layer]
H --> I[Dense Layer 1]
I --> J[Output Layer]
style A fill:#f9f,stroke:#333,stroke-width:2px
style B fill:#f9f,stroke:#333,stroke-width:2px
style C fill:#f9f,stroke:#333,stroke-width:2px
style D fill:#f9f,stroke:#333,stroke-width:2px
style E fill:#f9f,stroke:#333,stroke-width:2px
style F fill:#f9f,stroke:#333,stroke-width:2px
style G fill:#f9f,stroke:#333,stroke-width:2px
style H fill:#f9f,stroke:#333,stroke-width:2px
style I fill:#f9f,stroke:#333,stroke-width:2px
style J fill:#f9f,stroke:#333,stroke-width:2px
</pre>
</div>
</div>
</div>
</div>
<section id="data-preprocessing" class="level2">
<h2 class="anchored" data-anchor-id="data-preprocessing">Data Preprocessing</h2>
<p>In this section, we load and preprocess the dataset of images representing happy and sad emotions. We remove any images with unsupported file extensions and scale the pixel values to be between 0 and 1 for efficient training.</p>
<section id="preprocessing-code" class="level3">
<h3 class="anchored" data-anchor-id="preprocessing-code">Preprocessing Code</h3>
<div class="cell" data-execution_count="3">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Preprocessing Code</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="co">#%pip install tensorflow opencv-python matplotlib </span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> tensorflow <span class="im">as</span> tf</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> os</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="co"># ...</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="4">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>os.path.join(<span class="st">"data"</span>,<span class="st">"happy"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="4">
<pre><code>'data/happy'</code></pre>
</div>
</div>
</section>
<section id="check-if-a-gpu-is-available" class="level3">
<h3 class="anchored" data-anchor-id="check-if-a-gpu-is-available">Check if a GPU is available</h3>
<div class="cell" data-execution_count="2">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>gpus <span class="op">=</span> tf.config.experimental.list_physical_devices(<span class="st">'GPU'</span>)</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="bu">len</span>(gpus)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="2">
<pre><code>0</code></pre>
</div>
</div>
</section>
<section id="avoid-oom-errors-by-setting-gpu-memory-consumption-growth" class="level3">
<h3 class="anchored" data-anchor-id="avoid-oom-errors-by-setting-gpu-memory-consumption-growth">Avoid OOM Errors By Setting GPU Memory Consumption Growth</h3>
<div class="cell" data-execution_count="5">
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Avoid OOM Errors By Setting GPU Memory Consumption Growth</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>gpus <span class="op">=</span> tf.config.experimental.list_physical_devices(<span class="st">'GPU'</span>)</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> gpu <span class="kw">in</span> gpus:</span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> tf.config.experimental.set_memory_growth(gpu, <span class="va">True</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="remove-dodgy-images" class="level3">
<h3 class="anchored" data-anchor-id="remove-dodgy-images">Remove dodgy images</h3>
<div class="cell" data-execution_count="6">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> cv2</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> imghdr</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> matplotlib.pyplot <span class="im">as</span> plt</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>/var/folders/v8/l1n5gfyn3zj_f5m_0z4bv2m80000gn/T/ipykernel_4077/2011824555.py:2: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13
import imghdr</code></pre>
</div>
</div>
<div class="cell" data-execution_count="7">
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>data_dir <span class="op">=</span> <span class="st">"data"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="8">
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>os.listdir(os.path.join(data_dir,<span class="st">"happy"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="8">
<pre><code>['images26.jpg',
'images241.jpg',
'images32.jpg',
'89ca5d41335b4f9207b9cf03538a7dbd63497e474912837562cb9f58809ac32f._RI_TTW_.png',
'05-12-21-happy-people.jpg',
'110754-utyeqqosky-1547658396.jpeg',
'image22.jpeg',
'Happy.jpg',
'images137.jpg',
'Overtly-Cheerful-Primer-Editorials-min.png',
'how-happy-are-healthy-people.jpg',
'170404-happy-workers-feature.jpg',
'images27.jpg',
'friends-happy-190821.jpg',
'images242.jpg',
'goup-happy-people-group-jumping-isolated-white-background-35582232.jpg',
'images134.jpg',
'images120.jpg',
'GettyImages-454356720.jpg',
'WorldHappinessReport_620.jpg',
'_86a43964-aa8e-11e8-82d1-388e3d6e11aa.jpg',
'images243.jpg',
'images30.jpg',
'png-transparent-graphy-happy-people-love-child-photography-thumbnail.png',
'young-and-happy-people-vector-15114154.jpg',
'images247.jpg',
'file-20230208-27-3jttof.jpg',
'images125.jpg',
'friends_190412.jpg',
'images21.jpg',
'images246.jpg',
'happy-people-jump-with-raised-arms-characters-win_107791-14884.jpg',
'images250.jpg',
'images23.jpg',
'happy-peaceful.jpg',
'images132.jpg',
'MV5BMTM3ODM0NTQ1MF5BMl5BanBnXkFtZTcwMzAxMTM5OA._V1_FMjpg_UX1000_.jpg',
'gdfVVm_MyCRtqpvdkt8vtSB1n_oz_CpwCq6vNMpj0S8.jpg',
'images245.jpg',
'images236.jpg',
'images79.jpg',
'images183.jpg',
'images197.jpg',
'happiness.jpg',
'images6.jpg',
'maxresdefault.jpg',
'shiny-happy-people.jpg',
'images7.jpg',
'images196.jpg',
'images182.jpg',
'20150413185238-secrets-happy-entrepreneurs-woman-gratitude-rainbow-.jpeg',
'images78.jpg',
'images50.jpg',
'happy-person.jpeg',
'images87.jpg',
'images91.jpg',
'images85.jpg',
'images235.jpg',
'image24.jpeg',
'group-portrait-happy-people-disabilities-49330313.jpg',
'images156.jpg',
'GettyImages-871518740.jpg',
'images195.jpg',
'nm-how-happiness-affects-health-tnail.jpg',
'images208.jpg',
'images47.jpg',
'images53.jpg',
'images220.jpg',
'images84.jpg',
'group-young-happy-people-with-their-hands-up_369728-62.jpg',
'images218.jpg',
'images57.jpg',
'images43.jpg',
'1HEoLBLidT2u4mhJ0oiDgig.png',
'images191.jpg',
'images146.jpg',
'where-to-watch-shiny-happy-people.jpg',
'happy-woman-in-nature-at-sunset.jpg',
'image25.jpeg',
'9b65a25adca61c48bcb01370116723e3--happy-people-brings.jpg',
'_happy_jumping_on_beach-40815.jpg',
'i00YzYyLTkxY2ItY2I3OWE3NDBmNDVmXkEyXkFqcGdeQXVyMjkwOTAyMDU._V1_FMjpg_UX1000_.jpg',
'VJdvLa-download-happy-blackman-png.png',
'Duggar-Family-Secrets-Are-Exposed-in-New-Docuseries-Featuring-Jill-and-Amy-featured.png',
'613k1XcpYCL.jpg',
'images42.jpg',
'images81.jpg',
'images95.jpg',
'56f455011e0000b300705475.jpeg',
'images83.jpg',
'hand-drawn-happy-friends-jumping_23-2149095224.jpg',
'images179.jpg',
'images150.jpg',
'A_Sep20_14_1189155141.jpg',
'ipsos-global-advisor-happiness-2022-opti.jpg',
'images193.jpg',
'images55.jpg',
'images232.jpg',
'happy-indians_5f66fd46d9f5b.jpg',
'images70.jpg',
'Happy-people-800x533.jpg',
'Screen-Shot-2012-10-23-at-12.57.22-PM.png',
'images161.jpg',
'images149.jpg',
'images148.jpg',
'images160.jpg',
'Screaming-Happy-Woman-THe-Trent.jpg',
'images71.jpg',
'343515-worldhappinessreport1440.jpg',
'happiness_thumbnail.jpg',
'images200.jpg',
'images214.jpg',
'images189.jpg',
'images176.jpg',
'happy-people.jpg',
'image30.jpeg',
'images66.jpg',
'Successful-year.jpg',
'images211.jpg',
'7VR73K6EP5ETVEOUFANWBUYJEQ.jpg',
'physed-happiness-superJumbo.jpg',
'images9.jpg',
'988689_Wallpaper2.jpg',
'happy-people2.jpg',
'35438_hd.jpg',
'images199.jpg',
'Happy-People-PNG.png',
'happy-people-vector-839522.jpg',
'images63.jpg',
'images210.jpg',
'images77.jpg',
'images204.jpg',
'images238.jpg',
'Dollarphotoclub_76084977-1.jpg',
'images49.jpg',
'images206.jpg',
'jumping-and-dancing-happy-people-positive-emotions-set-illustration-free-vector.jpg',
'habits-of-happy-people.jpg',
'1_617fd1e2590c2.jpg',
'dv2051009.jpg',
'happy-woman.jpg',
'377dac1b50ef865c920abb84d9d3857d173750b14306061e9aa5b4a1ec0dcdfa-rimg-w1196-h796-gmir.jpg',
'smile.woman_.jpg',
'images159.jpg',
'images74.jpg',
'images13.jpg',
'Happy-Guy.jpg',
'getty_152414899_97046097045006_68075.jpg',
'images102.jpg',
'images117.jpg',
'106827976-1611251261868-twenty20_33fd1f3f-9221-4c64-bcb1-bfeec3022d9b.jpg',
'images249.jpg',
'images12.jpg',
'image16.jpeg',
'images10.jpg',
'what-makes-people-happy1.jpg',
'getty_505175324_2000131020009280246_158016.jpg',
'group-of-happy-people-2.jpg',
'happy-people_1463241208.jpg',
'images128.jpg',
'images114.jpg',
'getty_478389113_970647970450091_99776.jpg',
'images11.jpg',
'images29.jpg',
'happy-people-in-the-poppy-field-1280x800-wide-wallpapers-net.jpg',
'images15.jpg',
'riskshappypeopletakeh_1384254283.jpg',
'835405.jpg',
'images110.jpg',
'hdptcar-fi-2.jpg',
'images105.jpg',
'images139.jpg',
'happy-woman-headphones-pink-african-american-1296x728-header.jpg',
'web3-happy-people-outside-smile-sun-nature-eduardo-dutra-620857-unsplash.jpg',
'hand-drawn-happy-people-jumping_23-2149092878.jpg',
'images14.jpg',
'goup-happy-people-35582464.jpg',
'compassion-900x387.jpg',
'images107.jpg',
'happypeople-1024x679.jpg',
'images106.jpg',
'images17.jpg',
'png-clipart-happiness-graphy-smile-happy-people-love-photography.png']</code></pre>
</div>
</div>
<div class="cell" data-execution_count="9">
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>image_exts <span class="op">=</span> [<span class="st">"jpg"</span>, <span class="st">"jpeg"</span>, <span class="st">"png"</span>, <span class="st">"bmp"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="10">
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>image_exts[<span class="dv">0</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="10">
<pre><code>'jpg'</code></pre>
</div>
</div>
<div class="cell" data-execution_count="11">
<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> image_class <span class="kw">in</span> os.listdir(data_dir):</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> image <span class="kw">in</span> os.listdir(os.path.join(data_dir, image_class)):</span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(image)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>images26.jpg
images241.jpg
images32.jpg
89ca5d41335b4f9207b9cf03538a7dbd63497e474912837562cb9f58809ac32f._RI_TTW_.png
05-12-21-happy-people.jpg
110754-utyeqqosky-1547658396.jpeg
image22.jpeg
Happy.jpg
images137.jpg
Overtly-Cheerful-Primer-Editorials-min.png
how-happy-are-healthy-people.jpg
170404-happy-workers-feature.jpg
images27.jpg
friends-happy-190821.jpg
images242.jpg
goup-happy-people-group-jumping-isolated-white-background-35582232.jpg
images134.jpg
images120.jpg
GettyImages-454356720.jpg
WorldHappinessReport_620.jpg
_86a43964-aa8e-11e8-82d1-388e3d6e11aa.jpg
images243.jpg
images30.jpg
png-transparent-graphy-happy-people-love-child-photography-thumbnail.png
young-and-happy-people-vector-15114154.jpg
images247.jpg
file-20230208-27-3jttof.jpg
images125.jpg
friends_190412.jpg
images21.jpg
images246.jpg
happy-people-jump-with-raised-arms-characters-win_107791-14884.jpg
images250.jpg
images23.jpg
happy-peaceful.jpg
images132.jpg
MV5BMTM3ODM0NTQ1MF5BMl5BanBnXkFtZTcwMzAxMTM5OA._V1_FMjpg_UX1000_.jpg
gdfVVm_MyCRtqpvdkt8vtSB1n_oz_CpwCq6vNMpj0S8.jpg
images245.jpg
images236.jpg
images79.jpg
images183.jpg
images197.jpg
happiness.jpg
images6.jpg
maxresdefault.jpg
shiny-happy-people.jpg
images7.jpg
images196.jpg
images182.jpg
20150413185238-secrets-happy-entrepreneurs-woman-gratitude-rainbow-.jpeg
images78.jpg
images50.jpg
happy-person.jpeg
images87.jpg
images91.jpg
images85.jpg
images235.jpg
image24.jpeg
group-portrait-happy-people-disabilities-49330313.jpg
images156.jpg
GettyImages-871518740.jpg
images195.jpg
nm-how-happiness-affects-health-tnail.jpg
images208.jpg
images47.jpg
images53.jpg
images220.jpg
images84.jpg
group-young-happy-people-with-their-hands-up_369728-62.jpg
images218.jpg
images57.jpg
images43.jpg
1HEoLBLidT2u4mhJ0oiDgig.png
images191.jpg
images146.jpg
where-to-watch-shiny-happy-people.jpg
happy-woman-in-nature-at-sunset.jpg
image25.jpeg
9b65a25adca61c48bcb01370116723e3--happy-people-brings.jpg
_happy_jumping_on_beach-40815.jpg
i00YzYyLTkxY2ItY2I3OWE3NDBmNDVmXkEyXkFqcGdeQXVyMjkwOTAyMDU._V1_FMjpg_UX1000_.jpg
VJdvLa-download-happy-blackman-png.png
Duggar-Family-Secrets-Are-Exposed-in-New-Docuseries-Featuring-Jill-and-Amy-featured.png
613k1XcpYCL.jpg
images42.jpg
images81.jpg
images95.jpg
56f455011e0000b300705475.jpeg
images83.jpg
hand-drawn-happy-friends-jumping_23-2149095224.jpg
images179.jpg
images150.jpg
A_Sep20_14_1189155141.jpg
ipsos-global-advisor-happiness-2022-opti.jpg
images193.jpg
images55.jpg
images232.jpg
happy-indians_5f66fd46d9f5b.jpg
images70.jpg
Happy-people-800x533.jpg
Screen-Shot-2012-10-23-at-12.57.22-PM.png
images161.jpg
images149.jpg
images148.jpg
images160.jpg
Screaming-Happy-Woman-THe-Trent.jpg
images71.jpg
343515-worldhappinessreport1440.jpg
happiness_thumbnail.jpg
images200.jpg
images214.jpg
images189.jpg
images176.jpg
happy-people.jpg
image30.jpeg
images66.jpg
Successful-year.jpg
images211.jpg
7VR73K6EP5ETVEOUFANWBUYJEQ.jpg
physed-happiness-superJumbo.jpg
images9.jpg
988689_Wallpaper2.jpg
happy-people2.jpg
35438_hd.jpg
images199.jpg
Happy-People-PNG.png
happy-people-vector-839522.jpg
images63.jpg
images210.jpg
images77.jpg
images204.jpg
images238.jpg
Dollarphotoclub_76084977-1.jpg
images49.jpg
images206.jpg
jumping-and-dancing-happy-people-positive-emotions-set-illustration-free-vector.jpg
habits-of-happy-people.jpg
1_617fd1e2590c2.jpg
dv2051009.jpg
happy-woman.jpg
377dac1b50ef865c920abb84d9d3857d173750b14306061e9aa5b4a1ec0dcdfa-rimg-w1196-h796-gmir.jpg
smile.woman_.jpg
images159.jpg
images74.jpg
images13.jpg
Happy-Guy.jpg
getty_152414899_97046097045006_68075.jpg
images102.jpg
images117.jpg
106827976-1611251261868-twenty20_33fd1f3f-9221-4c64-bcb1-bfeec3022d9b.jpg
images249.jpg
images12.jpg
image16.jpeg
images10.jpg
what-makes-people-happy1.jpg
getty_505175324_2000131020009280246_158016.jpg
group-of-happy-people-2.jpg
happy-people_1463241208.jpg
images128.jpg
images114.jpg
getty_478389113_970647970450091_99776.jpg
images11.jpg
images29.jpg
happy-people-in-the-poppy-field-1280x800-wide-wallpapers-net.jpg
images15.jpg
riskshappypeopletakeh_1384254283.jpg
835405.jpg
images110.jpg
hdptcar-fi-2.jpg
images105.jpg
images139.jpg
happy-woman-headphones-pink-african-american-1296x728-header.jpg
web3-happy-people-outside-smile-sun-nature-eduardo-dutra-620857-unsplash.jpg
hand-drawn-happy-people-jumping_23-2149092878.jpg
images14.jpg
goup-happy-people-35582464.jpg
compassion-900x387.jpg
images107.jpg
happypeople-1024x679.jpg
images106.jpg
images17.jpg
png-clipart-happiness-graphy-smile-happy-people-love-photography.png
42-15542443.jpg
sad-person-concept-vector-26538685.jpg
png-transparent-woman-sad-folklore-ghost-horror-spirit-vendetta-vengeance-girl-person-thumbnail.png
sad-people-icon-2CCHXB2.jpg
2652760.jpg
dreamstime_s_101440985.jpg
aid12707023-v4-1200px-Make-a-Sad-Person-Happy-Step-10.jpg
man-portrait-contemplative-sad-looking-at-camera-732x549-thumbnail.jpg
iStock_000001932580XSmall.jpg
pexels-photo-4584665.jpeg
n-rendering-frustrated-upset-man-sitting-white-people-man-character-53250684.jpg
image-asset.jpeg
sadness-person-depression-clip-art-bored-cliparts.jpg
sad-eating_620x350_71525950886.jpg
sadness-inside-out-today-main-tease-191018.jpg
maxresdefault2.jpg
images20.jpg
sad-adult-man-checking-bad-news-smart-phone-side-view-portrait-park-161654848.jpg
7RNXwSxCAKL8vGtXG2ZkyD-1200-80.jpg
getty_91745128_333755.jpg
depressed-woman-sitting-chair-dark-room-home_53476-2193.jpg
SAD.jpg
person-super-depressed.jpg
sad-glance-mm-nisan-kandilcioglu.jpg
73705bd7debb66c2afc780a22c223804.jpg
Sad-man-being-consoled-by-friends-in-group-therapy.jpg
214-2142366_transparent-depression-png-depressed-sad-person-png-png.png
maxresdefault.jpg
5acf9ed1146e711e008b46d7.jpg
Science_robotgait_124649246.jpg
Sadder-not-wiser_AdobeStock_219682170.jpg
283-2838105_clipart-resting-man-sad-person-silhouette-png.png
stock-photo-depressed-man-studio-shot-404652526.jpg
Make-someone-sad-happy.jpg
314071_2200-732x549.jpg
dark-depression-mood-people-wallpaper-preview.jpg
63218722.jpg
Sad-People.jpg
8iAb9k4aT.jpg
280-2804580_sad-people-png-sad-person-png-transparent-png.png
crying-at-work.jpg
all-those-people-who-are-sad-17573-1.jpg
anxious-man-indoors-front-view_23-2149729600.jpg
lonely-depressed-person-sitting-near-brick-wall_181624-30778.jpg
-unhappy-miss-good-chance-dressed-casually-isolated-yellow-wall_273609-37534.jpg
107188144-1675355909384-gettyimages-1302154722-dsc_9175.jpeg
sadness.jpg
depression-1020x680.jpg
crying-on-steps-e1505252236719-300x200.jpg
sad-people-vector-26812552.jpg
sad2.jpg
Depression-Quotes-from-Books-1-1.jpg
How-To-Make-Someone-Happy-When-Theyre-Sad.jpg
sad-depressed-man-702x375.jpg
sad-hero.jpg
1694806.jpg
sad-woman.jpg
pngtree-portrait-of-sad-person-vector-picture-image_2293852.jpg
405-4050267_sad-people-png-sad-person-transparent-background-png.png
man-tears-tear-look.jpg
Sad-man-sitting-in-bedroom-header.jpg
man-with-head-down-300x300.jpg
186918-afqmdoqiwx-1676522411.jpg
sad-people-group-therapy-session_23-2148752071.jpg
Depression-Vs-Sadness-Are-You-Just-Sad-Or-Depressed-2020-960x640.jpg
image-20160914-4963-19knfh1.jpg
sad-wise-woman-at-window.jpg
screen-shot-2014-07-31-at-6-09-12-pm.png
images14.jpg
_2539df08-4f50-11e6-85e3-522dd231fa74.jpg
boy-with-head-down.jpg
Seasonal-affective-disorder.png
b2ap3_large_happy-sad-unsplash-850x575.jpg</code></pre>
</div>
</div>
<div class="cell" data-execution_count="12">
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>img <span class="op">=</span> cv2.imread(os.path.join(data_dir, <span class="st">"happy"</span>, <span class="st">"_86a43964-aa8e-11e8-82d1-388e3d6e11aa.jpg"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="13">
<div class="sourceCode cell-code" id="cb18"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a>img.shape</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="13">
<pre><code>(540, 960, 3)</code></pre>
</div>
</div>
<div class="cell" data-execution_count="14">
<div class="sourceCode cell-code" id="cb20"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a>plt.show()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<p><img src="Image_Classification_files/figure-html/cell-14-output-1.png" class="img-fluid"></p>
</div>
</div>
<div class="cell" data-execution_count="15">
<div class="sourceCode cell-code" id="cb21"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> image_class <span class="kw">in</span> os.listdir(data_dir):</span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> image <span class="kw">in</span> os.listdir(os.path.join(data_dir, image_class)):</span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a> image_path <span class="op">=</span> os.path.join(data_dir, image_class, image)</span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">try</span>:</span>
<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a> img <span class="op">=</span> cv2.imread(image_path)</span>
<span id="cb21-6"><a href="#cb21-6" aria-hidden="true" tabindex="-1"></a> tip <span class="op">=</span> imghdr.what(image_path)</span>
<span id="cb21-7"><a href="#cb21-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> tip <span class="kw">not</span> <span class="kw">in</span> image_exts:</span>
<span id="cb21-8"><a href="#cb21-8" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">"Image not in ext list </span><span class="sc">{}</span><span class="st">"</span> .<span class="bu">format</span>(image_path))</span>
<span id="cb21-9"><a href="#cb21-9" aria-hidden="true" tabindex="-1"></a> os.remove(image_path)</span>
<span id="cb21-10"><a href="#cb21-10" aria-hidden="true" tabindex="-1"></a> <span class="cf">except</span> <span class="pp">Exception</span> <span class="im">as</span> e:</span>
<span id="cb21-11"><a href="#cb21-11" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">"Issue with image at </span><span class="sc">{}</span><span class="st">"</span> .<span class="bu">format</span>(image_path))</span>
<span id="cb21-12"><a href="#cb21-12" aria-hidden="true" tabindex="-1"></a> <span class="co"># os.remove(image_path)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>libpng warning: iCCP: known incorrect sRGB profile</code></pre>
</div>
</div>
</section>
</section>
<section id="load-the-dataset" class="level2">
<h2 class="anchored" data-anchor-id="load-the-dataset">Load the dataset</h2>
<div class="cell">
<div class="sourceCode cell-code" id="cb23"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a>tf.data.Dataset.??</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="16">
<div class="sourceCode cell-code" id="cb24"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> numpy <span class="im">as</span> np</span>
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> matplotlib <span class="im">import</span> pyplot <span class="im">as</span> plt</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="17">
<div class="sourceCode cell-code" id="cb25"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a>data <span class="op">=</span> tf.keras.utils.image_dataset_from_directory(<span class="st">'data'</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Found 256 files belonging to 2 classes.</code></pre>
</div>
</div>
<div class="cell" data-execution_count="18">
<div class="sourceCode cell-code" id="cb27"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a>data_iterators <span class="op">=</span> data.as_numpy_iterator()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="dataset-exploration" class="level1">
<h1>Dataset Exploration</h1>
<p>In this section, we explore the loaded dataset and visualize some sample images.</p>
<div class="cell" data-execution_count="20">
<div class="sourceCode cell-code" id="cb28"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a><span class="co"># get another batch from data_iterators</span></span>
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a>batch <span class="op">=</span> data_iterators.<span class="bu">next</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="21">
<div class="sourceCode cell-code" id="cb29"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="bu">len</span>(batch)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="21">
<pre><code>2</code></pre>
</div>
</div>
<div class="cell" data-execution_count="22">
<div class="sourceCode cell-code" id="cb31"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a><span class="co"># images represent as numpy arrays</span></span>
<span id="cb31-2"><a href="#cb31-2" aria-hidden="true" tabindex="-1"></a>batch[<span class="dv">0</span>].shape</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="22">
<pre><code>(32, 256, 256, 3)</code></pre>
</div>
</div>
<div class="cell" data-execution_count="23">
<div class="sourceCode cell-code" id="cb33"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a><span class="co"># class 0 = happy</span></span>
<span id="cb33-2"><a href="#cb33-2" aria-hidden="true" tabindex="-1"></a><span class="co"># class 1 = sad</span></span>
<span id="cb33-3"><a href="#cb33-3" aria-hidden="true" tabindex="-1"></a>batch[<span class="dv">1</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="23">
<pre><code>array([0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 1, 1, 0, 0, 0], dtype=int32)</code></pre>
</div>
</div>
<div class="cell" data-execution_count="24">
<div class="sourceCode cell-code" id="cb35"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a>fig, ax <span class="op">=</span> plt.subplots(ncols<span class="op">=</span><span class="dv">4</span>, figsize<span class="op">=</span>(<span class="dv">20</span>, <span class="dv">20</span>))</span>
<span id="cb35-2"><a href="#cb35-2" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> idx, img <span class="kw">in</span> <span class="bu">enumerate</span>(batch[<span class="dv">0</span>][:<span class="dv">4</span>]):</span>
<span id="cb35-3"><a href="#cb35-3" aria-hidden="true" tabindex="-1"></a> ax[idx].imshow(img.astype(<span class="bu">int</span>))</span>
<span id="cb35-4"><a href="#cb35-4" aria-hidden="true" tabindex="-1"></a> ax[idx].title.set_text(batch[<span class="dv">1</span>][idx])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<p><img src="Image_Classification_files/figure-html/cell-24-output-1.png" class="img-fluid"></p>
</div>
</div>
<div class="cell" data-execution_count="25">
<div class="sourceCode cell-code" id="cb36"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a>scaled <span class="op">=</span> batch[<span class="dv">0</span>]<span class="op">/</span><span class="dv">255</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="26">
<div class="sourceCode cell-code" id="cb37"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a>scaled[<span class="dv">0</span>].<span class="bu">max</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="26">
<pre><code>1.0</code></pre>
</div>
</div>
<section id="data-preprocessing---scaling" class="level2">
<h2 class="anchored" data-anchor-id="data-preprocessing---scaling">Data Preprocessing - Scaling</h2>
<p>In this section, we scale the pixel values of the images to be between 0 and 1.</p>
<div class="cell" data-execution_count="27">
<div class="sourceCode cell-code" id="cb39"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a>data <span class="op">=</span> data.<span class="bu">map</span>(<span class="kw">lambda</span> x, y: (x<span class="op">/</span><span class="dv">255</span>, y))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="28">
<div class="sourceCode cell-code" id="cb40"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a>scaled_iterator <span class="op">=</span> data.as_numpy_iterator()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="29">
<div class="sourceCode cell-code" id="cb41"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a>batch <span class="op">=</span> scaled_iterator.<span class="bu">next</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>2023-07-27 03:58:21.672218: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile</code></pre>
</div>
</div>
<div class="cell" data-execution_count="30">
<div class="sourceCode cell-code" id="cb43"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a>batch[<span class="dv">0</span>].<span class="bu">max</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="30">
<pre><code>1.0</code></pre>
</div>
</div>
<div class="cell" data-execution_count="31">
<div class="sourceCode cell-code" id="cb45"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb45-1"><a href="#cb45-1" aria-hidden="true" tabindex="-1"></a>fig, ax <span class="op">=</span> plt.subplots(ncols<span class="op">=</span><span class="dv">4</span>, figsize<span class="op">=</span>(<span class="dv">20</span>, <span class="dv">20</span>))</span>
<span id="cb45-2"><a href="#cb45-2" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> idx, img <span class="kw">in</span> <span class="bu">enumerate</span>(batch[<span class="dv">0</span>][:<span class="dv">4</span>]):</span>
<span id="cb45-3"><a href="#cb45-3" aria-hidden="true" tabindex="-1"></a> ax[idx].imshow(img)</span>
<span id="cb45-4"><a href="#cb45-4" aria-hidden="true" tabindex="-1"></a> ax[idx].title.set_text(batch[<span class="dv">1</span>][idx])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<p><img src="Image_Classification_files/figure-html/cell-31-output-1.png" class="img-fluid"></p>
</div>
</div>
<div class="cell" data-execution_count="32">
<div class="sourceCode cell-code" id="cb46"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb46-1"><a href="#cb46-1" aria-hidden="true" tabindex="-1"></a><span class="bu">len</span>(data)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="32">
<pre><code>8</code></pre>
</div>
</div>
</section>
<section id="data-splitting" class="level2">
<h2 class="anchored" data-anchor-id="data-splitting">Data Splitting</h2>
<p>In this section, we split the dataset into training, validation, and test sets.</p>
<div class="cell" data-execution_count="33">
<div class="sourceCode cell-code" id="cb48"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb48-1"><a href="#cb48-1" aria-hidden="true" tabindex="-1"></a>train_size <span class="op">=</span> <span class="bu">int</span>(<span class="bu">len</span>(data)<span class="op">*</span><span class="fl">.7</span>)</span>
<span id="cb48-2"><a href="#cb48-2" aria-hidden="true" tabindex="-1"></a>val_size <span class="op">=</span> <span class="bu">int</span>(<span class="bu">len</span>(data)<span class="op">*</span><span class="fl">.2</span>)<span class="op">+</span><span class="dv">1</span></span>
<span id="cb48-3"><a href="#cb48-3" aria-hidden="true" tabindex="-1"></a>test_size <span class="op">=</span> <span class="bu">int</span>(<span class="bu">len</span>(data)<span class="op">*</span><span class="fl">.1</span>)<span class="op">+</span><span class="dv">1</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="34">
<div class="sourceCode cell-code" id="cb49"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb49-1"><a href="#cb49-1" aria-hidden="true" tabindex="-1"></a>train <span class="op">=</span> data.take(train_size)</span>
<span id="cb49-2"><a href="#cb49-2" aria-hidden="true" tabindex="-1"></a>val <span class="op">=</span> data.skip(train_size).take(val_size)</span>
<span id="cb49-3"><a href="#cb49-3" aria-hidden="true" tabindex="-1"></a>test <span class="op">=</span> data.skip(train_size<span class="op">+</span>val_size).take(test_size)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="35">
<div class="sourceCode cell-code" id="cb50"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb50-1"><a href="#cb50-1" aria-hidden="true" tabindex="-1"></a><span class="bu">len</span>(test)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="35">
<pre><code>1</code></pre>
</div>
</div>
</section>
</section>
<section id="deep-model" class="level1">
<h1>DEEP MODEL</h1>
<section id="good-stuff" class="level2">
<h2 class="anchored" data-anchor-id="good-stuff">good stuff</h2>
</section>
<section id="model-architecture" class="level2">
<h2 class="anchored" data-anchor-id="model-architecture">Model Architecture</h2>
<p>In this section, we define the CNN model architecture using Keras. We use the Sequential model from Keras to define the CNN. The model consists of 3 convolutional layers with a ReLU activation function and max pooling layers in between. At the end of the model, we have a fully connected layer with a sigmoid activation function. We use the Adam optimizer and categorical cross entropy as the loss function.</p>
<div class="cell" data-execution_count="36">
<div class="sourceCode cell-code" id="cb52"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb52-1"><a href="#cb52-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tensorflow.keras.models <span class="im">import</span> Sequential</span>
<span id="cb52-2"><a href="#cb52-2" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tensorflow.keras.layers <span class="im">import</span> Dense, Conv2D, MaxPooling2D, Flatten</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="37">
<div class="sourceCode cell-code" id="cb53"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb53-1"><a href="#cb53-1" aria-hidden="true" tabindex="-1"></a>model <span class="op">=</span> Sequential()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell">
<div class="cell-output-display">
<div>
<div>
<pre class="mermaid mermaid-js">graph LR
A[Input Layer] --> B[Convolutional Layer 1]
B --> C[MaxPooling Layer 1]
C --> D[Convolutional Layer 2]
D --> E[MaxPooling Layer 2]
E --> F[Convolutional Layer 3]
F --> G[MaxPooling Layer 3]
G --> H[Flatten Layer]
H --> I[Dense Layer 1]
I --> J[Output Layer]
style A fill:#f9f,stroke:#333,stroke-width:2px
style B fill:#f9f,stroke:#333,stroke-width:2px
style C fill:#f9f,stroke:#333,stroke-width:2px
style D fill:#f9f,stroke:#333,stroke-width:2px
style E fill:#f9f,stroke:#333,stroke-width:2px
style F fill:#f9f,stroke:#333,stroke-width:2px
style G fill:#f9f,stroke:#333,stroke-width:2px
style H fill:#f9f,stroke:#333,stroke-width:2px
style I fill:#f9f,stroke:#333,stroke-width:2px
style J fill:#f9f,stroke:#333,stroke-width:2px
</pre>
</div>
</div>
</div>
</div>
<div class="cell" data-execution_count="38">
<div class="sourceCode cell-code" id="cb54"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb54-1"><a href="#cb54-1" aria-hidden="true" tabindex="-1"></a>model.add(Conv2D(<span class="dv">16</span>, (<span class="dv">3</span>, <span class="dv">3</span>), activation<span class="op">=</span><span class="st">'relu'</span>, input_shape<span class="op">=</span>(<span class="dv">256</span>, <span class="dv">256</span>, <span class="dv">3</span>)))</span>
<span id="cb54-2"><a href="#cb54-2" aria-hidden="true" tabindex="-1"></a>model.add(MaxPooling2D())</span>
<span id="cb54-3"><a href="#cb54-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb54-4"><a href="#cb54-4" aria-hidden="true" tabindex="-1"></a>model.add(Conv2D(<span class="dv">32</span>, (<span class="dv">3</span>, <span class="dv">3</span>), activation<span class="op">=</span><span class="st">'relu'</span>))</span>
<span id="cb54-5"><a href="#cb54-5" aria-hidden="true" tabindex="-1"></a>model.add(MaxPooling2D())</span>
<span id="cb54-6"><a href="#cb54-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb54-7"><a href="#cb54-7" aria-hidden="true" tabindex="-1"></a>model.add(Conv2D(<span class="dv">64</span>, (<span class="dv">3</span>, <span class="dv">3</span>), activation<span class="op">=</span><span class="st">'relu'</span>))</span>
<span id="cb54-8"><a href="#cb54-8" aria-hidden="true" tabindex="-1"></a>model.add(MaxPooling2D())</span>
<span id="cb54-9"><a href="#cb54-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb54-10"><a href="#cb54-10" aria-hidden="true" tabindex="-1"></a>model.add(Flatten())</span>
<span id="cb54-11"><a href="#cb54-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb54-12"><a href="#cb54-12" aria-hidden="true" tabindex="-1"></a>model.add(Dense(<span class="dv">256</span>, activation<span class="op">=</span><span class="st">'relu'</span>))</span>
<span id="cb54-13"><a href="#cb54-13" aria-hidden="true" tabindex="-1"></a>model.add(Dense(<span class="dv">1</span>, activation<span class="op">=</span><span class="st">'sigmoid'</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="39">
<div class="sourceCode cell-code" id="cb55"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb55-1"><a href="#cb55-1" aria-hidden="true" tabindex="-1"></a>model.<span class="bu">compile</span>(optimizer<span class="op">=</span><span class="st">'adam'</span>, loss<span class="op">=</span><span class="st">'binary_crossentropy'</span>, metrics<span class="op">=</span>[<span class="st">'accuracy'</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="40">
<div class="sourceCode cell-code" id="cb56"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb56-1"><a href="#cb56-1" aria-hidden="true" tabindex="-1"></a>model.summary()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 254, 254, 16) 448
max_pooling2d (MaxPooling2 (None, 127, 127, 16) 0
D)
conv2d_1 (Conv2D) (None, 125, 125, 32) 4640
max_pooling2d_1 (MaxPoolin (None, 62, 62, 32) 0
g2D)
conv2d_2 (Conv2D) (None, 60, 60, 64) 18496
max_pooling2d_2 (MaxPoolin (None, 30, 30, 64) 0
g2D)
flatten (Flatten) (None, 57600) 0
dense (Dense) (None, 256) 14745856
dense_1 (Dense) (None, 1) 257
=================================================================
Total params: 14769697 (56.34 MB)
Trainable params: 14769697 (56.34 MB)
Non-trainable params: 0 (0.00 Byte)
_________________________________________________________________</code></pre>
</div>
</div>
</section>
</section>
<section id="model-training" class="level1">
<h1>Model Training</h1>
<section id="another-good-stuff" class="level2">
<h2 class="anchored" data-anchor-id="another-good-stuff">another good stuff</h2>
<p>In this section, we train the CNN model on the training and validation sets.</p>
<div class="cell" data-execution_count="41">
<div class="sourceCode cell-code" id="cb58"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb58-1"><a href="#cb58-1" aria-hidden="true" tabindex="-1"></a>log_dir <span class="op">=</span> <span class="st">"logs"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="42">
<div class="sourceCode cell-code" id="cb59"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb59-1"><a href="#cb59-1" aria-hidden="true" tabindex="-1"></a>tensorboard_callback <span class="op">=</span> tf.keras.callbacks.TensorBoard(log_dir<span class="op">=</span>log_dir)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-execution_count="43">
<div class="sourceCode cell-code" id="cb60"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb60-1"><a href="#cb60-1" aria-hidden="true" tabindex="-1"></a>hist <span class="op">=</span> model.fit(train, epochs<span class="op">=</span><span class="dv">20</span>, validation_data<span class="op">=</span>val, callbacks<span class="op">=</span>[tensorboard_callback])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Epoch 1/20
5/5 [==============================] - ETA: 0s - loss: 2.1236 - accuracy: 0.62505/5 [==============================] - 6s 852ms/step - loss: 2.1236 - accuracy: 0.6250 - val_loss: 1.0543 - val_accuracy: 0.3281
Epoch 2/20
5/5 [==============================] - ETA: 0s - loss: 0.7020 - accuracy: 0.57505/5 [==============================] - 5s 752ms/step - loss: 0.7020 - accuracy: 0.5750 - val_loss: 0.5787 - val_accuracy: 0.6719
Epoch 3/20
5/5 [==============================] - ETA: 0s - loss: 0.4572 - accuracy: 0.76885/5 [==============================] - 6s 886ms/step - loss: 0.4572 - accuracy: 0.7688 - val_loss: 0.4715 - val_accuracy: 0.7188
Epoch 4/20
5/5 [==============================] - ETA: 0s - loss: 0.4542 - accuracy: 0.76885/5 [==============================] - 6s 864ms/step - loss: 0.4542 - accuracy: 0.7688 - val_loss: 0.5098 - val_accuracy: 0.7188
Epoch 5/20
5/5 [==============================] - ETA: 0s - loss: 0.4182 - accuracy: 0.80625/5 [==============================] - 5s 749ms/step - loss: 0.4182 - accuracy: 0.8062 - val_loss: 0.3729 - val_accuracy: 0.9062
Epoch 6/20
5/5 [==============================] - ETA: 0s - loss: 0.3648 - accuracy: 0.83135/5 [==============================] - 5s 734ms/step - loss: 0.3648 - accuracy: 0.8313 - val_loss: 0.2589 - val_accuracy: 0.9375
Epoch 7/20
5/5 [==============================] - ETA: 0s - loss: 0.2975 - accuracy: 0.93125/5 [==============================] - 5s 735ms/step - loss: 0.2975 - accuracy: 0.9312 - val_loss: 0.3374 - val_accuracy: 0.7812
Epoch 8/20
5/5 [==============================] - ETA: 0s - loss: 0.2943 - accuracy: 0.86875/5 [==============================] - 5s 768ms/step - loss: 0.2943 - accuracy: 0.8687 - val_loss: 0.2920 - val_accuracy: 0.9062
Epoch 9/20
5/5 [==============================] - ETA: 0s - loss: 0.1788 - accuracy: 0.97505/5 [==============================] - 8s 1s/step - loss: 0.1788 - accuracy: 0.9750 - val_loss: 0.2523 - val_accuracy: 0.9062
Epoch 10/20
5/5 [==============================] - ETA: 0s - loss: 0.2026 - accuracy: 0.93755/5 [==============================] - 7s 1s/step - loss: 0.2026 - accuracy: 0.9375 - val_loss: 0.1680 - val_accuracy: 0.9375
Epoch 11/20
5/5 [==============================] - ETA: 0s - loss: 0.1517 - accuracy: 0.95635/5 [==============================] - 6s 898ms/step - loss: 0.1517 - accuracy: 0.9563 - val_loss: 0.1164 - val_accuracy: 0.9688
Epoch 12/20
5/5 [==============================] - ETA: 0s - loss: 0.1141 - accuracy: 0.98755/5 [==============================] - 6s 883ms/step - loss: 0.1141 - accuracy: 0.9875 - val_loss: 0.1531 - val_accuracy: 0.9531
Epoch 13/20
5/5 [==============================] - ETA: 0s - loss: 0.1109 - accuracy: 0.96885/5 [==============================] - 5s 796ms/step - loss: 0.1109 - accuracy: 0.9688 - val_loss: 0.0471 - val_accuracy: 1.0000
Epoch 14/20
5/5 [==============================] - ETA: 0s - loss: 0.0717 - accuracy: 0.98125/5 [==============================] - 5s 796ms/step - loss: 0.0717 - accuracy: 0.9812 - val_loss: 0.0218 - val_accuracy: 1.0000
Epoch 15/20
5/5 [==============================] - ETA: 0s - loss: 0.0526 - accuracy: 0.98755/5 [==============================] - 5s 695ms/step - loss: 0.0526 - accuracy: 0.9875 - val_loss: 0.0296 - val_accuracy: 0.9844
Epoch 16/20
5/5 [==============================] - ETA: 0s - loss: 0.0416 - accuracy: 0.99375/5 [==============================] - 5s 768ms/step - loss: 0.0416 - accuracy: 0.9937 - val_loss: 0.0382 - val_accuracy: 1.0000
Epoch 17/20
5/5 [==============================] - ETA: 0s - loss: 0.0256 - accuracy: 0.99375/5 [==============================] - 5s 900ms/step - loss: 0.0256 - accuracy: 0.9937 - val_loss: 0.0402 - val_accuracy: 0.9844
Epoch 18/20
5/5 [==============================] - ETA: 0s - loss: 0.0400 - accuracy: 0.99375/5 [==============================] - 7s 1s/step - loss: 0.0400 - accuracy: 0.9937 - val_loss: 0.0165 - val_accuracy: 1.0000
Epoch 19/20
5/5 [==============================] - ETA: 0s - loss: 0.0165 - accuracy: 1.00005/5 [==============================] - 5s 788ms/step - loss: 0.0165 - accuracy: 1.0000 - val_loss: 0.0145 - val_accuracy: 1.0000
Epoch 20/20
5/5 [==============================] - ETA: 0s - loss: 0.0105 - accuracy: 1.00005/5 [==============================] - 6s 1s/step - loss: 0.0105 - accuracy: 1.0000 - val_loss: 0.0081 - val_accuracy: 1.0000</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>2023-07-27 04:03:14.023704: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:18.255534: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:19.815394: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:23.174734: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:24.809815: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:28.622819: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:30.526848: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:34.421046: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:36.104529: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:39.478804: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:41.039956: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:44.435770: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:45.963591: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:49.178376: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:50.743021: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:54.037560: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:03:55.951233: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:01.456234: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:03.457572: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:08.061141: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:10.113932: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:13.776048: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:15.621654: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:19.308929: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:21.379377: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:25.076040: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:26.674164: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:30.163587: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:31.851561: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:34.950114: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:36.486424: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:39.724312: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:41.355761: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:45.180619: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:46.793976: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:52.472749: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:54.119024: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:57.169953: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:04:59.122699: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile
2023-07-27 04:05:03.629668: W tensorflow/core/lib/png/png_io.cc:88] PNG warning: iCCP: known incorrect sRGB profile</code></pre>
</div>