Cellpose test (win)
準備
Sample code
code:jupyter notebook
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from cellpose import models, io, plot, core
from cellpose.io import imread
import torch
code:jupyter notebook
fname = 'Merge.tif'
imgs = io.imread(fname)
for img in imgs:
plt.figure(figsize=(2,2))
plt.imshow(img)
plt.axis('off')
plt.show()
code:jupyter notebook
## GPU使えるか確認
use_GPU = core.use_gpu()
print('>>> GPU activated? %d'%use_GPU)
code:jupyter notebook
%%time
## CPUで実行
model = models.Cellpose(gpu=False, model_type="cyto3")
masks,flows = [],[]
for i,img in enumerate(imgs):
mask, flow, style, diam = model.eval(img, diameter=30,channels=chan)
masks.append(mask)
flows.append(flow)
io.save_to_png(img, mask, flow, 'mask/'+str(i)+'.png')
code:jupyter notebook
%%time
## GPUで実行
model = models.Cellpose(gpu=use_GPU, model_type='cyto3')
masks,flows = [],[]
for i,img in enumerate(imgs):
mask, flow, style, diam = model.eval(img, diameter=30,channels=chan)
masks.append(mask)
flows.append(flow)
io.save_to_png(img, mask, flow, 'mask/'+str(i)+'.png')
code:jupyter notebook
## 計算結果を確認
for img, mask,flow in zip(imgs,masks,flows):
fig = plt.figure(figsize=(12,5))
plot.show_segmentation(fig, img, mask, flow0, channels=chan) plt.tight_layout()
plt.show()
Apple Silicon Macの場合
Privateから転載
cellPose使い方
Web serverでの使い方
JPEGとかの画像をアップロードするだけ。お試し。
Jupyter notebookでの使い方
Anacondaが入っていたら、Prompt上で
pip install cellpose
G suite 共有ドライブ> Lab Protocol> Programming> jupyter notebook archivesにサンプルを入れています
Google colabでGPUを使ってみた。結構速い
Remarks
created by y-goto.icon
2024.07.01