gpt4 book ai didi

python - 我如何使用 mask_rcnn 保存我的图像结果

转载 作者:行者123 更新时间:2023-12-05 07:22:56 24 4
gpt4 key购买 nike

我只想保存我使用 mask_rcnn 的图像的一部分例如,我想从 test.jpg 中只提取包的类,并使用 python 图像裁剪得到只有该包的图像,但是代码太复杂,不知道。

# Load a random image from the images folder
file_names = next(os.walk(IMAGE_DIR))[2]
image = skimage.io.imread(os.path.join(IMAGE_DIR, "test2.jpg"))

# Run detection
results = model.detect([image], verbose=1)

# Visualize results
r = results[0]
visualize.display_instances(image, r['rois'], r['masks'], r['class_ids'],
class_names, r['scores'])

打印出只有一个袋子的图像并将其保存在名为 test.jpg 的文件中。通过使用 python 裁剪

最佳答案

您可以通过编辑 visualize.py 和插入来保存图像 plt.savefig('your_desired_pa​​th_to_image.jpg',bbox_inches='tight', pad_inches=-0.5,orientation= 'landscape') 在代码之后 ax.imshow(masked_image.astype(np.uint8))在这里找到链接 https://github.com/matterport/Mask_RCNN/issues/134

关于python - 我如何使用 mask_rcnn 保存我的图像结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56269033/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com