Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
veeralakrishna opened this issue Apr 25, 2024 · 2 comments

Comments

@veeralakrishna
Copy link

veeralakrishna commented Apr 25, 2024

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.

@veeralakrishna veeralakrishna changed the title Issue Title: ImportError when importing NonGeoDataset from torchgeo.datasets.geo ImportError when importing NonGeoDataset from torchgeo.datasets.geo Apr 25, 2024
@calebrob6
Copy link
Member

Hey @veeralakrishna -- can you try updating torchgeo to >= 0.5

@konstantinklemmer we should probably have an environment.yml or requirements.txt to head off version problems

@konstantinklemmer
Copy link
Collaborator

Yep, I will get to that in the coming two weeks (see also issue here).

I also recommend upgrading to torchgeo==0.5.0. Rasterio, torch and lightning versions seem fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants