Skip to content

Commit

Permalink
Fixed pre-commit and some arguments bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
spirosmaggioros committed Oct 31, 2024
1 parent 359f682 commit a778abd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 46 deletions.
35 changes: 15 additions & 20 deletions DLICV/__main__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import argparse
import json
import os
from pathlib import Path
import shutil
import sys
import warnings
from pathlib import Path

import torch

Expand All @@ -15,12 +16,13 @@
# VERSION = pkg_resources.require("NiChart_DLMUSE")[0].version
VERSION = 1.0


def main() -> None:
prog="DLICV"
prog = "DLICV"
parser = argparse.ArgumentParser(
prog=prog,
description="DLICV - Deep Learning Intra Cranial Volume.",
usage = """
usage="""
DLICV v{VERSION}
ICV calculation for structural MRI data.
Expand All @@ -36,18 +38,22 @@ def main() -> None:
-o /path/to/output \
-device cpu|cuda|mps
""".format(VERSION=VERSION),
""".format(
VERSION=VERSION
),
)

# Required Arguments
parser.add_argument(
"-i",
"--in_dir",
type=str,
required=True,
help="[REQUIRED] Input folder with T1 sMRI images (nii.gz).",
)
parser.add_argument(
"-o",
"out_dir",
type=str,
required=True,
help="[REQUIRED] Output folder. If it does not exist it will be created. Predicted segmentations will have the same name as their source images.",
Expand Down Expand Up @@ -200,14 +206,8 @@ def main() -> None:
args.f = [0]

if args.clear_cache:
shutil.rmtree(os.path.join(
Path(__file__).parent,
"nnunet_results"
))
shutil.rmtree(os.path.join(
Path(__file__).parent,
".cache"
))
shutil.rmtree(os.path.join(Path(__file__).parent, "nnunet_results"))
shutil.rmtree(os.path.join(Path(__file__).parent, ".cache"))
if not args.i or not args.o:
print("Cache cleared and missing either -i / -o. Exiting.")
sys.exit(0)
Expand Down Expand Up @@ -240,21 +240,16 @@ def main() -> None:
)

if args.clear_cache:
shutil.rmtree(os.path.join(
Path(__file__).parent,
"nnunet_results"
))
shutil.rmtree(os.path.join(
Path(__file__).parent,
".cache"
))
shutil.rmtree(os.path.join(Path(__file__).parent, "nnunet_results"))
shutil.rmtree(os.path.join(Path(__file__).parent, ".cache"))

# Check if model exists. If not exist, download using HuggingFace
if not os.path.exists(model_folder):
# HF download model
print("DLICV model not found, downloading...")

from huggingface_hub import snapshot_download

local_src = Path(__file__).parent
snapshot_download(repo_id="nichart/DLICV", local_dir=local_src)
print("DLICV model has been successfully downloaded!")
Expand Down
47 changes: 21 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""Setup tool for DLICV."""

import io
import os
from pathlib import Path

from setuptools import find_packages, setup

this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()

with open('requirements.txt') as f:
with open("requirements.txt") as f:
required = f.read().splitlines()

setup(
Expand All @@ -26,29 +25,25 @@
packages=find_packages(exclude=["tests", ".github"]),
python_requires=">=3.8",
install_requires=required,
entry_points={
"console_scripts": ["DLICV = DLICV.__main__:main"]
},
entry_points={"console_scripts": ["DLICV = DLICV.__main__:main"]},
classifiers=[
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: Healthcare Industry",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Image Processing",
"Topic :: Scientific/Engineering :: Medical Science Apps.",
],
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: Healthcare Industry",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Image Processing",
"Topic :: Scientific/Engineering :: Medical Science Apps.",
],
license="By installing/using DLICV, the user agrees to the following license: See https://www.med.upenn.edu/cbica/software-agreement-non-commercial.html",
keywords = [
'deep learning',
'image segmentation',
'semantic segmentation',
'medical image analysis',
'medical image segmentation',
'nnU-Net',
'nnunet'
],
package_data={
"DLICV": ["VERSION"]
},
keywords=[
"deep learning",
"image segmentation",
"semantic segmentation",
"medical image analysis",
"medical image segmentation",
"nnU-Net",
"nnunet",
],
package_data={"DLICV": ["VERSION"]},
)

0 comments on commit a778abd

Please sign in to comment.