Skip to content

ImportError when importing NonGeoDataset from torchgeo.datasets.geo #10

@veeralakrishna

Description

@veeralakrishna

Description: I am encountering an ImportError while attempting to import NonGeoDataset from torchgeo.datasets.geo module in the satclip codebase. This issue arises when executing the load.py script, specifically when attempting to import NonGeoDataset in the s2geo_dataset.py file.

Steps to Reproduce:

  1. Clone the satclip codebase.
  2. Navigate to the satclip directory.
  3. Execute the load.py script.

Expected Behavior: The load.py script should execute without errors and successfully import NonGeoDataset from torchgeo.datasets.geo module.

Actual Behavior: The following ImportError occurs:

import sys
sys.path.append("./satclip")
from load import get_satclip
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_290/977908425.py in <module>
      1 import sys
      2 sys.path.append("./satclip")
----> 3 from load import get_satclip

/mnt/satclip/satclip/load.py in <module>
----> 1 from main import *
      2 
      3 def get_satclip(ckpt_path, device, return_all=False):
      4     ckpt = torch.load(ckpt_path,map_location=device)
      5     ckpt['hyper_parameters'].pop('eval_downstream')

/mnt/satclip/satclip/main.py in <module>
      5 import lightning.pytorch
      6 import torch
----> 7 from datamodules.s2geo_dataset import S2GeoDataModule
      8 from lightning.pytorch.callbacks import ModelCheckpoint
      9 from lightning.pytorch.cli import LightningCLI

/mnt/satclip/satclip/datamodules/__init__.py in <module>
      1 from .transforms import *
----> 2 from .s2geo_dataset import *

/mnt/satclip/satclip/datamodules/s2geo_dataset.py in <module>
      5 import rasterio
      6 from torch import Tensor
----> 7 from torchgeo.datasets.geo import NonGeoDataset
      8 import matplotlib.pyplot as plt
      9 import numpy as np

ImportError: cannot import name 'NonGeoDataset' from 'torchgeo.datasets.geo' (/opt/conda/lib/python3.8/site-packages/torchgeo/datasets/geo.py)

Environment:

  • Operating System: Linux
  • Python Version: 3.8
  • Dependencies:
    • lightning==2.2.2
    • rasterio==1.3.10
    • torchgeo==0.4.1
    • torch==2.2.1

Additional Information:

  • I have confirmed that the torchgeo library is installed correctly.
  • I am using the latest version of the satclip codebase from the main branch.
  • I have checked the torchgeo documentation and source code, but I couldn't find any references to NonGeoDataset within the torchgeo.datasets.geo module.

Please let me know if there are any additional steps I can take to troubleshoot this issue or if there is any further information needed to assist with resolving this problem. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions