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

Layout and minimal changes #23

Merged
merged 5 commits into from
Aug 29, 2024
Merged

Conversation

jmarshrossney
Copy link
Collaborator

@jmarshrossney jmarshrossney commented Aug 22, 2024

This PR collects a small handful of changes which I'm hoping are sufficiently non-contentious to bundle together.

  1. Switch to a src/ layout.
  2. Add the [build-system] table to pyproject.toml (using setuptools for now)
  3. Remove the part of prepare_image that moves the tensor to the default cuda device if available
  4. Filter out deprecation warnings from the pytest output since these are all coming from the fact that we are using an old PyTorch version

As a side note, the main motivation was that I was experiencing a few problems just pip installing the package in editable mode, which made me feel like I was 20 again and unable to figure out why I couldn't import the package I'd just installed. Completing the pyproject.toml and changing to src/ fixed these issues today, as it happened.

@jmarshrossney
Copy link
Collaborator Author

Of negligible importance to us but the change to README.md was based on reading this: https://docs.pytest.org/en/latest/explanation/pythonpath.html#pytest-vs-python-m-pytest

@metazool
Copy link
Collaborator

Super happy with this, ideally want to merge #22 first so there aren't conflicts over layout, it's a good trigger to nudge the relevant people

Copy link
Collaborator

@metazool metazool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Let's get the whole stack of these improvements merged in when you're back on Thursday


# Check if the input is a single image or a batch
if len(tensor_image.shape) == 3:
# Single image, add a batch dimension
tensor_image = tensor_image.unsqueeze(0)

# Check if CUDA is available and move the tensor to the CUDA device
if torch.cuda.is_available():
tensor_image = tensor_image.cuda()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested any of this with a GPU machine, i remember you noticing that the model wasn't moved to CUDA when you ran it with GPU available, it's probably better to do that than remove the half-implemented option?


[tool.jupytext]
formats = "ipynb,md"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this incremental refinement, moving to the "src layout" was also on my inward list now I've been convinced of the benefits

@jmarshrossney jmarshrossney merged commit e1f6d58 into NERC-CEH:main Aug 29, 2024
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

Successfully merging this pull request may close these issues.

2 participants