Skip to content

Commit f7b961d

Browse files
committed
rename pie to fpie
1 parent b4b526a commit f7b961d

39 files changed

+147
-146
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ jobs:
2929
run: |
3030
cd tests
3131
python3 data.py benchmark
32-
pie --check-backend
33-
pie -s circle6.png -t circle6.png -m circle6.png -o result.png -n 5000
32+
fpie --check-backend
33+
fpie -s circle6.png -t circle6.png -m circle6.png -o result.png -n 5000

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.4)
22

3-
project(pie_core)
3+
project(fpie_core)
44

55
if(NOT CMAKE_BUILD_TYPE)
66
set(CMAKE_BUILD_TYPE Release)
@@ -23,21 +23,21 @@ endif()
2323

2424
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pybind11)
2525

26-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/pybind11/include pie/core)
26+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/pybind11/include fpie/core)
2727

28-
add_subdirectory(pie/core/gcc)
28+
add_subdirectory(fpie/core/gcc)
2929

3030
find_package(OpenMP)
3131
if(OpenMP_FOUND)
32-
add_subdirectory(pie/core/openmp)
32+
add_subdirectory(fpie/core/openmp)
3333
endif()
3434

3535
find_package(MPI)
3636
if(MPI_FOUND)
37-
add_subdirectory(pie/core/mpi)
37+
add_subdirectory(fpie/core/mpi)
3838
endif()
3939

4040
find_package(CUDA)
4141
if(CUDA_FOUND)
42-
add_subdirectory(pie/core/cuda)
42+
add_subdirectory(fpie/core/cuda)
4343
endif()

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include CMakeLists.txt
22
include cmake_modules/*.cmake
3-
recursive-include pie CMakeLists.txt *.h *.cc *.cu
3+
recursive-include fpie CMakeLists.txt *.h *.cc *.cu

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
SHELL = /bin/bash
2-
PROJECT_NAME = pie
3-
PYTHON_FILES = $(shell find setup.py pie tests -type f -name "*.py")
4-
CPP_FILES = $(shell find pie -type f -name "*.h" -o -name "*.cc" -o -name "*.cu")
5-
CMAKE_FILES = $(shell find pie -type f -name "CMakeLists.txt") $(shell find cmake_modules -type f) CMakeLists.txt
2+
PROJECT_NAME = fpie
3+
PYTHON_FILES = $(shell find setup.py fpie tests -type f -name "*.py")
4+
CPP_FILES = $(shell find fpie -type f -name "*.h" -o -name "*.cc" -o -name "*.cu")
5+
CMAKE_FILES = $(shell find fpie -type f -name "CMakeLists.txt") $(shell find cmake_modules -type f) CMakeLists.txt
66
COMMIT_HASH = $(shell git log -1 --format=%h)
77

88
# installation

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Poisson Image Editing - A Parallel Implementation
22

3-
[![PyPI](https://img.shields.io/pypi/v/pie)](https://pypi.org/project/pie/)
4-
[![Unittest](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/workflows/Unittest/badge.svg?branch=master)](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/actions)
3+
[![PyPI](https://img.shields.io/pypi/v/fpie)](https://pypi.org/project/fpie/)
4+
[![Unittest](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/workflows/Test/badge.svg?branch=main)](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/actions)
55

66
> Jiayi Weng (jiayiwen), Zixu Chen (zixuc)
77
@@ -17,6 +17,9 @@ This project aims to provide a fast poisson image editing algorithm (based on [J
1717
# install cmake >= 3.4
1818
# if you don't have sudo (like GHC), install cmake from source
1919
# on macOS, type `brew install cmake`
20+
$ pip install fpie
21+
22+
# or install from source
2023
$ pip install .
2124
```
2225

@@ -34,7 +37,7 @@ $ pip install .
3437
After installation, you can use `--check-backend` option to verify:
3538

3639
```bash
37-
$ pie --check-backend
40+
$ fpie --check-backend
3841
['numpy', 'taichi-cpu', 'taichi-gpu', 'taichi-cuda', 'gcc', 'openmp', 'mpi', 'cuda']
3942
```
4043

@@ -51,14 +54,14 @@ $ cd tests && ./data.py
5154
This script will download 8 tests from GitHub, and create 10 images for benchmarking (5 circle, 5 square). To run:
5255

5356
```bash
54-
$ pie -s test1_src.jpg -m test1_mask.jpg -t test1_tgt.jpg -o result1.jpg -h1 -150 -w1 -50 -n 5000 -g max
55-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result2.jpg -h1 130 -w1 130 -n 5000 -g src
56-
$ pie -s test3_src.jpg -m test3_mask.jpg -t test3_tgt.jpg -o result3.jpg -h1 100 -w1 100 -n 5000 -g max
57-
$ pie -s test4_src.jpg -m test4_mask.jpg -t test4_tgt.jpg -o result4.jpg -h1 100 -w1 100 -n 5000 -g max
58-
$ pie -s test5_src.jpg -m test5_mask.png -t test5_tgt.jpg -o result5.jpg -h0 -70 -w0 0 -h1 50 -w1 0 -n 5000 -g max
59-
$ pie -s test6_src.png -m test6_mask.png -t test6_tgt.png -o result6.jpg -h1 50 -w1 0 -n 5000 -g max
60-
$ pie -s test7_src.jpg -t test7_tgt.jpg -o result7.jpg -h1 50 -w1 30 -n 5000 -g max
61-
$ pie -s test8_src.jpg -t test8_tgt.jpg -o result8.jpg -h1 90 -w1 90 -n 10000 -g max
57+
$ fpie -s test1_src.jpg -m test1_mask.jpg -t test1_tgt.jpg -o result1.jpg -h1 -150 -w1 -50 -n 5000 -g max
58+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result2.jpg -h1 130 -w1 130 -n 5000 -g src
59+
$ fpie -s test3_src.jpg -m test3_mask.jpg -t test3_tgt.jpg -o result3.jpg -h1 100 -w1 100 -n 5000 -g max
60+
$ fpie -s test4_src.jpg -m test4_mask.jpg -t test4_tgt.jpg -o result4.jpg -h1 100 -w1 100 -n 5000 -g max
61+
$ fpie -s test5_src.jpg -m test5_mask.png -t test5_tgt.jpg -o result5.jpg -h0 -70 -w0 0 -h1 50 -w1 0 -n 5000 -g max
62+
$ fpie -s test6_src.png -m test6_mask.png -t test6_tgt.png -o result6.jpg -h1 50 -w1 0 -n 5000 -g max
63+
$ fpie -s test7_src.jpg -t test7_tgt.jpg -o result7.jpg -h1 50 -w1 30 -n 5000 -g max
64+
$ fpie -s test8_src.jpg -t test8_tgt.jpg -o result8.jpg -h1 90 -w1 90 -n 10000 -g max
6265
```
6366

6467
Here are the results:
@@ -80,7 +83,7 @@ We have provided 6 backends. Each backend has two solvers: EquSolver and GridSol
8083

8184
For different backend usage, please check out the related documentation under [docs/backend](/docs/backend).
8285

83-
For other usage, please run `pie -h` to see the hint.
86+
For other usage, please run `fpie -h` to see the hint.
8487

8588
## Benchmark Result
8689

docs/backend/README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
To specify backend, simply typing `-b cuda` or `--backend openmp`, together with other parameters described below.
44

5-
Feel free to play `pie` with other arguments!
5+
Feel free to play `fpie` with other arguments!
66

77
## GridSolver
88

@@ -32,7 +32,7 @@ This backend uses NumPy vectorized operation for parallel computation.
3232
There's no extra parameter for NumPy EquSolver:
3333

3434
```bash
35-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b numpy --method equ
35+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b numpy --method equ
3636
Successfully initialize PIE equ solver with numpy backend
3737
# of vars: 12559
3838
Iter 5000, abs error [450.09415 445.24747 636.1397 ]
@@ -43,7 +43,7 @@ Successfully write image to result.jpg
4343
There's no extra parameter for NumPy GridSolver:
4444

4545
```bash
46-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b numpy --method grid
46+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b numpy --method grid
4747
Successfully initialize PIE grid solver with numpy backend
4848
# of vars: 17227
4949
Iter 5000, abs error [450.07922 445.27014 636.1374 ]
@@ -60,7 +60,7 @@ This backend uses a single thread C++ program to perform computation.
6060
There's no extra parameter for GCC EquSolver:
6161

6262
```bash
63-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b gcc --method equ
63+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b gcc --method equ
6464
Successfully initialize PIE equ solver with gcc backend
6565
# of vars: 12559
6666
Iter 5000, abs error [ 5.179281 6.6939087 11.006622 ]
@@ -71,7 +71,7 @@ Successfully write image to result.jpg
7171
For GCC GridSolver, you need to specify `--grid-x` and `--grid-y` described in the first section:
7272

7373
```bash
74-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b gcc --method grid --grid-x 8 --grid-y 8
74+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b gcc --method grid --grid-x 8 --grid-y 8
7575
Successfully initialize PIE grid solver with gcc backend
7676
# of vars: 17227
7777
Iter 5000, abs error [ 5.1776047 6.69458 11.001862 ]
@@ -92,7 +92,7 @@ There's no other parameters for Taichi EquSolver:
9292

9393
```bash
9494
# taichi-cpu
95-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b taichi-cpu --method equ -c 6
95+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b taichi-cpu --method equ -c 6
9696
[Taichi] version 0.9.2, llvm 10.0.0, commit 7a4d73cd, linux, python 3.8.10
9797
[Taichi] Starting on arch=x64
9898
Successfully initialize PIE equ solver with taichi-cpu backend
@@ -104,7 +104,7 @@ Successfully write image to result.jpg
104104

105105
```bash
106106
# taichi-gpu
107-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b taichi-gpu --method equ -z 1024
107+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b taichi-gpu --method equ -z 1024
108108
[Taichi] version 0.9.2, llvm 10.0.0, commit 7a4d73cd, linux, python 3.8.10
109109
[Taichi] Starting on arch=cuda
110110
Successfully initialize PIE equ solver with taichi-gpu backend
@@ -118,7 +118,7 @@ For Taichi GridSolver, you also need to specify `--grid-x` and `--grid-y` descri
118118

119119
```bash
120120
# taichi-cpu
121-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b taichi-cpu --method grid --grid-x 16 --grid-y 16 -c 12
121+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b taichi-cpu --method grid --grid-x 16 --grid-y 16 -c 12
122122
[Taichi] version 0.9.2, llvm 10.0.0, commit 7a4d73cd, linux, python 3.8.10
123123
[Taichi] Starting on arch=x64
124124
Successfully initialize PIE grid solver with taichi-cpu backend
@@ -130,7 +130,7 @@ Successfully write image to result.jpg
130130

131131
```bash
132132
# taichi-gpu
133-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b taichi-gpu --method grid --grid-x 8 --grid-y 8 -z 64
133+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b taichi-gpu --method grid --grid-x 8 --grid-y 8 -z 64
134134
[Taichi] version 0.9.2, llvm 10.0.0, commit 7a4d73cd, linux, python 3.8.10
135135
[Taichi] Starting on arch=cuda
136136
Successfully initialize PIE grid solver with taichi-gpu backend
@@ -147,7 +147,7 @@ OpenMP backend needs to specify the number of CPU cores it can use, with `-c` or
147147
There's no other parameters for OpenMP EquSolver:
148148

149149
```bash
150-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b openmp --method equ -c 6
150+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b openmp --method equ -c 6
151151
Successfully initialize PIE equ solver with openmp backend
152152
# of vars: 12559
153153
Iter 5000, abs error [ 5.2758713 6.768402 11.11969 ]
@@ -158,7 +158,7 @@ Successfully write image to result.jpg
158158
For OpenMP GridSolver, you also need to specify `--grid-x` and `--grid-y` described in the first section:
159159

160160
```bash
161-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b openmp --method grid --grid-x 8 --grid-y 8 -c 6
161+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b openmp --method grid --grid-x 8 --grid-y 8 -c 6
162162
Successfully initialize PIE grid solver with openmp backend
163163
# of vars: 17227
164164
Iter 5000, abs error [ 5.187172 6.701462 11.020264]
@@ -168,22 +168,22 @@ Successfully write image to result.jpg
168168

169169
### Parallelization Strategy
170170

171-
For [EquSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/pie/core/openmp/equ.cc), it first groups the pixels into two folds by `(i+j)%2`, then parallelizes per-pixel iteration inside a group in each step. This strategy can utilize the thread-local accessment.
171+
For [EquSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/fpie/core/openmp/equ.cc), it first groups the pixels into two folds by `(i+j)%2`, then parallelizes per-pixel iteration inside a group in each step. This strategy can utilize the thread-local accessment.
172172

173-
For [GridSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/pie/core/openmp/grid.cc), it parallelizes per-grid iteration in each step, where the grid size is `(grid_x, grid_y)`. It simply iterates all pixels in each grid.
173+
For [GridSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/fpie/core/openmp/grid.cc), it parallelizes per-grid iteration in each step, where the grid size is `(grid_x, grid_y)`. It simply iterates all pixels in each grid.
174174

175175
## MPI
176176

177177
To run with MPI backend, you need to install both mpicc and mpi4py (`pip install mpi4py`).
178178

179-
Different from other methods, you need to use `mpiexec` or `mpirun` to launch MPI service instead of directly calling `pie` program. `-np` option is to indicate the number of process it will launch.
179+
Different from other methods, you need to use `mpiexec` or `mpirun` to launch MPI service instead of directly calling `fpie` program. `-np` option is to indicate the number of process it will launch.
180180

181181
Apart from that, you need to specify the synchronization interval for MPI backend with `--mpi-sync-interval`. If this number is too small, it will cause a large amount of overhead of synchronization; however, if it is too large, the quality of solution drops down dramatically.
182182

183183
MPI EquSolver and GridSolver don't have any other arguments because of the parallelization strategy we used, see the next section.
184184

185185
```bash
186-
$ mpiexec -np 6 pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b mpi --method equ --mpi-sync-interval 100
186+
$ mpiexec -np 6 fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b mpi --method equ --mpi-sync-interval 100
187187
Successfully initialize PIE equ solver with mpi backend
188188
# of vars: 12559
189189
Iter 5000, abs error [264.6767 269.55304 368.4869 ]
@@ -192,7 +192,7 @@ Successfully write image to result.jpg
192192
```
193193

194194
```bash
195-
$ mpiexec -np 6 pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b mpi --method grid --mpi-sync-interval 100
195+
$ mpiexec -np 6 fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b mpi --method grid --mpi-sync-interval 100
196196
Successfully initialize PIE grid solver with mpi backend
197197
# of vars: 17227
198198
Iter 5000, abs error [204.41124 215.00548 296.4441 ]
@@ -204,9 +204,9 @@ Successfully write image to result.jpg
204204

205205
MPI cannot use share-memory program model, so that we need to reduce the amount of data for communication. Each process is only responsible for a part of computation, and synchronized with other process per `mpi_sync_interval` steps.
206206

207-
For [EquSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/pie/core/mpi/equ.cc), it's hard to say which part of the data should be exchanged to other process, since it relabels all pixels at the very beginning of this process. We use `MPI_Bcast` to force sync all data.
207+
For [EquSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/fpie/core/mpi/equ.cc), it's hard to say which part of the data should be exchanged to other process, since it relabels all pixels at the very beginning of this process. We use `MPI_Bcast` to force sync all data.
208208

209-
For [GridSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/pie/core/mpi/grid.cc), we use line partition: process `i` exchanges its first and last line data with process `i-1` and `i+1` separately. This strategy has a continuous memory layout to exchange, thus has less overhead comparing with block partition.
209+
For [GridSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/fpie/core/mpi/grid.cc), we use line partition: process `i` exchanges its first and last line data with process `i-1` and `i+1` separately. This strategy has a continuous memory layout to exchange, thus has less overhead comparing with block partition.
210210

211211
However, even if we don't use the synchronization in MPI (set `mpi_sync_interval` to be greater than the number of iteration), it is still slower than OpenMP and CUDA backends.
212212

@@ -217,7 +217,7 @@ CUDA backend needs to specify the number of threads in one block it will use, wi
217217
There's no other parameters for CUDA EquSolver:
218218

219219
```bash
220-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b cuda --method equ -z 256
220+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b cuda --method equ -z 256
221221
---------------------------------------------------------
222222
Found 1 CUDA devices
223223
Device 0: NVIDIA GeForce GTX 1060
@@ -235,7 +235,7 @@ Successfully write image to result.jpg
235235
For CUDA GridSolver, you also need to specify `--grid-x` and `--grid-y` described in the first section:
236236

237237
```bash
238-
$ pie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b cuda --method grid --grid-x 4 --grid-y 128 -z 1024
238+
$ fpie -s test2_src.png -m test2_mask.png -t test2_tgt.png -o result.jpg -h1 130 -w1 130 -n 5000 -g src -b cuda --method grid --grid-x 4 --grid-y 128 -z 1024
239239
---------------------------------------------------------
240240
Found 1 CUDA devices
241241
Device 0: NVIDIA GeForce GTX 1060
@@ -254,6 +254,6 @@ Successfully write image to result.jpg
254254

255255
The strategy used in CUDA backend is quite similar to OpenMP.
256256

257-
For [EquSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/pie/core/cuda/equ.cu), it performs equation-level parallelization.
257+
For [EquSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/fpie/core/cuda/equ.cu), it performs equation-level parallelization.
258258

259-
For [GridSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/pie/core/cuda/grid.cu), each grid with size `(grid_x, grid_y)` will be in the same block. A thread in a block performs iteration only for a single pixel.
259+
For [GridSolver](https://github.com/Trinkle23897/Fast-Poisson-Image-Editing/blob/main/fpie/core/cuda/grid.cu), each grid with size `(grid_x, grid_y)` will be in the same block. A thread in a block performs iteration only for a single pixel.

0 commit comments

Comments
 (0)