Skip to content

Instantly share code, notes, and snippets.

@oeway
Created November 23, 2020 19:58
Show Gist options
  • Save oeway/3d79e646751a523165c9a4363273f703 to your computer and use it in GitHub Desktop.
Save oeway/3d79e646751a523165c9a4363273f703 to your computer and use it in GitHub Desktop.
from imjoy import api
import pyclesperanto_prototype as cle
from skimage.io import imread, imsave, imshow
import matplotlib
import numpy as np
class ImJoyPlugin():
async def setup(self):
await api.showMessage("initialized, using GPU: " + cle.get_device().name)
async def run(self, ctx):
# load data
image = imread('https://samples.fiji.sc/blobs.png')
await api.showMessage("Loaded image size: " + str(image.shape))
# push image to GPU memory
input_img = cle.push(image)
await api.showMessage("Image size in GPU: " + str(input_img.shape))
viewer = await api.createWindow(src="https://kaibu.org/#/app")
await viewer.view_image(cle.pull(input_img))
api.export(ImJoyPlugin())
<docs lang="markdown">
[TODO: write documentation for this plugin.]
</docs>
<config lang="json">
{
"name": "Pyclesperanto-demo",
"type": "native-python",
"version": "0.1.0",
"description": "[TODO: describe this plugin with one sentence.]",
"tags": [],
"ui": "",
"cover": "",
"inputs": null,
"outputs": null,
"flags": [],
"icon": "extension",
"api_version": "0.1.8",
"env": "",
"permissions": [],
"requirements": ["pip: numpy matplotlib scikit-image imageio pyclesperanto_prototype"],
"dependencies": []
}
</config>
<script lang="python">
from imjoy import api
import pyclesperanto_prototype as cle
from skimage.io import imread, imsave, imshow
import matplotlib
import numpy as np
class ImJoyPlugin():
def setup(self):
api.alert("Used GPU: " + cle.get_device().name)
api.log('initialized')
def run(self, ctx):
api.alert('hello world.')
api.export(ImJoyPlugin())
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment