ValueError:有 5 个颜色箱(包括扩展),但 ncolors = 4; ncolors 必须等于或大于 bin 的数量

发布于 2025-01-15 13:29:56 字数 1216 浏览 2 评论 0 原文

我正在栅格化我的 Shapefile,以便使用以下代码使用 U-Net 创建语义分割标签:

rstzr = r.Rasterizer(shape_file,
                     raster_file,
                     class_column,
                     classes_interest = classes_of_interest,
                     non_class_name = non_class)

rstzr.collect_class_names()
rstzr.rasterize_layer()
rstzr.remove_labels_under_cloud(pos_qa = 0, new_label = 3)
m_class_names = ['No Data'] + rstzr.get_class_names() + ['Clouds']
rasterized_layer = rstzr.get_labeled_raster()

rstzr.save_labeled_raster_to_gtiff(out_labels)

vis.plot_labels(rasterized_layer, m_class_names, colors = ['white', 'green', 'yellow', 'blue'], title = "Rasterized Ground Truth")

当我在 Google Colab 中使用此代码时 光栅化形状文件,它工作正常,并且光栅化地面真相也正在绘制,如屏幕截图所示。但是,当我在我大学的其他具有高计算性能的 Jupyter 平台上尝试相同的代码时,它显示错误,可以在屏幕截图中看到

我大学的 Jupyter Notebook 中显示错误,但在 Google Colab 中工作正常

任何人都可以建议该错误可能是什么问题

ValueError:有 5 个颜色箱(包括扩展),但 ncolors = 4; ncolors 必须等于或超过 bin 数量

才能正常工作?

I am rasterizing my Shapefiles for creating labels for Semantic Segmentation using U-Net using the following code:

rstzr = r.Rasterizer(shape_file,
                     raster_file,
                     class_column,
                     classes_interest = classes_of_interest,
                     non_class_name = non_class)

rstzr.collect_class_names()
rstzr.rasterize_layer()
rstzr.remove_labels_under_cloud(pos_qa = 0, new_label = 3)
m_class_names = ['No Data'] + rstzr.get_class_names() + ['Clouds']
rasterized_layer = rstzr.get_labeled_raster()

rstzr.save_labeled_raster_to_gtiff(out_labels)

vis.plot_labels(rasterized_layer, m_class_names, colors = ['white', 'green', 'yellow', 'blue'], title = "Rasterized Ground Truth")

When I am using this code in Google Colab Rasterized Shapefiles, it is working properly and the Rasterized Ground Truth is also being plotted as can be seen in the screenshot. But when I am trying the same code in other Jupyter Platform of my university with high computation performance, it is showing error which can be seen in the screenshot

Error showing in the Jupyter Notebook of my University but working fine in Google Colab

Can anyone suggest what can be the issue for the error

ValueError: There are 5 color bins including extensions, but ncolors = 4; ncolors must equal or exceed the number of bins

while it is working properly when I use it with Google Colab?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文