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

HF datasets version fix #249

Merged
merged 3 commits into from
Jan 31, 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
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: "--check -t py37 -t py38 -t py39 -t py310 -t py311"
jupyter: true
pylint:
name: Lint with flake8 for syntax+other error codes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Install flake8
run: pip install flake8
run: pip install flake8==7.0.0
- name: Lint with flake8
run: flake8 --ignore=E203,E501,E722,E401,W503 src tests --count --show-source --statistics
run: flake8 --ignore=E203,E501,E722,E401,W503,E704 src tests --count --show-source --statistics
nblint:
name: Lint Notebooks
runs-on: ubuntu-latest
Expand Down
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.1.1
hooks:
- id: black
- id: black-jupyter
language_version: python3.11

- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
Expand All @@ -11,8 +12,8 @@ repos:
description: Clears output and some metadata from notebooks

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
args: ['--ignore=E203,E501,E722,E401,W503 src tests --count --show-source --statistics']
args: ['--ignore=E203,E501,E722,E401,W503,E704 src tests --count --show-source --statistics']

8 changes: 6 additions & 2 deletions docs/source/tutorials/huggingface_dataset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@
"metadata": {},
"outputs": [],
"source": [
"indices = imagelab.issues.query('is_blurry_issue').sort_values(by='blurry_score').index.tolist()"
"indices = (\n",
" imagelab.issues.query(\"is_blurry_issue\")\n",
" .sort_values(by=\"blurry_score\")\n",
" .index.tolist()\n",
")"
]
},
{
Expand All @@ -216,7 +220,7 @@
"metadata": {},
"outputs": [],
"source": [
"dataset[indices[8]]['image']"
"dataset[indices[8]][\"image\"]"
]
},
{
Expand Down
4 changes: 3 additions & 1 deletion docs/source/tutorials/torchvision_dataset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@
"metadata": {},
"outputs": [],
"source": [
"indices = imagelab.issues.query('is_dark_issue').sort_values(by='dark_score').index.tolist()"
"indices = (\n",
" imagelab.issues.query(\"is_dark_issue\").sort_values(by=\"dark_score\").index.tolist()\n",
")"
]
},
{
Expand Down
14 changes: 8 additions & 6 deletions docs/source/tutorials/tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@
"metadata": {},
"outputs": [],
"source": [
"blurry_images = imagelab.issues[imagelab.issues[\"is_blurry_issue\"] == True].sort_values(by=['blurry_score'])\n",
"blurry_images = imagelab.issues[imagelab.issues[\"is_blurry_issue\"] == True].sort_values(\n",
" by=[\"blurry_score\"]\n",
")\n",
"blurry_image_files = blurry_images.index.tolist()"
]
},
Expand Down Expand Up @@ -249,7 +251,7 @@
"metadata": {},
"outputs": [],
"source": [
"imagelab.visualize(issue_types=['blurry'])"
"imagelab.visualize(issue_types=[\"blurry\"])"
]
},
{
Expand Down Expand Up @@ -289,7 +291,7 @@
"metadata": {},
"outputs": [],
"source": [
"imagelab.info['statistics'].keys()"
"imagelab.info[\"statistics\"].keys()"
]
},
{
Expand All @@ -308,7 +310,7 @@
"metadata": {},
"outputs": [],
"source": [
"imagelab.info['statistics']['entropy']"
"imagelab.info[\"statistics\"][\"entropy\"]"
]
},
{
Expand All @@ -334,7 +336,7 @@
"metadata": {},
"outputs": [],
"source": [
"imagelab.info['exact_duplicates']['num_sets']"
"imagelab.info[\"exact_duplicates\"][\"num_sets\"]"
]
},
{
Expand All @@ -351,7 +353,7 @@
"metadata": {},
"outputs": [],
"source": [
"imagelab.info['exact_duplicates']['sets']"
"imagelab.info[\"exact_duplicates\"][\"sets\"]"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies = [
]

[project.optional-dependencies]
huggingface = ["datasets>=2.7.0"]
huggingface = ['datasets>=2.15.0; python_version > "3.7"', 'datasets>=2.7.0; python_version < "3.8"']
pytorch = ["torchvision>=0.12.0"]
azure = ["adlfs>=2022.2.0"] # latest compatible with Python 3.7
gcs = ["gcsfs>=2022.1.0"] # latest compatible with Python 3.7
Expand Down
1 change: 1 addition & 0 deletions src/cleanvision/imagelab.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
The methods in this module should suffice for most use-cases,
but advanced users can get extra flexibility via the code in other CleanVision modules.
"""

from __future__ import annotations

import random
Expand Down
14 changes: 7 additions & 7 deletions src/cleanvision/issue_managers/image_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,15 @@ def calc_avg_brightness(image: Image) -> float:


@overload
def calculate_brightness(red: float, green: float, blue: float) -> float:
...
def calculate_brightness(red: float, green: float, blue: float) -> float: ...


@overload
def calculate_brightness(
red: "np.ndarray[Any, Any]",
green: "np.ndarray[Any, Any]",
blue: "np.ndarray[Any, Any]",
) -> "np.ndarray[Any, Any]":
...
) -> "np.ndarray[Any, Any]": ...


def calculate_brightness(
Expand Down Expand Up @@ -127,9 +125,11 @@ def score_columns(self) -> List[str]:
def __init__(self, issue_type: str) -> None:
self.issue_type = issue_type
self._score_columns = [
"brightness_perc_99"
if self.issue_type == IssueType.DARK.value
else "brightness_perc_5"
(
"brightness_perc_99"
if self.issue_type == IssueType.DARK.value
else "brightness_perc_5"
)
]

def calculate(self, image: Image) -> Dict[str, Union[float, str]]:
Expand Down
Loading