Image Classification with Lazarus

Now the 16 Steps (extract):

Ign:1https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 InRelease Get:2https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ InRelease [3,626 B] Ign:3https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 InRelease Hit:4https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 Release Hit:5https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 Release Get:6http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Get:7https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages [67.4 kB] Get:8http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic InRelease [15.9 kB] Hit:9http://archive.ubuntu.com/ubuntu bionic InRelease Get:11http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Hit:13http://ppa.launchpad.net/cran/libgit2/ubuntu bionic InRelease Get:14http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB] Hit:15http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic InRelease Get:16http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [581 kB] Hit:17http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease Get:18http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1,428 kB] Get:19http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic/main Sources [1,802 kB] Get:20http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [2,335 kB] Get:21http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [2,202 kB] Get:22http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [613 kB] Get:23http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic/main amd64 Packages [922 kB] Get:24http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [2,770 kB] Fetched 13.0 MB in 4s (3,425 kB/s) Reading package lists... Done
Reading package lists... Done Building dependency tree Reading state information... Done git is already the newest version (1:2.17.1-1ubuntu0.9).
Cloning into 'neural-api'... remote: Enumerating objects: 2372, done. remote: Counting objects: 100% (494/494), done. remote: Compressing objects: 100% (370/370), done. remote: Total 2372 (delta 340), reused 236 (delta 124), pack-reused 1878 Receiving objects: 100% (2372/2372), 4.58 MiB | 10.38 MiB/s, done. Resolving deltas: 100% (1585/1585), done.
mtprocs/examples A mtprocs/examples/parallelloop1.lpr A mtprocs/examples/parallelloop_nested1.lpi A mtprocs/examples/parallelloop_nested1.lpr A mtprocs/examples/recursivemtp1.lpr A mtprocs/examples/simplemtp1.lpr A mtprocs/examples/parallelloop1.lpi A mtprocs/examples/recursivemtp1.lpi A mtprocs/examples/simplemtp1.lpi A mtprocs/examples/testmtp1.lpi A mtprocs/examples/testmtp1.lpr A mtprocs/Readme.txt A mtprocs/mtprocs.pas A mtprocs/mtpcpu.pas A mtprocs/multithreadprocslaz.lpk A mtprocs/mtputils.pas A mtprocs/multithreadprocslaz.pas Checked out revision 8093.
-rw-r--r-- 1 root root 5694 Sep 23 08:37 neural-api/examples/SimpleImageClassifier/SimpleImageClassifier.lpi
Hint: (lazarus) [RunTool] /usr/bin/fpc "-iWTOTP" Hint: (lazarus) [RunTool] /usr/bin/fpc "-va" "compilertest.pas" TProject.DoLoadStateFile Statefile not found: /content/neural-api/bin/x86_64-linux/units/SimpleImageClassifier.compiled Hint: (lazarus) [RunTool] /usr/bin/fpc "-iWTOTP" "-Px86_64" "-Tlinux" Hint: (lazarus) [RunTool] /usr/bin/fpc "-va" "-Px86_64" "-Tlinux" "compilertest.pas" Hint: (11031) End of reading config file /etc/fpc.cfg Free Pascal Compiler version 3.0.4+dfsg-18ubuntu2 [2018/08/29] for x86_64 Copyright (c) 1993-2017 by Florian Klaempfl and others (1002) Target OS: Linux for x86-64 (3104) Compiling SimpleImageClassifier.lpr (3104) Compiling /content/neural-api/neural/neuralnetwork.pas (3104) Compiling /content/neural-api/neural/neuralvolume.pas
-rwxr-xr-x 1 root root 1951024 Sep 23 08:43neural-api/bin/x86_64-linux/bin/SimpleImageClassifier*
import os import urllib.request if not os.path.isfile('cifar-10-batches-bin/data_batch_1.bin'): print("Downloading CIFAR-10 Files") url = 'https://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz' urllib.request.urlretrieve(url, './file.tar') Downloading CIFAR-10 Filestotal 166080 -rw-r--r-- 1 root root 170052171 Sep 23 08:46 file.tar drwxr-xr-x 5 root root 4096 Sep 23 08:39mtprocs/ drwxr-xr-x 7 root root 4096 Sep 23 08:42neural-api/ drwxr-xr-x 1 root root 4096 Sep 16 13:40sample_data/
cifar-10-batches-bin/ cifar-10-batches-bin/data_batch_1.bin cifar-10-batches-bin/batches.meta.txt cifar-10-batches-bin/data_batch_3.bin cifar-10-batches-bin/data_batch_4.bin cifar-10-batches-bin/test_batch.bin cifar-10-batches-bin/readme.html cifar-10-batches-bin/data_batch_5.bin cifar-10-batches-bin/data_batch_2.binif not os.path.isfile('./data_batch_1.bin'): print("Copying files to current folder") !cp ./cifar-10-batches-bin/* ./Copying files to current folder
if os.path.isfile('./data_batch_1.bin'): print("RUNNING!")
RUNNING! Creating Neural Network... Layers: 12 Neurons:331 Weights:162498 Sum: -19.536575 File name is: SimpleImageClassifier-64 Learning rate:0.001000 L2 decay:0.000010 Inertia:0.900000 Batch size:64 Step size:64 Staircase ephocs:10 Training images: 40000 Validation images: 10000 Test images: 10000 File name is: SimpleImageClassifier-64 Learning rate:0.001000 L2 decay:0.000010 Inertia:0.900000 Batch size:64 Step size:64 Staircase ephocs:10 Training images: 40000 Validation images: 10000 Test images: 10000 RUNNING! Creating Neural Network... Layers: 12 Neurons:331 Weights:162498 Sum: -19.536575VALIDATION RECORD! Saving NN at SimpleImageClassifier-64.nn Epochs: 20 - Examples seen:800000 Validation Accuracy: 0.8077 Validation Error: 0.5409 Validation Loss: 0.5646 Total time: 69.72min Layer 0 Starting Testing. Epochs: 20 Examples seen:800000 Test Accuracy: 0.8013 Test Error: 0.5539 Test Loss: 0.5934 Total time: 70.75min
Epoch time: 2.2958 minutes. 50 epochs: 1.9132 hours.
Epochs: 20. Working time: 1.18 hours.
Learning rate set to: 0.00082
Layer 11 Max Output: 0.608 Min Output: 0.000 TNNetSoftMax 10,1,1 Times: 0.00s 0.00s Parent:10 Starting Testing. Epochs: 50 Examples seen:2000000 Test Accuracy: 0.8393 Test Error: 0.4457 Test Loss: 0.4874 Total time: 176.12min Epoch time: 2.3167 minutes. 50 epochs: 1.9306 hours. Epochs: 50. Working time: 2.94 hours. Finished.14.from google.colab import files
-rw-r--r-- 1 root root 61 Sep 23 08:51 batches.meta.txt drwxr-xr-x 2 2156 1103 4096 Jun 4 2009 cifar-10-batches-bin -rw-r--r-- 1 root root 30730000 Sep 23 08:51 data_batch_1.bin -rw-r--r-- 1 root root 30730000 Sep 23 08:51 data_batch_2.bin -rw-r--r-- 1 root root 30730000 Sep 23 08:51 data_batch_3.bin -rw-r--r-- 1 root root 30730000 Sep 23 08:51 data_batch_4.bin -rw-r--r-- 1 root root 30730000 Sep 23 08:51 data_batch_5.bin -rw-r--r-- 1 root root 170052171 Sep 23 08:46 file.tar drwxr-xr-x 5 root root 4096 Sep 23 08:39 mtprocs drwxr-xr-x 7 root root 4096 Sep 23 08:42 neural-api -rw-r--r-- 1 root root 88 Sep 23 08:51 readme.html drwxr-xr-x 1 root root 4096 Sep 16 13:40 sample_data -rw-r--r-- 1 root root 3390 Sep 23 11:48 SimpleImageClassifier-64.csv -rw-r--r-- 1 root root 2349757 Sep 23 11:41 SimpleImageClassifier-64.nn -rw-r--r-- 1 root root 30730000 Sep 23 08:51 test_batch.bin15.files.download('SimpleImageClassifier-64.nn') 16.files.download('SimpleImageClassifier-64.csv') FileNotFoundError: Cannot find file: SimpleImageClassifier.csv 16. files.download('SimpleImageClassifier-64.csv')

Summary of the 16 Steps:

# -*- coding: utf-8 -*- """
Kopie von EKON_SimpleImageClassificationCPU_2021.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1clvG2uoMGo-_bfrJnxBJmpNTxjvnsMx9
"""
1. !apt-get update
2. !apt-get install fpc fpc-source lazarus git subversion3. !git clone https://github.com/joaopauloschuler/neural-api.git4. !svn checkout https://svn.code.sf.net/p/lazarus-ccr/svn/components/multithreadprocs mtprocs5. !lazbuild mtprocs/multithreadprocslaz.lpk6. !ls -l neural-api/examples/SimpleImageClassifier/SimpleImageClassifier.lpi7. !lazbuild neural-api/examples/SimpleImageClassifier/SimpleImageClassifier.lpi 9. ls -l neural-api/bin/x86_64-linux/bin/SimpleImageClassifier10. import os import urllib.request
if not os.path.isfile('cifar-10-batches-bin/data_batch_1.bin'):
print("Downloading CIFAR-10 Files")
url = 'https://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz' urllib.request.urlretrieve(url, './file.tar')

11. ls -l
!tar -xvf ./file.tar

12. if not os.path.isfile('./data_batch_1.bin'):
print("Copying files to current folder") !cp ./cifar-10-batches-bin/* ./
13. if os.path.isfile('./data_batch_1.bin'):
print("RUNNING!")
!neural-api/bin/x86_64-linux/bin/SimpleImageClassifier
14. from google.colab import files
!ls -l
15. files.download('SimpleImageClassifier-66.nn')
16. files.download('SimpleImageClassifier-66.csv')
person : 80.40134906768799
integrate image detector compute ends…
Colab with file structure

--

--

Max Kleiner's professional environment is in the areas of OOP, UML and coding - among other things as a trainer, developer and consultant.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Max Kleiner

Max Kleiner

Max Kleiner's professional environment is in the areas of OOP, UML and coding - among other things as a trainer, developer and consultant.