Skip to content

Commit

Permalink
Final Experimental to stable Merge pull request #7 from AdrienJaugey/…
Browse files Browse the repository at this point in the history
…experimental

Final Experimental to stable merge
  • Loading branch information
AdrienJaugey authored Jul 16, 2021
2 parents 6c17f9d + 4dc890f commit 5979ca4
Show file tree
Hide file tree
Showing 49 changed files with 3,100 additions and 1,012 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ results
*.jp2
*.txt
*.h5
!docs/img/*.png
!docs/img/*.jpg
!requirements.txt
Mask_R_CNN_mAP_auto_script.py
test.py
bidouille.py
745 changes: 419 additions & 326 deletions nephrology.py → InferenceTool.py

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Skinet (Segmentation of the Kidney through a Neural nETwork) Project

MIT License

Copyright (c) 2020 Adrien Jaugey
Copyright (c) 2020 Skinet Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
23 changes: 23 additions & 0 deletions LICENSE_MATTERPORT
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Mask R-CNN

The MIT License (MIT)

Copyright (c) 2017 Matterport, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
194 changes: 194 additions & 0 deletions Mask_R_CNN_ASAP_Annotations_Fusion.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "KqzoydcMBgc-"
},
"source": [
"# Mask R-CNN - ASAP Annotations Fusion"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Tu0r49kND1_z"
},
"source": [
"## Initialisation"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "fA4OVDl3D5zL"
},
"source": [
"### Detecting Environment"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1JnPwYerzUO4"
},
"outputs": [],
"source": [
"import sys\n",
"IN_COLAB = 'google.colab' in sys.modules\n",
"print(\"Executing in Google Colab\" if IN_COLAB else \"Executing locally\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "LXIK5fcSD9Xq"
},
"source": [
"### Getting all the needed files"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "wa3F4QvMxmCE"
},
"outputs": [],
"source": [
"if IN_COLAB:\n",
" import shutil\n",
" shutil.rmtree('sample_data/', ignore_errors=True)\n",
" import os\n",
" GITHUB_REPO = \"https://raw.githubusercontent.com/AdrienJaugey/Custom-Mask-R-CNN-for-kidney-s-cell-recognition/experimental/\"\n",
" files = ['mrcnn/TensorflowDetector.py', 'mrcnn/utils.py', 'mrcnn/visualize.py', 'mrcnn/post_processing.py',\n",
" 'mrcnn/Config.py', 'mrcnn/statistics.py', 'datasetTools/datasetDivider.py', 'common_utils.py',\n",
" 'datasetTools/datasetWrapper.py', 'datasetTools/datasetIsolator.py', 'datasetTools/AnnotationAdapter.py',\n",
" 'datasetTools/ASAPAdapter.py', 'datasetTools/LabelMeAdapter.py', 'datasetTools/CustomDataset.py']\n",
" for fileToDownload in files:\n",
" url = GITHUB_REPO + fileToDownload\n",
" !wget -qN $url\n",
" if '/' in fileToDownload:\n",
" destDir = fileToDownload.split('/')[0]\n",
" fileName = fileToDownload.split('/')[1].replace('/', '')\n",
" os.makedirs(destDir, exist_ok=True)\n",
" !mv $fileName $fileToDownload"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if IN_COLAB:\n",
" from google.colab import drive\n",
" drive.mount('/content/drive')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "w-I3GmFGEqUQ"
},
"source": [
"## Annotations fusion"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import os\n",
"from datasetTools import AnnotationAdapter\n",
"from datasetTools.ASAPAdapter import ASAPAdapter as a\n",
"from common_utils import progressBar"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Please set ```firstAnnotationsDir```, ```secondAnnotationsDir``` and ```outputAnnotationsDir``` before executing the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"firstAnnotationsDir = \"annotations_in_1/\" #@param {type:\"string\"}\n",
"secondAnnotationsDir = \"annotations_in_2/\" #@param {type:\"string\"}\n",
"outputAnnotationsDir = \"annotations_out/\" #@param {type:\"string\"}\n",
"if IN_COLAB:\n",
" firstAnnotationsDir = os.path.join('drive/MyDrive', firstAnnotationsDir)\n",
" secondAnnotationsDir = os.path.join('drive/MyDrive', secondAnnotationsDir)\n",
" outputAnnotationsDir = os.path.join('drive/MyDrive', outputAnnotationsDir)\n",
"firstAnnotationsDir = os.path.normpath(firstAnnotationsDir)\n",
"secondAnnotationsDir = os.path.normpath(secondAnnotationsDir)\n",
"outputAnnotationsDir = os.path.normpath(outputAnnotationsDir)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Z6OOmdASyMvJ",
"pycharm": {
"name": "#%%\n"
},
"scrolled": false
},
"outputs": [],
"source": [
"firstDirList = os.listdir(firstAnnotationsDir)\n",
"secondDirList = os.listdir(secondAnnotationsDir)\n",
"files = [file for file in firstDirList if file in secondDirList]\n",
"total = len(files)\n",
"if not os.path.exists(outputAnnotationsDir):\n",
" os.makedirs(outputAnnotationsDir)\n",
"for idx, file in enumerate(files):\n",
" progressBar(idx + 1, total, prefix=\"Fusing annotations\", suffix=f\"Current file : {file}\")\n",
" a.fuseAnnotationsFiles([os.path.join(folder, file) for folder in [firstAnnotationsDir, secondAnnotationsDir]],\n",
" os.path.join(outputAnnotationsDir, file))\n",
"print(\"\\nDone !\")"
]
}
],
"metadata": {
"colab": {
"authorship_tag": "ABX9TyOHBS6d5l6TXpghydDsqc9D",
"collapsed_sections": [],
"name": "Mask_R_CNN_Stats_Extractor.ipynb",
"provenance": [],
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Loading

0 comments on commit 5979ca4

Please sign in to comment.