程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何修复:TypeError:通过 python 使用 cellpose 时,“list”对象没有属性“shape”大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决如何修复:TypeError:通过 python 使用 cellpose 时,“list”对象没有属性“shape”?

开发过程中遇到如何修复:TypeError:通过 python 使用 cellpose 时,“list”对象没有属性“shape”的问题如何解决?下面主要结合日常开发的经验,给出你关于如何修复:TypeError:通过 python 使用 cellpose 时,“list”对象没有属性“shape”的解决方法建议,希望对你解决如何修复:TypeError:通过 python 使用 cellpose 时,“list”对象没有属性“shape”有所启发或帮助;

在 cellpose 中,我的图形显示为空白,没有做任何掩码或分割,它返回此类型错误:“列表”对象没有属性“形状”。我想知道是否有人可以帮我弄清楚如何制作它以便程序识别该功能并显示图像?

它标记的包含类型错误消息的代码是:

TypeError TraceBACk (most recent call last)
    in ()
    ----> 1 plot.show_segmentation (fig,imgs[IDx],maski,flowi,chAnnels=chAnnels[IDx])
1 frames
    /usr/local/lib/python3.7/dist-packages/cellpose/plot.py in image_to_rgb(img0,chAnnels)
    169 if img.shape[0]<5:
    170 img = np.transpose(img,(1,2,0))
    --> 171 if chAnnels[0]==0:
    172 img = img.mean(axis=-1)[:,:,np.newaxis]
    173 for i in range(img.shape[-1]):

这是它在没有错误消息的情况下标记的实际代码:

fig = plt.figure(figsize=(12,5))
plot.show_segmentation(fig,imgs,chAnnels=chAnnels)
plt.tight_layout()
plt.show()

这也是一张带有空白图像的屏幕截图 This is the blank image This is the snapshot of my error code This is what I want my image to look like when the code is complete

我试过用print()和type()函数检查,我试过转换为整数,我试过导入np.array,但不知道在我的代码中分配它的位置,等等。没有其中正在发挥作用。如果有人可以帮我弄清楚如何让它通过python识别纤维素中的功能,将不胜感激!非常感谢您的任何帮助,我非常感谢!

温暖的祝福和非常感谢!

作为完整参,这里是我正在使用的完整代码,这也是 cellpose 网站供参https://colab.research.google.com/github/MouseLand/cellpose/blob/master/notebooks/run_cellpose_GPU.ipynb#scrollTo=8P5voZOVM-H9

代码开始'''

!nvcc --version
!nvIDia-smi
!pip install cellpose
import numpy as np
import time,os,sys
from urllib.parse import urlparse
import skimage.io
import matplotlib.pyplot as plt
import matplotlib as mpl
%matplotlib inline
mpl.rcParams['figure.dpi'] = 300

from urllib.parse import urlparse
from cellpose import models

use_GPU = modelS.Use_gpu()
print('>>> GPU activated? %d'%use_GPU)

from IPython.display import Image
Image('WellA01_ChAnnelBrightfIEld_Seq0000.png')
files = ['WellA01_ChAnnelBrightfIEld_Seq0000.png']
import skimage.io 
imgs = [skimage.io.imread('WellA01_ChAnnelBrightfIEld_Seq0000.png')]
nimg = len(imgs)

plt.figure(figsize=(8,4))
for k,img in enumerate(imgs[:-1]):
  plt.subplot(1,3,k+1)
  plt.imshow(img)
from cellpose import models
import skimage.io



imgs_2D = imgs

from cellpose import models
model = models.Cellpose(gpu=True,model_type='cyto')

# define CHAnnELS to run segementation on
#grayscale=0,R=1,G=2,B=3
chAnnels = ['cytoplasm','nucleus']
# IF ALL YOUR IMAGES ARE THE SAME TYPE,you can give a List with 2 elements
chAnnels = [0,0] 

# if Diameter is set to None,the size of the cells is estimated on a per image basis
# you can set the average cell `diameter` in pixels yourself (recommended) 
# diameter can be a List or a single number for all images

masks,flows,styles,diams = model.eval(imgs,diameter=None,chAnnels=[0,0],flow_threshold=None,do_3D=falsE)
import numpy as np
# disPLAY RESulTS
from cellpose import plot

nimg = len(imgs_2D)
for IDx in range(nimg):
    maski = masks
    flowi = flows[0]

    fig = plt.figure(figsize=(12,5))
    plot.show_segmentation(fig,chAnnels=chAnnels)
    plt.tight_layout()
    plt.show() 

代码结束'''

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的如何修复:TypeError:通过 python 使用 cellpose 时,“list”对象没有属性“shape”全部内容,希望文章能够帮你解决如何修复:TypeError:通过 python 使用 cellpose 时,“list”对象没有属性“shape”所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。