Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Kohulan authored Feb 15, 2024
2 parents 7bd9601 + c990944 commit 8e2046d
Show file tree
Hide file tree
Showing 13 changed files with 630 additions and 615 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/check_errors_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This is a basic workflow to help you get started with Actions

name: Error checking and testing

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ master ]
pull_request:
branches: [ master ]


# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install basic dependencies
run: |
python -m pip install --upgrade pip
- name: Test with tox
run: |
pip install -e .
pip install tox
tox
release-please:
runs-on: ubuntu-latest
needs: build
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: python
package-name: release-please-action
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
start-version: '1.1.4'
25 changes: 25 additions & 0 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish Python distributions to PyPI

on:
release:
types: [published]
workflow_dispatch:

jobs:
build-n-publish:
name: Build and publish Python distributions to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install pypa/setuptools
run: python -m pip install wheel
- name: Build a binary wheel
run: python setup.py sdist bdist_wheel
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
78 changes: 78 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Changelog

## [1.3.0](https://github.com/Kohulan/DECIMER-Image-Segmentation/compare/v1.2.5...v1.3.0) (2023-11-20)


### Features

* delete more deprecated mask expansion code ([45e0b97](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/45e0b970f3cf1c0b89421c478bc9a6ce23bd0217))
* delete tests of deleted functions ([99d1b38](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/99d1b3849aba7abe7588d489486f4862ebd158f4))
* new seed pixel determination ([2ef9a5e](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/2ef9a5e7e406407b09e1197f1c0defc2be1250bb))
* remove deprecated expansion code ([1ca862f](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/1ca862f0237134b935d5d32151129d0045057f4c))
* speed-up scikit-image and avoiding loops ([fd874a3](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/fd874a34ec9045b8ab116c34f1821479397e5e10))
* Update demonstration notebook ([e648541](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/e6485410fcebe72ef50b26d4a335d151db42de67))
* update dependencies ([60358c9](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/60358c9f9cc4fd29184d78c84718cb454b8cbfaf))
* Update link to download new model ([28c3397](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/28c33975d1538f6920321f03cc638d38e96f7dd9))


### Bug Fixes

* table line exlusion with connected object detection ([e2f38d7](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/e2f38d7b646fefc39b3401d49fd9a54707ddeb20))
* tests for mask expansion ([3ec8239](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/3ec8239db46b1d92faa89a15e3e1319462f04502))
* update model link README.md ([c5b2cd3](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/c5b2cd3d04133aeaee41ee9fb6a0d263154abb7e))

## [1.2.5](https://github.com/Kohulan/DECIMER-Image-Segmentation/compare/v1.2.4...v1.2.5) (2023-10-19)


### Bug Fixes

* adapt seed pixel determination test according to changes ([337775d](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/337775d34b536ee79aa63e7b0153aae7c49b229d))
* do not return empty segments ([f1deb46](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/f1deb4606627fd96c43ec8527c5287e0823f5905))
* don't use pixels from exclusion mask as seed pixels ([fe96aa9](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/fe96aa91af94c2c8b650ae8d3215a3b497af7469))

## [1.2.4](https://github.com/Kohulan/DECIMER-Image-Segmentation/compare/v1.2.3...v1.2.4) (2023-10-19)


### Bug Fixes

* expansion crash when no structures have been detected [#95](https://github.com/Kohulan/DECIMER-Image-Segmentation/issues/95) ([1242a67](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/1242a676de2ba970d074be151b8b1865b608f8d5))

## [1.2.3](https://github.com/Kohulan/DECIMER-Image-Segmentation/compare/v1.2.2...v1.2.3) (2023-09-21)


### Bug Fixes

* test-commit ([33fd1b7](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/33fd1b70cc021aac0334e29cf85c312ea50fd42f))

## [1.2.2](https://github.com/Kohulan/DECIMER-Image-Segmentation/compare/v1.2.1...v1.2.2) (2023-09-21)


### Bug Fixes

* remove wrong version specification ([b997b43](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/b997b43c7cbb1f581f576a3a6e4fc50fc8aeb2d4))
* stable version specification for ([22b1a51](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/22b1a51a1e90c0b10848cbddbf03a0852548afc3))
* trigger pypi release on release ([7b1eb37](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/7b1eb37efe32473e4268205953aa82d3c3e5518f))

## [1.2.1](https://github.com/Kohulan/DECIMER-Image-Segmentation/compare/v1.2.0...v1.2.1) (2023-09-21)


### Bug Fixes

* GH action for pypi releases ([ce4c3b9](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/ce4c3b940d4c9763f6fb352c7cc4bf5895185d2a))

## [1.2.0](https://github.com/Kohulan/DECIMER-Image-Segmentation/compare/1.1.4...v1.2.0) (2023-09-19)


### Features

* adaptive line kernel based on structure size ([2f2fe8e](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/2f2fe8e350b6f88eeda2fa9d2c20967283ef0bb6))
* function to get mean size from bboxes ([70a5b2b](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/70a5b2b66a29dda2e63308e0c24b57093eaefb76))
* GH Action for automated Pypi releases ([dbc55f6](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/dbc55f64ba91899b542ffe5e007ae23ba570d892))


### Bug Fixes

* formatted with black ([b7c7417](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/b7c74173fa62f7f5a880fe85069a7942783d296a))
* linter appeasement ([79c89ca](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/79c89ca4898edca0ad0552ae6681d379198fa426))
* lower relative threshold for kernel for line detection ([1aa4deb](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/1aa4debe8557e8ef379db0b52823e8f5d0dd1ed8))
* max instead of mean structure size for line kernels ([227c452](https://github.com/Kohulan/DECIMER-Image-Segmentation/commit/227c4527cfeb5407daa7b041eb221ff5913420f8))
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ authors:


title: "DECIMER-Image-Segmentation"
version: 1.1.1
version: 1.3.0
doi: 10.5281/zenodo.7299334
date-released: 2021-05-03
url: "https://github.com/OBrink/DECIMER-Image-Segmentation"
Expand Down
148 changes: 101 additions & 47 deletions DECIMER_Segmentation_notebook.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $ conda install -c conda-forge poppler
$ pip install decimer-segmentation
```

### The Mask-RCNN Model is available at: [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7228583.svg)](https://doi.org/10.5281/zenodo.7228583)
### The Mask-RCNN Model is available at: [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10142866.svg)](https://doi.org/10.5281/zenodo.10142866)

## How to use DECIMER-Segmentation
- The repository contains a script that can be used for the segmentation of chemical structures from an image of a scanned page or from a pdf document:
Expand Down
120 changes: 81 additions & 39 deletions Validation/visualization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -131,47 +131,67 @@
"def weighted_average(array, weights):\n",
" average = 0\n",
" for n in range(len(array)):\n",
" average += array[n]*weights[n]/sum(weights)\n",
" average += array[n] * weights[n] / sum(weights)\n",
" return average\n",
" \n",
"\n",
"\n",
"journals = np.array([\"Molecules\", \"Phytochemistry\", \"J. Nat. Prod\"])\n",
"sum_of_all_structures = np.array([396+33, 182+29, 306+24]) # real amount of structures\n",
"sum_of_all_structures = np.array(\n",
" [396 + 33, 182 + 29, 306 + 24]\n",
") # real amount of structures\n",
"complete_structures_only_model = np.array([321, 152, 250])\n",
"complete_structures = np.array([396, 182, 306])\n",
"recognized_structures = np.array([398, 182, 306])\n",
"too_much_only_model = [44, 10, 29]\n",
"too_much = [50, 21, 29]\n",
"\n",
"recognized_structure_proportions = recognized_structures/sum_of_all_structures\n",
"complete_structures_only_model_proportions = complete_structures_only_model/recognized_structures\n",
"complete_structures_proportions = complete_structures/recognized_structures\n",
"recognized_structure_proportions = recognized_structures / sum_of_all_structures\n",
"complete_structures_only_model_proportions = (\n",
" complete_structures_only_model / recognized_structures\n",
")\n",
"complete_structures_proportions = complete_structures / recognized_structures\n",
"too_much_only_model_proportions = too_much_only_model / recognized_structures\n",
"too_much_proportions = too_much / recognized_structures\n",
"\n",
"\n",
"df_array= np.array([journals, \n",
" recognized_structure_proportions,\n",
" complete_structures_only_model_proportions,\n",
" complete_structures_proportions,\n",
" too_much_only_model_proportions,\n",
" too_much_proportions])\n",
"df_array = np.array(\n",
" [\n",
" journals,\n",
" recognized_structure_proportions,\n",
" complete_structures_only_model_proportions,\n",
" complete_structures_proportions,\n",
" too_much_only_model_proportions,\n",
" too_much_proportions,\n",
" ]\n",
")\n",
"\n",
"labels = np.array([[\"Journals\"],\n",
" [\"Proportion of recognized structures\"], \n",
" [\"Complete structures (only model) (proportions)\"],\n",
" [\"Complete structures (proportions)\"],\n",
" [\"too much (only model) (proportions)\"],\n",
" [\"too much (proportions)\"]])\n",
"labels = np.array(\n",
" [\n",
" [\"Journals\"],\n",
" [\"Proportion of recognized structures\"],\n",
" [\"Complete structures (only model) (proportions)\"],\n",
" [\"Complete structures (proportions)\"],\n",
" [\"too much (only model) (proportions)\"],\n",
" [\"too much (proportions)\"],\n",
" ]\n",
")\n",
"\n",
"weighted_averages = np.array([[\"Weighted average\"],\n",
" [weighted_average(recognized_structure_proportions, sum_of_all_structures)],\n",
" [weighted_average(complete_structures_only_model_proportions, recognized_structures)],\n",
" [weighted_average(complete_structures_proportions, recognized_structures)],\n",
" [weighted_average(too_much_only_model_proportions, recognized_structures)],\n",
" [weighted_average(too_much_proportions, recognized_structures)]])\n",
"weighted_averages = np.array(\n",
" [\n",
" [\"Weighted average\"],\n",
" [weighted_average(recognized_structure_proportions, sum_of_all_structures)],\n",
" [\n",
" weighted_average(\n",
" complete_structures_only_model_proportions, recognized_structures\n",
" )\n",
" ],\n",
" [weighted_average(complete_structures_proportions, recognized_structures)],\n",
" [weighted_average(too_much_only_model_proportions, recognized_structures)],\n",
" [weighted_average(too_much_proportions, recognized_structures)],\n",
" ]\n",
")\n",
"\n",
"pd.DataFrame(np.concatenate((labels, df_array, weighted_averages), axis = 1)).round(1)\n",
"\n"
"pd.DataFrame(np.concatenate((labels, df_array, weighted_averages), axis=1)).round(1)"
]
},
{
Expand All @@ -193,35 +213,57 @@
}
],
"source": [
"# This plot has been created according to the tutorial on \n",
"# This plot has been created according to the tutorial on\n",
"# https://matplotlib.org/gallery/lines_bars_and_markers/barchart.html#sphx-glr-gallery-lines-bars-and-markers-barchart-py\n",
"#height = [306*100/331, 295*100/306, 183*100/206, 177*100/183, 398*100/403, 387*100/398]\n",
"labels = ('Molecules', 'Phytochemistry', 'J. Nat. Prod.')\n",
"# height = [306*100/331, 295*100/306, 183*100/206, 177*100/183, 398*100/403, 387*100/398]\n",
"labels = (\"Molecules\", \"Phytochemistry\", \"J. Nat. Prod.\")\n",
"x = np.arange(len(labels)) # label locations\n",
"width = 0.25 # width of the bars\n",
"\n",
"fig, ax = plt.subplots()\n",
"rects1 = ax.bar(x - width, complete_structures_proportions*100, width, label=\"Proportion of segments with complete chemical structures \", color = \"#D7FA64\")\n",
"rects2 = ax.bar(x, recognized_structure_proportions*100, width, label=\"Proportion of recognized structure depictions\", color = \"#7DAFFA\")\n",
"rects3 = ax.bar(x + width, too_much_proportions*100, width, label=\"Proportion of segments with additional elements\", color = \"#F27D6D\")\n",
"rects1 = ax.bar(\n",
" x - width,\n",
" complete_structures_proportions * 100,\n",
" width,\n",
" label=\"Proportion of segments with complete chemical structures \",\n",
" color=\"#D7FA64\",\n",
")\n",
"rects2 = ax.bar(\n",
" x,\n",
" recognized_structure_proportions * 100,\n",
" width,\n",
" label=\"Proportion of recognized structure depictions\",\n",
" color=\"#7DAFFA\",\n",
")\n",
"rects3 = ax.bar(\n",
" x + width,\n",
" too_much_proportions * 100,\n",
" width,\n",
" label=\"Proportion of segments with additional elements\",\n",
" color=\"#F27D6D\",\n",
")\n",
"\n",
"# Add some text for labels, title and custom x-axis tick labels, etc.\n",
"ax.set_ylabel('Percentage (%)')\n",
"ax.set_ylabel(\"Percentage (%)\")\n",
"ax.set_xticks(x)\n",
"ax.set_xticklabels(labels)\n",
"ax.legend()\n",
"ax.set_ylim(0,140)\n",
"ax.set_ylim(0, 140)\n",
"\n",
"\n",
"def autolabel(rects):\n",
" \"\"\"Attach a text label above each bar in *rects*, displaying its height.\"\"\"\n",
" for rect in rects:\n",
" height = rect.get_height()\n",
" height = round(height, 1)\n",
" ax.annotate('{}'.format(height),\n",
" xy=(rect.get_x() + rect.get_width() / 2, height),\n",
" xytext=(0, 3), # 3 points vertical offset\n",
" textcoords=\"offset points\",\n",
" ha='center', va='bottom')\n",
" ax.annotate(\n",
" \"{}\".format(height),\n",
" xy=(rect.get_x() + rect.get_width() / 2, height),\n",
" xytext=(0, 3), # 3 points vertical offset\n",
" textcoords=\"offset points\",\n",
" ha=\"center\",\n",
" va=\"bottom\",\n",
" )\n",
"\n",
"\n",
"autolabel(rects1)\n",
Expand Down
4 changes: 2 additions & 2 deletions decimer_segmentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
For comments, bug reports or feature requests,
please raise a issue on our Github repository.
please raise an issue on our GitHub repository.
"""

__version__ = "1.1.3"
__version__ = "1.3.0"

__all__ = [
"decimer_segmentation",
Expand Down
Loading

0 comments on commit 8e2046d

Please sign in to comment.