首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >模块sklearn.feature_extraction.image没有属性“extract_patches”

模块sklearn.feature_extraction.image没有属性“extract_patches”
EN

Stack Overflow用户
提问于 2022-03-13 21:59:08
回答 1查看 149关注 0票数 2

对于代码,我不知道如何使用3位置的extract_patches

代码语言:javascript
运行
复制
for filei in phases[phase]:
    fname=files[filei] 
    
    print(fname)
    classid=[idx for idx in range(len(class_names)) if class_names[idx] in fname][0]
    totals[classid]+=1

    io=cv2.cvtColor(cv2.imread(fname),cv2.COLOR_BGR2RGB)
    interp_method=PIL.Image.BICUBIC


    io = cv2.resize(io,(0,0),fx=resize,fy=resize, interpolation=interp_method) #resize it as specified above
    io = np.pad(io, [(mirror_pad_size, mirror_pad_size), (mirror_pad_size, mirror_pad_size), (0, 0)], mode="reflect")

    #convert input image into overlapping tiles, size is ntiler x ntilec x 1 x patch_size x patch_size x3
    io_arr_out=sklearn.feature_extraction.image.extract_patches(io,(patch_size,patch_size,3),stride_size)
   

    #resize it into a ntile x patch_size x patch_size x 3
    io_arr_out=io_arr_out.reshape(-1,patch_size,patch_size,3)



    storage["imgs"].append(io_arr_out)
    storage["labels"].append([classid for x in range(io_arr_out.shape[0])]) #add the filename to the storage array
    storage["filenames"].append([fname for x in range(io_arr_out.shape[0])]) #add the filename to the storage array
EN

回答 1

Stack Overflow用户

发布于 2022-10-01 04:55:32

您可以使用patchify代替:

代码语言:javascript
运行
复制
from patchify import patchify
io_arr_out = patchify(io, (patch_size,patch_size,3), step = stride_size )
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71461192

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档