运行地球观测CNN会导致错误

2024-06-06 11:53:07 发布

您现在位置:Python中文网/ 问答频道 /正文

在对python github代码和python教程进行了许多天的研究之后,我发现了一个值得运行的代码,以便参与地球观测数据集,作为我实现目标的起点。 这是我试图找出如何运行它的代码:https://github.com/simongrest/farm-pin-crop-detection-challenge更具体地说,这个笔记本:https://github.com/simongrest/farm-pin-crop-detection-challenge/blob/master/notebooks/Create%20Unet%20Features.ipynb我试图在colab上运行它,但是有很多错误,所以我复制并粘贴到一个.py文件,以便运行到Ubuntu 20.04。它在笔记本的这一点(“7”)崩溃:

class LULC(Enum):
    NO_DATA        = (0,  'No Data',          'black')
    COTTON         = (1,  'Cotton',           'xkcd:lime')
    DATES          = (2,  'Dates',            'xkcd:darkgreen')
    GRASS          = (3,  'Grass',            'orange')
    LUCERN         = (4,  'Lucern',           'xkcd:tan')
    MAIZE          = (5,  'Maize',            'xkcd:azure')
    PECAN          = (6,  'Pecan',            'xkcd:lightblue')
    VACANT         = (7,  'Vacant',           'xkcd:beige')
    VINEYARD       = (8,  'Vineyard',         'crimson')
    VINEYARD_PECAN = (9,  'Vineyard & Pecan', 'xkcd:lavender')
    
    def __init__(self, val1, val2, val3):
        self.id = val1
        self.class_name = val2
        self.color = val3
        
# Reference colormap things
lulc_cmap = mpl.colors.ListedColormap([entry.color for entry in LULC])

我面临着这个错误:

File "/home/UbuntuUser/.local/lib/python3.8/site-packages/eolearn/core/eodata.py", line 708, in __getitem__
    value = super().__getitem__(feature_name)
KeyError: 'LULC'

这是eodata.py文件的以下错误:

def __getitem__(self, feature_name, load=True):    # line 706
    """Implements lazy loading."""
    value = super().__getitem__(feature_name)      # line 708 <------------------------
 
 
    if isinstance(value, FeatureIO) and load:
        value = value.load()
        self[feature_name] = value
 
    return value                                   # line 715

文件如下:https://github.com/sentinel-hub/eo-learn/blob/master/core/eolearn/core/eodata.py

我花了很多天的时间在谷歌上寻找问题所在,但都没有成功,你能帮我吗


Tags: 文件代码namepyhttpsselfgithubcom