-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add the github action for publishing the package.
- Rename files.
- Loading branch information
Showing
11 changed files
with
195 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Upload Python Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
- name: Build and publish | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_NAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PSS }} | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
twine upload dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# https://github.com/LongTengDao/TOML/ | ||
|
||
[tool.isort] | ||
# https://pycqa.github.io/isort/docs/configuration/options/ | ||
profile = "black" | ||
multi_line_output = 3 | ||
filter_files = true | ||
supported_extensions = "py" | ||
|
||
[tool.black] | ||
line-length = 99 | ||
include = '\.pyi?$' | ||
exclude = ''' | ||
/( | ||
\.eggs | ||
| \.git | ||
| \.idea | ||
| \.vscode | ||
| \.hg | ||
| \.mypy_cache | ||
| \.tox | ||
| \.venv | ||
| _build | ||
| buck-out | ||
| build | ||
| dist | ||
| output | ||
)/ | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
numpy~=1.18.0 | ||
scipy~=1.5.0 | ||
opencv-python~=4.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="pysodmetrics", | ||
packages=find_packages(), | ||
version="1.2.1", | ||
license="MIT", | ||
description="A simple and efficient implementation of SOD metrics.", | ||
author="lartpang", | ||
author_email="[email protected]", | ||
url="https://github.com/lartpang/PySODMetrics", | ||
keywords=[ | ||
"salient object detection", | ||
"saliency detection", | ||
"metric", | ||
"deep learning", | ||
], | ||
install_requires=["scipy>=1.5,<2", "numpy>=1.18,<2"], | ||
classifiers=[ | ||
"Development Status :: 5 - Production/Stable", | ||
"Environment :: Console", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Topic :: Scientific/Engineering :: Artificial Intelligence", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
# @Time : 2021/3/5 | ||
# @Author : Lart Pang | ||
# @GitHub : https://github.com/lartpang | ||
|
||
|
||
import numpy as np | ||
|
||
from py_sod_metrics.sod_metrics import Emeasure, Fmeasure, MAE, Smeasure, WeightedFmeasure | ||
|
||
|
||
class CalTotalMetric(object): | ||
def __init__(self): | ||
self.cal_mae = MAE() | ||
self.cal_fm = Fmeasure() | ||
self.cal_sm = Smeasure() | ||
self.cal_em = Emeasure() | ||
self.cal_wfm = WeightedFmeasure() | ||
|
||
def step(self, pred: np.ndarray, gt: np.ndarray, gt_path: str): | ||
assert pred.ndim == gt.ndim and pred.shape == gt.shape, (pred.shape, gt.shape, gt_path) | ||
assert pred.dtype == np.uint8, pred.dtype | ||
assert gt.dtype == np.uint8, gt.dtype | ||
|
||
self.cal_mae.step(pred, gt) | ||
self.cal_fm.step(pred, gt) | ||
self.cal_sm.step(pred, gt) | ||
self.cal_em.step(pred, gt) | ||
self.cal_wfm.step(pred, gt) | ||
|
||
def get_results(self, bit_width: int = 3) -> dict: | ||
fm = self.cal_fm.get_results()["fm"] | ||
wfm = self.cal_wfm.get_results()["wfm"] | ||
sm = self.cal_sm.get_results()["sm"] | ||
em = self.cal_em.get_results()["em"] | ||
mae = self.cal_mae.get_results()["mae"] | ||
results = { | ||
"Smeasure": sm, | ||
"wFmeasure": wfm, | ||
"MAE": mae, | ||
"adpEm": em["adp"], | ||
"meanEm": em["curve"].mean(), | ||
"maxEm": em["curve"].max(), | ||
"adpFm": fm["adp"], | ||
"meanFm": fm["curve"].mean(), | ||
"maxFm": fm["curve"].max(), | ||
} | ||
results = {name: metric.round(bit_width) for name, metric in results.items()} | ||
return results | ||
|
||
|
||
if __name__ == '__main__': | ||
cal_total_seg_metrics = CalTotalMetric() | ||
for batch in data_loader: | ||
seg_preds = model(batch) | ||
for seg_pred in seg_preds: | ||
cal_total_seg_metrics.step(seg_pred, mask_array, mask_path) | ||
fixed_seg_results = cal_total_seg_metrics.get_results() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters