-
Notifications
You must be signed in to change notification settings - Fork 2
Accuracy check YML #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Accuracy check YML #277
Changes from all commits
e1f90af
fe9785a
d76e10d
25c23eb
93bbb72
6d562cf
2929f06
a4d1611
69c19fa
a5838d9
3f9fa39
a8409f1
5c4e528
7b96923
392ea50
6c3b056
2554a45
aab38cc
978481f
7748c55
c561374
4ff9e1d
9dc92bb
df7b5a7
7ff4e1b
5c93127
b0924af
73f3046
20e4039
4e6a9bc
4eb3771
040794f
d75a28d
510e764
aeeb3c6
dab3fdb
2fe1f5a
209921c
b235670
5440df4
2d0c1f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,7 +229,7 @@ jobs: | |
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| slug: embedded-dev-research/ITLabAI | ||
|
|
||
| evaluate-model: | ||
| evaluate-model-alexnet: | ||
| runs-on: ubuntu-latest | ||
| needs: [build-linux] | ||
| permissions: | ||
|
|
@@ -319,3 +319,285 @@ jobs: | |
| git commit -m "[CI] Update accuracy: $(cat accuracy_value.txt)" | ||
| git push origin master | ||
| fi | ||
|
|
||
| evaluate-models-onnx: | ||
| runs-on: ubuntu-latest | ||
| needs: [build-linux] | ||
| permissions: | ||
| contents: write | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| model: [googlenet, densenet, resnet, yolo] | ||
| include: | ||
| - model: googlenet | ||
| parser: parser_onnx.py | ||
| model_file: GoogLeNet.onnx | ||
| model_path: docs/models/GoogLeNet.onnx | ||
| model_url: '' | ||
| extra_args: "--onednn 10000" | ||
| - model: densenet | ||
| parser: parser_onnx.py | ||
| model_file: densenet121_Opset16.onnx | ||
| model_url: https://github.com/onnx/models/raw/refs/heads/main/Computer_Vision/densenet121_Opset16_timm/densenet121_Opset16.onnx?download= | ||
| extra_args: "--onednn 1000" | ||
| - model: resnet | ||
| parser: parser_onnx.py | ||
| model_file: resnest101e_Opset16.onnx | ||
| model_url: https://github.com/onnx/models/raw/refs/heads/main/Computer_Vision/resnest101e_Opset16_timm/resnest101e_Opset16.onnx?download= | ||
| extra_args: "--onednn 1000" | ||
| - model: yolo | ||
| parser: parser_onnx.py | ||
| model_file: yolo11x-cls.pt | ||
| model_url: https://github.com/ultralytics/assets/releases/download/v8.4.0/yolo11x-cls.pt | ||
| extra_args: "--onednn 1000" | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Download binary and libs | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: mnist-RELEASE | ||
| path: build/ | ||
|
|
||
| - name: Set binary path | ||
| id: set_eval_binary | ||
| run: | | ||
| echo "EVAL_BINARY=build/bin/ACC" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Install system dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libgtk-3-0 libtbb12 libjpeg-dev libpng-dev libtiff-dev libopenjp2-7 libdnnl3 | ||
| sudo ldconfig | ||
|
|
||
| - name: Download model (if URL provided) | ||
| if: matrix.model_url != '' | ||
| run: | | ||
| mkdir -p docs/models | ||
| echo "Скачивание ${{ matrix.model_file }} из ${{ matrix.model_url }}" | ||
| wget -O docs/models/${{ matrix.model_file }} ${{ matrix.model_url }} | ||
| ls -la docs/models/ | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.10' | ||
|
|
||
| - name: Install Python dependencies from requirements.txt | ||
| run: | | ||
| cd app/Converters | ||
| pip install -r requirements.txt | ||
| cd ../.. | ||
|
|
||
| - name: Cache model JSON files | ||
| id: cache-model-json | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: docs/jsons | ||
| key: model-json-${{ matrix.model }}-${{ hashFiles('app/Converters/parser_onnx.py', 'app/Converters/requirements.txt') }} | ||
| restore-keys: | | ||
| model-json-${{ matrix.model }}- | ||
| model-json- | ||
|
|
||
| - name: Generate model JSON | ||
| if: steps.cache-model-json.outputs.cache-hit != 'true' | ||
| run: | | ||
| mkdir -p docs/jsons | ||
| cd app/Converters | ||
| python ${{ matrix.parser }} ${{ matrix.model }} | ||
| cd ../.. | ||
|
|
||
| - name: Cache ImageNet-Paste dataset | ||
| id: cache-imagenet-restore | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: docs/ImageNet | ||
| key: imagenet-paste-${{ github.run_id }}-${{ hashFiles('app/Converters/download_imagenet.py') }} | ||
| restore-keys: | | ||
| imagenet-paste- | ||
|
|
||
| - name: Download ImageNet-Paste dataset | ||
| if: steps.cache-imagenet-restore.outputs.cache-hit != 'true' | ||
| env: | ||
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
| run: | | ||
| mkdir -p docs/ImageNet/test | ||
| cd app/Converters | ||
| python download_imagenet.py | ||
| cd ../.. | ||
|
|
||
| - name: Save ImageNet-Paste dataset | ||
| if: steps.cache-imagenet-restore.outputs.cache-hit != 'true' | ||
| uses: actions/cache/save@v4 | ||
| with: | ||
| path: docs/ImageNet | ||
| key: imagenet-paste-v1-${{ hashFiles('app/Converters/download_imagenet.py') }} | ||
|
|
||
| - name: Prepare environment | ||
| run: | | ||
| chmod +x "${{ steps.set_eval_binary.outputs.EVAL_BINARY }}" | ||
| echo "LD_LIBRARY_PATH=$PWD/build/bin/all_libs:/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV | ||
|
|
||
| - name: Increase system limits | ||
| run: | | ||
| sudo prlimit --pid $$ --as=unlimited | ||
| ulimit -s unlimited | ||
| ulimit -c unlimited | ||
| echo "Новые лимиты:" | ||
| ulimit -a | ||
|
|
||
| - name: Run evaluation | ||
| run: | | ||
| DATASET_PATH="docs/ImageNet/test" | ||
| MODEL="${{ matrix.model }}" | ||
| EXTRA_ARGS="${{ matrix.extra_args }}" | ||
|
|
||
| echo "Запуск оценки для модели $MODEL" | ||
| echo "Команда: ${{ steps.set_eval_binary.outputs.EVAL_BINARY }} --model $MODEL $EXTRA_ARGS" | ||
|
|
||
| echo "Системная информация до запуска:" | ||
| echo "--- Память ---" | ||
| free -h | ||
| echo "--- CPU ---" | ||
| top -bn1 | head -5 | ||
| echo "--- Диск ---" | ||
| df -h docs/ImageNet/test/ | ||
|
|
||
| TIMESTAMP=$(date +%s) | ||
| MONITOR_LOG="monitor_$MODEL.log" | ||
|
|
||
| monitor_process() { | ||
| local pid=$1 | ||
| local log_file=$2 | ||
|
|
||
| echo "Мониторинг процесса $pid..." | ||
|
|
||
| while kill -0 $pid 2>/dev/null; do | ||
| NOW=$(date '+%H:%M:%S') | ||
|
|
||
| MEM=$(ps -o rss= -p $pid 2>/dev/null | awk '{print $1/1024 " MB"}' || echo "N/A") | ||
|
|
||
| CPU=$(ps -o pcpu= -p $pid 2>/dev/null || echo "N/A") | ||
|
|
||
| TOTAL_MEM=$(free -m | awk 'NR==2{print $3 " MB / " $2 " MB"}') | ||
|
|
||
| echo "[$NOW] PID: $pid | MEM: $MEM | CPU: $CPU% | System MEM: $TOTAL_MEM" >> $log_file | ||
|
|
||
| sleep 2 | ||
| done | ||
|
|
||
| echo "Процесс $pid завершен" >> $log_file | ||
| } | ||
|
|
||
| echo "Запуск ACC в фоновом режиме..." | ||
| "${{ steps.set_eval_binary.outputs.EVAL_BINARY }}" \ | ||
| --model $MODEL \ | ||
| $EXTRA_ARGS > accuracy_$MODEL.txt 2>&1 & | ||
| ACC_PID=$! | ||
|
|
||
| echo "PID процесса: $ACC_PID" | ||
|
|
||
| monitor_process $ACC_PID $MONITOR_LOG & | ||
| MONITOR_PID=$! | ||
|
|
||
| wait $ACC_PID | ||
| EXIT_CODE=$? | ||
|
|
||
| kill $MONITOR_PID 2>/dev/null || true | ||
|
|
||
| echo "Результаты мониторинга:" | ||
| if [ -f "$MONITOR_LOG" ]; then | ||
| cat "$MONITOR_LOG" | ||
| else | ||
| echo "Лог мониторинга не создан" | ||
| fi | ||
|
|
||
| echo "Системная информация после запуска:" | ||
| free -h | ||
|
|
||
| echo "Код завершения: $EXIT_CODE" | ||
|
|
||
| if [ $EXIT_CODE -eq 143 ]; then | ||
| echo "Ошибка 143 (SIGTERM) - процесс убит системой" | ||
|
|
||
| if sudo dmesg | tail -20 | grep -i "killed process" | grep -q "$ACC_PID"; then | ||
| echo "Подтверждено: процесс убит OOM Killer" | ||
| sudo dmesg | tail -20 | grep -i "killed process" | tail -5 | ||
| else | ||
| echo "Не найдено подтверждение OOM Killer в логах" | ||
| sudo dmesg | tail -20 | ||
| fi | ||
|
|
||
| elif [ $EXIT_CODE -ne 0 ]; then | ||
| echo "Ошибка при оценке модели $MODEL (код: $EXIT_CODE)" | ||
| else | ||
| echo "Оценка успешно завершена" | ||
| fi | ||
|
|
||
| echo "Лог ACC:" | ||
| if [ -f "accuracy_$MODEL.txt" ]; then | ||
| cat "accuracy_$MODEL.txt" | ||
| else | ||
| echo "Файл лога не создан" | ||
| fi | ||
|
|
||
| # Выход с ошибкой если нужно | ||
| if [ $EXIT_CODE -ne 0 ]; then | ||
| exit $EXIT_CODE | ||
| fi | ||
|
|
||
| - name: Extract accuracy value | ||
| run: | | ||
| ACCURACY=$(grep -oE '[0-9]+\.?[0-9]*%' accuracy_${{ matrix.model }}.txt | head -1 || echo "0%") | ||
| echo "$ACCURACY" > accuracy_value_${{ matrix.model }}.txt | ||
| echo "Accuracy for ${{ matrix.model }}: $ACCURACY" | ||
|
|
||
| - name: Upload accuracy artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: accuracy-${{ matrix.model }} | ||
| path: | | ||
| accuracy_${{ matrix.model }}.txt | ||
| accuracy_value_${{ matrix.model }}.txt | ||
|
|
||
| - name: Update README for model (master only) | ||
| if: github.ref == 'refs/heads/master' | ||
| run: | | ||
| TOP1_ACC=$(grep -oE 'Top-1 Accuracy: [0-9]+\.?[0-9]*%' accuracy_${{ matrix.model }}.txt | grep -oE '[0-9]+\.?[0-9]*') | ||
| TOP5_ACC=$(grep -oE 'Top-5 Accuracy: [0-9]+\.?[0-9]*%' accuracy_${{ matrix.model }}.txt | grep -oE '[0-9]+\.?[0-9]*') | ||
| DATE=$(date '+%Y-%m-%d') | ||
|
|
||
| if [ -z "$TOP1_ACC" ] || [ -z "$TOP5_ACC" ]; then | ||
| echo "Ошибка: Не удалось извлечь точность из файла accuracy_${{ matrix.model }}.txt" | ||
| cat accuracy_${{ matrix.model }}.txt | ||
| exit 1 | ||
| fi | ||
|
|
||
| UPDATE_TEXT="<!--ACCURACY_${{ matrix.model }}_PLACEHOLDER-->Accuracy: Top-1: ${TOP1_ACC}% | Top-5: ${TOP5_ACC}% (updated: ${DATE})<!--END_ACCURACY_${{ matrix.model }}-->" | ||
|
|
||
| if grep -q "<!--ACCURACY_${{ matrix.model }}_PLACEHOLDER-->" README.md; then | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we update README in that regard? Since we have more model and only one placeholder as of now
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
| sed -i "s|<!--ACCURACY_${{ matrix.model }}_PLACEHOLDER-->.*<!--END_ACCURACY_${{ matrix.model }}-->|${UPDATE_TEXT}|" README.md | ||
| echo "Обновлена точность для ${{ matrix.model }} в README" | ||
| else | ||
| echo "Ошибка: Плейсхолдер <!--ACCURACY_${{ matrix.model }}_PLACEHOLDER--> не найден в README.md" | ||
| echo "Содержимое README.md:" | ||
| cat README.md | ||
| exit 1 | ||
| fi | ||
|
Comment on lines
+585
to
+590
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better to report an error if we didn't find something
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
|
||
| - name: Commit and push changes (main only) | ||
| if: github.ref == 'refs/heads/main' | ||
| run: | | ||
| git config --global user.name "GitHub Actions" | ||
| git config --global user.email "actions@github.com" | ||
| git add README.md | ||
| if git diff-index --quiet HEAD --; then | ||
| echo "No changes to commit" | ||
| else | ||
| git commit -m "[CI] Update accuracy for ${{ matrix.model }}: $(cat accuracy_value_${{ matrix.model }}.txt)" | ||
| git push origin master | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our main branch is called
mainthis code will not be run whatsoeverThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed