#!/usr/bin/env python # coding: utf-8 # In[1]: from cucim import CuImage from cucim.clara.cache import calc_preferred_cache_memory img = CuImage("notebooks/input/image.tif") memory_capacity = calc_preferred_cache_memory(img, (256, 256)) CuImage.cache("per_process", memory_capacity=memory_capacity, record_stat=True) #CuImage.cache("per_process", memory_capacity=2048, record_stat=True) region = img.read_region((0,0), (100,100)) cache = CuImage.cache() # In[2]: cache.config # In[3]: print(f"cache hit: {cache.hit_count}, chche miss: {cache.miss_count}") # In[4]: region = img.read_region((0,0), (100,100)) print(f"cache hit: {cache.hit_count}, chche miss: {cache.miss_count}") print(f"items in cache: {cache.size}/{cache.capacity}, memory usage in cache: {cache.memory_size}/{cache.memory_capacity}") # In[1]: from cucim import CuImage img = CuImage("notebooks/input/image.tif") # In[3]: dir(img._C) # In[1]: from cucim import CuImage img = CuImage("notebooks/input/image.tif") # In[5]: get_ipython().run_cell_magic('timeit', '', '\nimg.is_loaded\n') # In[6]: get_ipython().run_cell_magic('timeit', '', 'img._C.is_loaded\n') # In[14]: get_ipython().system('pip install --force-reinstall dist/*.whl') dir(img) # In[3]: get_ipython().run_cell_magic('timeit', '', '\nimg.is_loaded\n') # In[9]: help(img.read_region) # In[6]: from cucim import CuImage img = CuImage("notebooks/input/image.tif") region = img.read_region((1000,1000), (100, 100)) # In[7]: from PIL import Image import numpy as np Image.fromarray(np.asarray(region)) # In[8]: import cupy as cp region_cupy = img.read_region((1000,1000), (100, 100), device='cuda') vis = cp.asarray(region_cupy) # In[15]: Image.fromarray(vis.get()) # In[16]: del vis # In[12]: b.__array_interface__ # In[13]: get_ipython().system('pip install cupy-cuda112')