@@ -18,22 +18,11 @@ jobs:
18
18
strategy :
19
19
matrix :
20
20
build_type : [DEBUG, RELEASE]
21
- use_tensorflow : [ON, OFF]
22
21
runs-on : ubuntu-latest
23
22
steps :
24
23
- uses : actions/checkout@v4
25
24
with :
26
25
submodules : true
27
- - name : Download and extract TensorFlow
28
- run : |
29
- wget https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.7.0.tar.gz
30
- tar -xzvf libtensorflow-cpu-linux-x86_64-2.7.0.tar.gz
31
- if : ${{ matrix.use_tensorflow }} == ON
32
- - name : Set TensorFlow environment variables
33
- run : |
34
- echo "export TensorFlow_INCLUDE_DIRS=${PWD}/include" >> $GITHUB_ENV
35
- echo "export TensorFlow_LIBRARIES=${PWD}/lib/libtensorflow.so" >> $GITHUB_ENV
36
- if : ${{ matrix.use_tensorflow }} == ON
37
26
- name : Setup ccache
38
27
uses :
hendrikmuhs/[email protected]
39
28
with :
@@ -45,11 +34,25 @@ jobs:
45
34
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
46
35
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
47
36
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
48
- -DTensorFlow_INCLUDE_DIRS=${{ env.TensorFlow_INCLUDE_DIRS }} \
49
- -DTensorFlow_LIBRARIES=${{ env.TensorFlow_LIBRARIES }}
37
+ -DOPENCV_PATH=3rdparty/opencv/build
50
38
cmake --build build --parallel
51
39
env :
52
40
CTEST_OUTPUT_ON_FAILURE : 1
41
+ - name : Prepare OpenCV libs
42
+ run : |
43
+ mkdir -p build/bin/opencv_libs
44
+ cp -a 3rdparty/opencv/build/lib/libopencv_* build/bin/opencv_libs/
45
+ echo "Library permissions after copy:"
46
+ stat -c "%A %n" build/bin/opencv_libs/libopencv_imgcodecs.so*
47
+
48
+ - name : Upload artifacts
49
+ uses : actions/upload-artifact@v4
50
+ with :
51
+ name : mnist-${{ matrix.build_type }}
52
+ path : |
53
+ build/bin/ACC_MNIST*
54
+ build/bin/opencv_libs/*
55
+ build/setenv.sh
53
56
- name : Test
54
57
run : cmake --build build -t test
55
58
env :
70
73
- name : Install prerequisites
71
74
run : |
72
75
sudo apt install clang libomp-dev
73
- - name : Download and extract TensorFlow
74
- run : |
75
- wget https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.7.0.tar.gz
76
- tar -xzvf libtensorflow-cpu-linux-x86_64-2.7.0.tar.gz
77
- - name : Set TensorFlow environment variables
78
- run : |
79
- echo "TensorFlow_INCLUDE_DIRS=${PWD}/include" >> $GITHUB_ENV
80
- echo "TensorFlow_LIBRARIES=${PWD}/lib/libtensorflow.so" >> $GITHUB_ENV
81
- echo "export TensorFlow_INCLUDE_DIRS=${PWD}/include" >> $GITHUB_ENV
82
- echo "export TensorFlow_LIBRARIES=${PWD}/lib/libtensorflow.so" >> $GITHUB_ENV
83
76
- name : Setup ccache
84
77
uses :
hendrikmuhs/[email protected]
85
78
with :
90
83
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
91
84
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
92
85
-DCMAKE_C_COMPILER=clang \
93
- -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DTensorFlow_INCLUDE_DIRS=${{ env.TensorFlow_INCLUDE_DIRS }} -DTensorFlow_LIBRARIES=${{ env.TensorFlow_LIBRARIES }}
86
+ -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
94
87
cmake --build build --parallel
95
88
- name : Test
96
89
run : cmake --build build -t test
@@ -113,16 +106,6 @@ jobs:
113
106
run : |
114
107
brew install libomp
115
108
brew link libomp --overwrite --force
116
- - name : Download and extract TensorFlow
117
- run : |
118
- curl -O https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-2.7.0.tar.gz
119
- tar -xzvf libtensorflow-cpu-darwin-x86_64-2.7.0.tar.gz
120
- - name : Set TensorFlow environment variables
121
- run : |
122
- echo "TensorFlow_INCLUDE_DIRS=${PWD}/include" >> $GITHUB_ENV
123
- echo "TensorFlow_LIBRARIES=${PWD}/lib/libtensorflow.dylib" >> $GITHUB_ENV
124
- echo "export TensorFlow_INCLUDE_DIRS=${PWD}/include" >> $GITHUB_ENV
125
- echo "export TensorFlow_LIBRARIES=${PWD}/lib/libtensorflow.dylib" >> $GITHUB_ENV
126
109
- name : Setup ccache
127
110
uses :
hendrikmuhs/[email protected]
128
111
with :
@@ -133,7 +116,7 @@ jobs:
133
116
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
134
117
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
135
118
-DCMAKE_C_FLAGS="-I$(brew --prefix libomp)/include" \
136
- -DCMAKE_CXX_FLAGS="-I$(brew --prefix libomp)/include" -DTensorFlow_INCLUDE_DIRS=$TensorFlow_INCLUDE_DIRS -DTensorFlow_LIBRARIES=$TensorFlow_LIBRARIES
119
+ -DCMAKE_CXX_FLAGS="-I$(brew --prefix libomp)/include"
137
120
cmake --build build --parallel
138
121
- name : Test
139
122
run : cmake --build build -t test
@@ -145,10 +128,6 @@ jobs:
145
128
- uses : actions/checkout@v4
146
129
with :
147
130
submodules : true
148
- - name : Download and extract TensorFlow
149
- run : |
150
- curl -O https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.7.0.zip
151
- Expand-Archive -Path libtensorflow-cpu-windows-x86_64-2.7.0.zip -DestinationPath 3rdparty/tensorflow
152
131
- name : Setup ccache
153
132
uses :
hendrikmuhs/[email protected]
154
133
with :
@@ -174,20 +153,6 @@ jobs:
174
153
- uses : actions/checkout@v4
175
154
with :
176
155
submodules : true
177
- - name : Download and extract TensorFlow
178
- run : |
179
- wget https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.7.0.tar.gz
180
- tar -xzvf libtensorflow-cpu-linux-x86_64-2.7.0.tar.gz
181
- - name : Set TensorFlow environment variables
182
- run : |
183
- echo "TensorFlow_INCLUDE_DIRS=${PWD}/include" >> $GITHUB_ENV
184
- echo "TensorFlow_LIBRARIES=${PWD}/lib/libtensorflow.so" >> $GITHUB_ENV
185
- echo "export TensorFlow_INCLUDE_DIRS=${PWD}/include" >> $GITHUB_ENV
186
- echo "export TensorFlow_LIBRARIES=${PWD}/lib/libtensorflow.so" >> $GITHUB_ENV
187
- - name : Display TensorFlow environment variables
188
- run : |
189
- echo "TensorFlow_INCLUDE_DIRS: ${{ env.TensorFlow_INCLUDE_DIRS }}"
190
- echo "TensorFlow_LIBRARIES: ${{ env.TensorFlow_LIBRARIES }}"
191
156
- name : Setup ccache
192
157
uses :
hendrikmuhs/[email protected]
193
158
with :
@@ -201,9 +166,7 @@ jobs:
201
166
-DCMAKE_C_FLAGS="--coverage" \
202
167
-DCMAKE_CXX_FLAGS="--coverage" \
203
168
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
204
- -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
205
- -DTensorFlow_INCLUDE_DIRS=${{ env.TensorFlow_INCLUDE_DIRS }} \
206
- -DTensorFlow_LIBRARIES=${{ env.TensorFlow_LIBRARIES }}
169
+ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
207
170
cmake --build build --parallel
208
171
- name : Test
209
172
run : cmake --build build -t test
@@ -216,3 +179,110 @@ jobs:
216
179
with :
217
180
token : ${{ secrets.CODECOV_TOKEN }}
218
181
slug : embedded-dev-research/itlab_2023
182
+
183
+ evaluate-model :
184
+ runs-on : ubuntu-latest
185
+ needs : [build-linux]
186
+ permissions :
187
+ contents : write
188
+
189
+ steps :
190
+ - uses : actions/checkout@v4
191
+ with :
192
+ fetch-depth : 0
193
+
194
+ - name : Install system dependencies
195
+ run : |
196
+ sudo apt-get update
197
+ sudo apt-get install -y \
198
+ libgtk-3-0 \
199
+ libtbb12 \
200
+ libjpeg-dev \
201
+ libpng-dev \
202
+ libtiff-dev
203
+ sudo ldconfig
204
+ - name : Generate model JSON
205
+ run : |
206
+ cd app/AlexNet
207
+ pip install -r requirements.txt
208
+ python parser.py
209
+ cd ../..
210
+
211
+ - name : Download MNIST test dataset
212
+ run : |
213
+ mkdir -p docs/mnist/mnist/test
214
+ if [ ! -f "docs/mnist/mnist/test/0_000000.png" ]; then
215
+ echo "Downloading test images..."
216
+ wget -q https://github.com/DeepTrackAI/MNIST_dataset/archive/main.zip
217
+ unzip -q main.zip
218
+ cp MNIST_dataset-main/mnist/test/*.png docs/mnist/mnist/test/
219
+ rm -rf main.zip MNIST_dataset-main
220
+ echo "Downloaded $(ls docs/mnist/mnist/test | wc -l) images"
221
+ fi
222
+
223
+ - name : Download binary and libs
224
+ uses : actions/download-artifact@v4
225
+ with :
226
+ name : mnist-RELEASE
227
+ path : build/
228
+
229
+ - name : Prepare environment
230
+ run : |
231
+ chmod +x build/bin/ACC_MNIST*
232
+
233
+ export LD_LIBRARY_PATH=$PWD/build/bin/opencv_libs:/usr/lib/x86_64-linux-gnu
234
+ echo "Final LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
235
+
236
+ - name : Verify library integrity
237
+ run : |
238
+ echo "### Library verification ###"
239
+ file build/bin/opencv_libs/libopencv_imgcodecs.so.4.9.0 | grep "shared object"
240
+ ldd build/bin/opencv_libs/libopencv_imgcodecs.so.4.9.0 || true
241
+ realpath build/bin/opencv_libs/libopencv_imgcodecs.so.409
242
+
243
+ - name : Run evaluation
244
+ run : |
245
+ echo "### Pre-run checks ###"
246
+ export LD_LIBRARY_PATH=$PWD/build/bin/opencv_libs:/usr/lib/x86_64-linux-gnu
247
+ echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
248
+
249
+ LD_DEBUG=files ./build/bin/ACC_MNIST* 2> ld_debug.log || true
250
+ echo "### Library loading debug # ##"
251
+ grep -i "opencv_imgcodecs" ld_debug.log
252
+
253
+ ./build/bin/ACC_MNIST* > accuracy.txt
254
+ echo "Accuracy : $(cat accuracy.txt)"
255
+
256
+ - name : Update README (master only)
257
+ if : github.ref == 'refs/heads/master'
258
+ run : |
259
+ ACCURACY=$(cat accuracy.txt | sed 's/%//g')
260
+ DATE=$(date '+%Y-%m-%d')
261
+
262
+ echo "Updating README with:"
263
+ echo "Accuracy : $ACCURACY"
264
+ echo "Date : $DATE"
265
+
266
+ echo "Current README content:"
267
+ grep -A 2 -B 2 "ACCURACY_PLACEHOLDER" README.md || echo "Placeholder not found"
268
+
269
+ sed -i "s/<!--ACCURACY_PLACEHOLDER-->.*<!--END_ACCURACY-->/<!--ACCURACY_PLACEHOLDER-->Accuracy : ${ACCURACY}% (updated: ${DATE})<!--END_ACCURACY-->/" README.md
270
+
271
+ echo "Updated README content:"
272
+ grep -A 2 -B 2 "ACCURACY_PLACEHOLDER" README.md
273
+
274
+ - name : Commit and push changes (master only)
275
+ if : github.ref == 'refs/heads/master'
276
+ run : |
277
+ git config --global user.name "GitHub Actions"
278
+ git config --global user.email "[email protected] "
279
+
280
+ git add README.md
281
+
282
+ if git diff-index --quiet HEAD --; then
283
+ echo "No changes to commit"
284
+ else
285
+ git commit -m "[CI] Update accuracy : $(cat accuracy.txt)%"
286
+ git push origin master
287
+ echo "Changes pushed to master branch"
288
+ fi
0 commit comments