Skip to content

Commit

Permalink
Layout and minimal changes (#23)
Browse files Browse the repository at this point in the history
* don't move to gpu inside prepare_data

* switch to src layout

* run black

* change python -m pytest to pytest in README

---------

Co-authored-by: marshrossney <[email protected]>
  • Loading branch information
jmarshrossney and jmarshrossney authored Aug 29, 2024
1 parent f2eb3aa commit e1f6d58
Show file tree
Hide file tree
Showing 56 changed files with 23 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
**/__pycache__/
vectors/
*.ipynb
*.egg-info/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ Please note that this is specifically pinned to python 3.9 due to dependency ver

Get started by cloning this repository and running

`pip install -e .`
`python -m pip install -e .`

### Running tests

`python -m pytest` or `py.test`
`pytest` or `py.test`

## Contents

Expand Down
20 changes: 15 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
[build-system]
requires = ["setuptools >= 61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "cyto_ml"
version = "0.1"
version = "0.1.0"
requires-python = "==3.9.*"
description = "This package supports the processing and analysis of plankton sample data"
readme = "README.md"
requires-python = "==3.9.*"

[tool.setuptools]
py-modules = []

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

[tool.pytest.ini_options]
filterwarnings = [
"ignore::DeprecationWarning",
]

[tool.black]
target-version = ["py39"]
line-length = 88
1 change: 1 addition & 0 deletions scripts/intake_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Via https://gallery.pangeo.io/repos/pangeo-data/pangeo-tutorial-gallery/intake.html#Build-an-intake-catalog
"""

import os
from cyto_ml.data.intake import intake_yaml
from cyto_ml.data.s3 import s3_endpoint, image_index
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 4 additions & 6 deletions cyto_ml/models/scivision.py → src/cyto_ml/models/scivision.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,18 @@ def prepare_image(image: DataArray):
Take an xarray of image data and prepare it to pass through the model
a) Converts the image data to a PyTorch tensor
b) Accepts a single image or batch (no need for torch.stack)
c) Uses a CUDA device if available
"""
# Computes the DataArray and returns a numpy array
image_numpy = image.to_numpy()

# Convert the image data to a PyTorch tensor
tensor_image = torchvision.transforms.ToTensor()(image.to_numpy())
tensor_image = torchvision.transforms.ToTensor()(image_numpy)

# 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()

return tensor_image


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e1f6d58

Please sign in to comment.