Skip to content

Commit

Permalink
Merge pull request #216 from clEsperanto/prep-0.12.0
Browse files Browse the repository at this point in the history
Prep 0.12.0
  • Loading branch information
StRigaud authored Aug 22, 2024
2 parents 9f03bee + a7ac46a commit dba1b82
Show file tree
Hide file tree
Showing 22 changed files with 1,788 additions and 2,459 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ option(BUILD_SHARED_LIBS OFF)


## CLIc dependency
set(CLIC_REPO_TAG 0.11.1) # branch name for dev
set(CLIC_REPO_TAG 0.12.0) # branch name for dev
set(CLIC_REPO_URL https://github.com/clEsperanto/CLIc.git)
set(BUILD_OPENCL_BACKEND ON CACHE BOOL "Build with OCL if FOUND" FORCE)
set(BUILD_CUDA_BACKEND ON CACHE BOOL "Build with CUDA if FOUND" FORCE)
Expand Down
113 changes: 113 additions & 0 deletions demos/interoperability/napari.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "50b170a2-98e2-4257-b5af-9e008a264a83",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(OpenCL) NVIDIA GeForce RTX 4090 (OpenCL 3.0 CUDA)\n",
"\tVendor: NVIDIA Corporation\n",
"\tDriver Version: 535.183.06\n",
"\tDevice Type: GPU\n",
"\tCompute Units: 128\n",
"\tGlobal Memory Size: 24217 MB\n",
"\tMaximum Object Size: 6054 MB\n",
"\tMax Clock Frequency: 2625 MHz\n",
"\tImage Support: Yes"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import napari\n",
"import numpy as np\n",
"import pyclesperanto as cle\n",
"\n",
"cle.select_device()"
]
},
{
"cell_type": "markdown",
"id": "8df18a3d",
"metadata": {},
"source": [
"Let's create a numpy array and process it with clesperanto, in this case applying a gaussian blur"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c5791a69",
"metadata": {},
"outputs": [],
"source": [
"img = np.random.randint(0, 65536, size=(1024, 1024), dtype=np.uint16)\n",
"blurred = cle.gaussian_blur(img, sigma_x=2, sigma_y=2)"
]
},
{
"cell_type": "markdown",
"id": "4517fe36",
"metadata": {},
"source": [
"Both images can be seemlessly added to the napari viewer. In the background, clesperanto implement internal method which allows napari to call back the data from the GPU to the host memory. Hence for napari, a clesperanto array is treated the same as a numpy array."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "14da0d8e",
"metadata": {},
"outputs": [],
"source": [
"\n",
"viewer = napari.Viewer()\n",
"viewer.add_image(img)\n",
"viewer.add_image(blurred)\n",
"napari.run()"
]
},
{
"cell_type": "markdown",
"id": "d9006505",
"metadata": {},
"source": [
"Enjoy!"
]
},
{
"cell_type": "markdown",
"id": "5fd04493",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.19"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit dba1b82

Please sign in to comment.