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

Fix GH Actions tests #652

Merged
merged 7 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions .github/workflows/Conda-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.x"
- "3.12"
- "3.11"
- "3.10"
Expand All @@ -33,21 +32,29 @@ jobs:
- name: "Checkout code"
uses: "actions/checkout@v4"

- name: Install opencv dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-glx libegl1-mesa
sudo apt-get install -y python3-opencv

- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-name: DeepForest
environment-file: environment.yml
extra-specs: "python=${{ matrix.python-version }}"
cache-env: true
create-args: "python=${{ matrix.python-version }}"
cache-environment: true
cache-downloads: true

- name: Run pytest, test style, and notebooks
run: |
pip install -e .
pytest -v
yapf -d --recursive deepforest/ --style=.style.yapf
pytest --nbmake docs/*.ipynb
- name: Run pytest
run: pytest -v

- name: Check style
run: yapf -d --recursive deepforest/ --style=.style.yapf

- name: Check notebook build
run: pytest --nbmake docs/*.ipynb

- name: Test Docs
run: |
Expand Down
6 changes: 4 additions & 2 deletions deepforest/models/FasterRCNN.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def __init__(self, config, **kwargs):

def load_backbone(self):
"""A torch vision retinanet model"""
backbone = torchvision.models.detection.fasterrcnn_resnet50_fpn(weights='FasterRCNN_ResNet50_FPN_Weights.COCO_V1')
backbone = torchvision.models.detection.fasterrcnn_resnet50_fpn(
weights='FasterRCNN_ResNet50_FPN_Weights.COCO_V1')
return backbone

def create_model(self, backbone=None):
Expand All @@ -24,7 +25,8 @@ def create_model(self, backbone=None):
model: a pytorch nn module
"""
# load Faster RCNN pre-trained model
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(weights='FasterRCNN_ResNet50_FPN_Weights.COCO_V1')
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(
weights='FasterRCNN_ResNet50_FPN_Weights.COCO_V1')

# get the number of input features
in_features = model.roi_heads.box_predictor.cls_score.in_features
Expand Down
14 changes: 6 additions & 8 deletions deepforest/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,13 @@ def select_annotations(annotations, windows, index, allow_empty=False):
offset = 40
selected_annotations = annotations[(annotations.xmin > (window_xmin - offset)) &
(annotations.xmin < (window_xmax)) &
(annotations.xmax >
(window_xmin)) & (annotations.ymin >
(window_ymin - offset)) &
(annotations.xmax > (window_xmin)) &
(annotations.ymin > (window_ymin - offset)) &
(annotations.xmax < (window_xmax + offset)) &
(annotations.ymin <
(window_ymax)) & (annotations.ymax >
(window_ymin)) &
(annotations.ymax <
(window_ymax + offset))].copy(deep=True)
(annotations.ymin < (window_ymax)) &
(annotations.ymax > (window_ymin)) &
(annotations.ymax < (window_ymax + offset))].copy(
deep=True)
# change the image name
image_basename = os.path.splitext("{}".format(annotations.image_path.unique()[0]))[0]
selected_annotations.image_path = "{}_{}.png".format(image_basename, index)
Expand Down
5 changes: 3 additions & 2 deletions deepforest/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,9 @@ def shapefile_to_annotations(shapefile,
if gdf.crs:
# Check matching the crs
if not gdf.crs.to_string() == raster_crs.to_string():
raise ValueError("The shapefile crs {} does not match the image crs {}".format(
gdf.crs, src.crs))
raise ValueError(
"The shapefile crs {} does not match the image crs {}".format(
gdf.crs, src.crs))

# Transform project coordinates to image coordinates
df["tile_xmin"] = (df.minx - left) / resolution
Expand Down
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dependencies:
- pandas
- pillow>6.2.0
- pip
- pycocotools
- psutil
- pytest
- pytest-profiling
Expand All @@ -28,11 +27,12 @@ dependencies:
- recommonmark
- rtree
- slidingwindow
- setuptools<=59.2.0
- setuptools
- sphinx
- sphinx_rtd_theme
- pytorch::torchvision
- tqdm
- tensorboard
- twine
- xmltodict
- yapf
Expand All @@ -41,4 +41,4 @@ dependencies:
- imagecodecs
- albumentations>=1.0.0
- comet_ml

- pycocotools