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

resize_with_crop_or_pad gives better overall results than central crop to resize (which squeezes) #17

Merged
merged 2 commits into from
Mar 21, 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
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ exclude =
test-obs*,
venv
max-complexity = 10

inline-quotes = "
11 changes: 8 additions & 3 deletions .github/workflows/CI-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ jobs:
build-and-test:
name: Build/Test
runs-on: ubuntu-20.04
steps:
strategy:
matrix:
python-version:
- 3.8.10
- 3.11.6
steps:
- uses: actions/checkout@v4

- name: Use Python
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.11.6'
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
Expand Down
5 changes: 3 additions & 2 deletions lib/inat_inferrer.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,9 @@ def prepare_image_for_inference(file_path):
image = tf.io.read_file(file_path)
image = tf.image.decode_jpeg(image, channels=3)
image = tf.image.convert_image_dtype(image, tf.float32)
image = tf.image.central_crop(image, 0.875)
image = tf.image.resize(image, [299, 299], tf.image.ResizeMethod.NEAREST_NEIGHBOR)
image = tf.image.resize_with_crop_or_pad(
image, 299, 299
)
return tf.expand_dims(image, 0)

@staticmethod
Expand Down
5 changes: 3 additions & 2 deletions lib/vision_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ def prepare_image_for_inference(self, cache_path):
image = tf.io.read_file(cache_path)
image = tf.image.decode_jpeg(image, channels=3)
image = tf.image.convert_image_dtype(image, tf.float32)
image = tf.image.central_crop(image, 0.875)
image = tf.image.resize(image, [299, 299], tf.image.ResizeMethod.NEAREST_NEIGHBOR)
image = tf.image.resize_with_crop_or_pad(
image, 299, 299
)
return tf.expand_dims(image, 0)

def assess_top_results(self, observation, top_results):
Expand Down
8 changes: 4 additions & 4 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage
pytest
pytest-cov
pytest-mock
coverage==7.4.4
pytest==8.1.1
pytest-cov==4.1.0
pytest-mock==3.12.0
57 changes: 33 additions & 24 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
flake8
Flask
Flask-WTF
h3
h3pandas
itsdangerous
jinja2
keras
matplotlib
numpy
pandas
Pillow
prison
python-magic
pyyaml
scikit_learn
scipy
six
tensorflow
tifffile
umap_learn
uWSGI
werkzeug
WTForms
flake8==7.0.0
flake8-quotes==3.4.0
Flask==3.0.2
Flask-WTF==1.2.1
h3==3.7.7
h3pandas==0.2.6
itsdangerous==2.1.2
Jinja2==3.1.3
keras==2.14.0;python_version>="3.11"
keras==2.12.0;python_version=="3.8"
matplotlib==3.8.3;python_version>="3.11"
matplotlib==3.7.5;python_version=="3.8"
numpy==1.26.4;python_version>="3.11"
numpy==1.23.5;python_version=="3.8"
pandas==2.1.2;python_version>="3.11"
pandas==2.0.3;python_version=="3.8"
pillow==10.2.0
prison==0.2.1
python-magic==0.4.27
PyYAML==6.0.1
scikit-learn==1.4.1.post1;python_version>="3.11"
scikit-learn==1.3.2;python_version=="3.8"
scipy==1.12.0;python_version>="3.11"
scipy==1.10.1;python_version=="3.8"
six==1.16.0
tensorflow==2.14.0;python_version>="3.11"
tensorflow==2.12.0;python_version=="3.8"
tifffile==2024.2.12;python_version>="3.11"
tifffile==2023.7.10;python_version=="3.8"
umap-learn==0.5.5
uWSGI==2.0.24
Werkzeug==3.0.1
WTForms==3.1.2
Loading