Skip to content

Commit

Permalink
Merge branch 'topic/default/add-sample-wake_legi' into 'branch/default'
Browse files Browse the repository at this point in the history
Performance optimizations for PIV

See merge request fluiddyn/fluidimage!94
  • Loading branch information
paugier committed Apr 17, 2024
2 parents 12571bb + 5c8740c commit d03e43f
Show file tree
Hide file tree
Showing 14 changed files with 646 additions and 360 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
See also the
[unreleased changes](https://foss.heptapod.net/fluiddyn/fluidimage/-/compare/0.4.3...branch%2Fdefault).

## [0.4.5] (2024-04-17)

- Performance optimizations for PIV (- ~40% of CPU time without TPS)

## [0.4.4] (2024-04-16)

- `fluidimage-monitor` [Textual](https://textual.textualize.io/) app to monitor
Expand Down
63 changes: 63 additions & 0 deletions doc/examples/profile_piv_work.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Profile PIV work with pyinstrument
Result with fluidimage 0.4.4:
total: ~4.7 s
- ~25% _compute_indices_max, fluidimage/calcul/correl.py:78
- ~25% CorrelFFTW.__call__, fluidimage/calcul/correl.py:690 (10.4% fftshift, ~1% fft)
- ~10% WorkPIVFromDisplacement._crop_im0 (and 1) fluidimage/works/piv/singlepass.py:403
- ~17% smooth_clean fluidimage/calcul/smooth_clean.py:25 (9% griddata)
"""

import os

from pyinstrument import Profiler
from pyinstrument.renderers import ConsoleRenderer

from fluidimage.piv import Work

os.environ["OMP_NUM_THREADS"] = "1"

params = Work.create_default_params()

params.series.path = "../../image_samples/wake_legi/images/B*.png"

params.piv0.shape_crop_im0 = 40
params.piv0.displacement_max = 14

params.piv0.nb_peaks_to_search = 2
params.piv0.particle_radius = 3

params.mask.strcrop = ":, :1500"

params.multipass.number = 2

params.multipass.use_tps = "last"
# params.multipass.use_tps = False
params.multipass.subdom_size = 200
params.multipass.smoothing_coef = 10.0
params.multipass.threshold_tps = 0.5

params.fix.correl_min = 0.15
params.fix.threshold_diff_neighbour = 3

work = Work(params=params)

profiler = Profiler()
profiler.start()
piv = work.process_1_serie()
profiler.stop()

print(
profiler.output(
renderer=ConsoleRenderer(
unicode=True,
color=True,
show_all=False,
# time="percent_of_total",
# flat=True, # buggy with pyinstrument 4.6.2!
)
)
)
1 change: 1 addition & 0 deletions doc/examples/test_run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def teardown_module(module):
"surface_tracking.py",
"preproc_sback1_filter.py",
"preproc_sback2_rescale.py",
"profile_piv_work.py",
]
)

Expand Down
Binary file added image_samples/wake_legi/images/B00001A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_samples/wake_legi/images/B00001B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
180 changes: 115 additions & 65 deletions pdm.lock

Large diffs are not rendered by default.

198 changes: 198 additions & 0 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ pythran = ">=0.15.0"
pytest = ">=8.0.0"
pytest-cov = ">=4.1.0"
coverage = ">=7.4.1"
pytest-asyncio = ">=0.23.6,<0.24"
linkify-it-py = ">=2.0.3,<2.1"
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = 'mesonpy'

[project]
name = "fluidimage"
version = "0.4.4"
version = "0.4.5"
description = "Fluid image processing with Python."
authors = [
{name = "Pierre Augier", email = "[email protected]"},
Expand Down Expand Up @@ -64,7 +64,7 @@ pims = ["pims"]
opencv = ["opencv-python"]
graph = ["gprof2dot"]
pytest = ["pytest", "pytest-asyncio"]
all = ["fluidimage[pims, opencv-python, gprof2dot, pytest]"]
all = ["fluidimage[pims, opencv, graph, pytest]"]
# qt = ["PySide6"]

[project.entry-points."fluidimage.executors"]
Expand Down Expand Up @@ -124,6 +124,7 @@ dev = [
"isort",
"ipdb>=0.13.13",
"textual-dev",
"pyinstrument",
]

[tool.pdm.scripts]
Expand Down
5 changes: 0 additions & 5 deletions src/fluidimage/calcul/_evaluate_subpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
except ImportError:
classes.pop("skcufft")

try:
import theano
except ImportError:
classes.pop("theano")


def setUpImages(nx, ny, dx, dy, part_size):
displacements = np.array([dx, dy])
Expand Down
Loading

0 comments on commit d03e43f

Please sign in to comment.