Skip to content

Commit bbe8a4c

Browse files
committed
ci: add github workflows
1 parent 7a29867 commit bbe8a4c

File tree

4 files changed

+119
-14
lines changed

4 files changed

+119
-14
lines changed

.github/workflows/ci.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build-test-ubuntu:
13+
name: Build & Test on Ubuntu 22.04 (CPU only)
14+
runs-on: ubuntu-22.04
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
with:
20+
submodules: recursive
21+
22+
- name: Install dependencies
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -y cmake g++ ninja-build
26+
27+
- name: Configure and build
28+
run: |
29+
cmake -G Ninja . -B build
30+
cmake --build build --config Release
31+
32+
- name: Run tests
33+
run: ctest build -C Release
34+
35+
build-test-ubuntu-vulkan:
36+
name: Build & Test on Ubuntu 22.04 with Vulkan
37+
runs-on: ubuntu-22.04
38+
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v3
42+
with:
43+
submodules: recursive
44+
45+
- name: Install dependencies
46+
run: |
47+
wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
48+
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
49+
sudo apt-get update -y
50+
sudo apt-get install -y build-essential cmake g++ ninja-build mesa-vulkan-drivers vulkan-sdk
51+
52+
- name: Configure and build with Vulkan
53+
run: |
54+
cmake -G Ninja . -B build -D VISP_VULKAN=ON
55+
cmake --build build --config Release
56+
57+
- name: Run tests
58+
run: ctest build -C Release
59+
60+
build-test-windows:
61+
name: Build & Test on Windows (CPU only)
62+
runs-on: windows-latest
63+
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v3
67+
with:
68+
submodules: recursive
69+
70+
- name: Configure and build
71+
run: |
72+
cmake -G Ninja . -B build
73+
cmake --build build --config Release
74+
75+
- name: Run tests
76+
run: ctest build -C Release
77+
78+
build-test-macos:
79+
name: Build & Test on macOS (CPU only)
80+
runs-on: macos-latest
81+
82+
steps:
83+
- name: Checkout code
84+
uses: actions/checkout@v3
85+
with:
86+
submodules: recursive
87+
88+
- name: Install dependencies
89+
run: brew install cmake ninja
90+
91+
- name: Configure and build
92+
run: |
93+
cmake -G Ninja . -B build
94+
cmake --build build --config Release
95+
96+
- name: Run tests
97+
run: ctest build -C Release

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ See [Building](#building) to build from source. Binaries can be found in `build/
3030
Let's use MobileSAM to generate a segmentation mask for the <object>
3131
at pixel position (320, 240).
3232

33-
You can download the required model from huggingface: [MobileSAM-F16.gguf]().
33+
You can download the required model from huggingface: [MobileSAM-F16.gguf](https://huggingface.co/Acly/MobileSAM-GGUF/resolve/main/MobileSAM-F16.gguf).
3434

3535
#### CLI
3636

@@ -93,14 +93,14 @@ vision-cli esrgan -m models/4x_foolhardy_Remacrih-F16.gguf -i input.png -o outpu
9393

9494
### Converting models
9595

96-
Models need to be converted to GGUF before they can be used. This can also
96+
Models need to be converted to GGUF before they can be used. This will also
9797
rearrange or precompute tensors for more optimal inference.
9898

99-
To convert eg. an ESRGAN model, install [uv](https://docs.astral.sh/uv/) and run:
99+
To convert a model, install [uv](https://docs.astral.sh/uv/) and run:
100100
```sh
101-
uv run scripts/convert.py esrgan 4x_NMKD-Superscale-SP_178000_G.pth -q f16
101+
uv run scripts/convert.py <arch> MyModel.pth -q f16
102102
```
103-
This will create `models/4x_NMKD-Superscale-SP_178000_G-F16.gguf`.
103+
where `<arch>` is one of `sam, birefnet, esrgan, ...`. This will create `models/MyModel-F16.gguf`.
104104

105105
See `convert.py --help` for more options.
106106

@@ -110,7 +110,7 @@ Building requires CMake and a compiler with C++20 support.
110110

111111
**Get the sources**
112112
```sh
113-
git clone --recursive
113+
git clone https://github.com/Acly/vision.cpp.git --recursive
114114
cd vision.cpp
115115
```
116116

@@ -120,16 +120,16 @@ cmake . -B build
120120
cmake --build build --config Release
121121
```
122122

123-
### Vulkan
123+
### _(Optional)_ Vulkan
124124

125125
Vulkan GPU support requires the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) to be installed.
126126

127127
```sh
128-
cmake . -B build -DVISP_VULKAN=ON
128+
cmake . -B build -D VISP_VULKAN=ON
129129
cmake --build build --config Release
130130
```
131131

132-
### Tests
132+
### _(Optional)_ Tests
133133

134134
Run all tests with the following command:
135135
```sh

tests/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target_include_directories(test-vision PRIVATE . ../src)
99
target_compile_options(visioncpp PRIVATE ${VISP_WARNINGS})
1010
target_compile_definitions(visioncpp PRIVATE ${VISP_ASSERT} ${VISP_FMT_DEFS})
1111
target_link_libraries(test-vision PRIVATE visioncpp ${VISP_FMT_LINK})
12-
add_test(NAME vision COMMAND test-vision)
12+
add_test(NAME vision COMMAND test-vision -v)
1313

1414
#
1515
# Model tests (image comparisons)
@@ -23,7 +23,11 @@ target_include_directories(test-models PRIVATE . ../src)
2323
target_compile_options(visioncpp PRIVATE ${VISP_WARNINGS})
2424
target_compile_definitions(visioncpp PRIVATE ${VISP_ASSERT} ${VISP_FMT_DEFS})
2525
target_link_libraries(test-models PRIVATE visioncpp ${VISP_FMT_LINK})
26-
add_test(NAME models COMMAND test-models)
26+
if(VISP_VULKAN)
27+
add_test(NAME models COMMAND test-models -v)
28+
else()
29+
add_test(NAME models COMMAND test-models -v --no-gpu)
30+
endif()
2731

2832
include(reference-images.cmake)
2933

tests/testing.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ int main(int argc, char** argv) {
3939

4040
auto run = [&](test_case const& test, char const* name, backend_type backend) {
4141
try {
42-
printf("%s", name);
43-
fflush(stdout);
42+
if (verbose) {
43+
printf("%s", name);
44+
fflush(stdout);
45+
}
4446

4547
if (test.is_backend_test) {
4648
test.backend_func(backend);
@@ -94,7 +96,9 @@ int main(int argc, char** argv) {
9496
std::chrono::duration_cast<std::chrono::milliseconds>(time_end - time_start).count();
9597

9698
char const* color = (failed > 0 || errors > 0) ? "\033[31m" : "\033[32m";
97-
printf("%s----------------------------------------------------------------------\n", color);
99+
if (verbose || failed > 0 || errors > 0) {
100+
printf("%s----------------------------------------------------------------------\n", color);
101+
}
98102
if (failed > 0) {
99103
printf("\033[31m%d failed, ", failed);
100104
}

0 commit comments

Comments
 (0)