作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 skimage 包读取图像,然后对其进行裁剪并保存。
直到裁剪它工作正常。保存时,它会引发以下错误
ValueError: Could not find a format to write the specified file in single-image mode
import os
import numpy as np
import matplotlib.pyplot as plt
import skimage
import dataloader
from utility import To_csv
path='D:\\beantech_Data\\objtect_detection'
def crop(img):
return skimage.util.crop(img, ((0,500),(0,0),(0,0)))
images, boxes, labels = dataloader.train_loader(path)
os.makedirs(os.path.join(path, 'train','cropped'), exist_ok=True)
for i in range(len(images)):
croped_image = crop(images[i])
skimage.io.imsave(os.path.join(path, 'train','cropped',f'img{str(i)}'), croped_image)
box = boxes[i]
To_csv(box, i,os.path.join(path, 'train','cropped'), Aug= True )
最佳答案
问题是,代码中没有给出文件格式,即(.png、.jpeg 等)。
通过更正这一行,代码工作正常-
skimage.io.imsave(os.path.join(path, 'train','cropped',f'img{str(i)}.png'), croped_image)
关于python - 值错误 : Could not find a format to write the specified file in single-image mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61147120/
我是一名优秀的程序员,十分优秀!