-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
648 additions
and
0 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,13 @@ | ||
venv/ | ||
*__pycache__/ | ||
resources/ | ||
*.DS_Store | ||
*.nii | ||
*.nii.gz | ||
*.nrrd | ||
*.obj | ||
*.zip | ||
*log.csv | ||
*.ini | ||
gradio_cached_examples/ | ||
.idea/ |
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,32 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. Windows] | ||
- Version: [e.g. 10] | ||
- Python: [e.g. 3.8.10] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
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,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
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,20 @@ | ||
name: Deploy | ||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
# to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
sync-to-hub: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
lfs: true | ||
- name: Push to hub | ||
env: | ||
HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
run: git push https://dbouget:$HF_TOKEN@huggingface.co/spaces/dbouget/Raidionics-HF main |
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,16 @@ | ||
name: Check file size | ||
on: # or directly `on: [push]` to run the action on every push on any branch | ||
pull_request: | ||
branches: [ main ] | ||
|
||
# to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check-filesize: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check large files | ||
uses: ActionsDesk/lfs-warning@v2.0 | ||
with: | ||
filesizelimit: 10485760 # this is 10MB so we can sync to HF Spaces |
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: Linting | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- '*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Install lint dependencies | ||
run: pip install wheel setuptools black==22.3.0 isort==5.10.1 flake8==4.0.1 | ||
|
||
- name: Lint the code | ||
run: sh shell/lint.sh |
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,13 @@ | ||
venv/ | ||
*__pycache__/ | ||
resources/ | ||
*.DS_Store | ||
*.nii | ||
*.nii.gz | ||
*.nrrd | ||
*.obj | ||
*.zip | ||
*log.csv | ||
*.ini | ||
gradio_cached_examples/ | ||
.idea/ |
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,74 @@ | ||
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker | ||
# you will also find guides on how best to write your Dockerfile | ||
FROM python:3.8-slim | ||
|
||
# set language, format and stuff | ||
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 | ||
|
||
WORKDIR /code | ||
|
||
RUN apt-get update -y | ||
#RUN apt-get install -y python3 python3-pip | ||
RUN apt install git --fix-missing -y | ||
RUN apt install wget -y | ||
|
||
# installing other libraries | ||
RUN apt-get install python3-pip -y && \ | ||
apt-get -y install sudo | ||
RUN apt-get install curl -y | ||
RUN apt-get install nano -y | ||
RUN apt-get update && apt-get install -y git | ||
RUN apt-get install libblas-dev -y && apt-get install liblapack-dev -y | ||
RUN apt-get install gfortran -y | ||
RUN apt-get install libpng-dev -y | ||
RUN apt-get install python3-dev -y | ||
|
||
WORKDIR /code | ||
|
||
# install dependencies | ||
COPY ./requirements.txt /code/requirements.txt | ||
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | ||
|
||
# resolve issue with tf==2.4 and gradio dependency collision issue | ||
RUN pip install --force-reinstall typing_extensions==4.7.1 | ||
|
||
# Install wget | ||
RUN apt install wget -y && \ | ||
apt install unzip | ||
|
||
# Set up a new user named "user" with user ID 1000 | ||
RUN useradd -m -u 1000 user | ||
|
||
# Switch to the "user" user | ||
USER user | ||
|
||
# Set home to the user's home directory | ||
ENV HOME=/home/user \ | ||
PATH=/home/user/.local/bin:$PATH | ||
|
||
# Set the working directory to the user's home directory | ||
WORKDIR $HOME | ||
|
||
# Copy the current directory contents into the container at $HOME/app setting the owner to the user | ||
COPY --chown=user . $HOME | ||
|
||
# Download pretrained models | ||
RUN mkdir -p resources/models/ | ||
RUN wget "https://github.com/raidionics/Raidionics-models/releases/download/1.2.0/Raidionics-MRI_Brain-ONNX-v12.zip" && \ | ||
unzip "Raidionics-MRI_Brain-ONNX-v12.zip" && mv MRI_Brain/ resources/models/MRI_Brain/ | ||
RUN wget "https://github.com/raidionics/Raidionics-models/releases/download/1.2.0/Raidionics-MRI_GBM-ONNX-v12.zip" && \ | ||
unzip "Raidionics-MRI_GBM-ONNX-v12.zip" && mv MRI_GBM/ resources/models/MRI_GBM/ \ | ||
RUN wget "https://github.com/raidionics/Raidionics-models/releases/download/1.2.0/Raidionics-MRI_LGGlioma-ONNX-v12.zip" && \ | ||
unzip "Raidionics-MRI_LGGlioma-ONNX-v12.zip" && mv MRI_LGGlioma/ resources/models/MRI_LGGlioma/ \ | ||
RUN wget "https://github.com/raidionics/Raidionics-models/releases/download/1.2.0/Raidionics-MRI_Meningioma-ONNX-v12.zip" && \ | ||
unzip "Raidionics-MRI_Meningioma-ONNX-v12.zip" && mv MRI_Meningioma/ resources/models/MRI_Meningioma/ | ||
RUN wget "https://github.com/raidionics/Raidionics-models/releases/download/1.2.0/Raidionics-MRI_Metastasis-ONNX-v12.zip" && \ | ||
unzip "Raidionics-MRI_Metastasis-ONNX-v12.zip" && mv MRI_Metastasis/ resources/models/MRI_Metastasis/ | ||
|
||
RUN rm -r *.zip | ||
|
||
# Download test sample | ||
RUN wget "https://github.com/raidionics/Raidionics-HF/releases/download/v1.0.0/t1gd.nii.gz" | ||
|
||
# CMD ["/bin/bash"] | ||
CMD ["python3", "app.py"] |
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,41 @@ | ||
import os | ||
from argparse import ArgumentParser | ||
|
||
from src.gui import WebUI | ||
|
||
|
||
def main(): | ||
parser = ArgumentParser() | ||
parser.add_argument( | ||
"--cwd", | ||
type=str, | ||
default="/home/user/app/", | ||
help="Set current working directory (path to app.py).", | ||
) | ||
parser.add_argument( | ||
"--share", | ||
type=int, | ||
default=1, | ||
help="Whether to enable the app to be accessible online" | ||
"-> setups a public link which requires internet access.", | ||
) | ||
args = parser.parse_args() | ||
|
||
print("Current working directory:", args.cwd) | ||
|
||
if not os.path.exists(args.cwd): | ||
raise ValueError("Chosen 'cwd' is not a valid path!") | ||
if args.share not in [0, 1]: | ||
raise ValueError( | ||
"The 'share' argument can only be set to 0 or 1, but was:", | ||
args.share, | ||
) | ||
|
||
# initialize and run app | ||
print("Launching demo...") | ||
app = WebUI(cwd=args.cwd, share=args.share) | ||
app.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,2 @@ | ||
raidionicsrads@git+https://github.com/dbouget/raidionics_rads_lib | ||
gradio==3.44.4 |
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,14 @@ | ||
[metadata] | ||
description-file = README.md | ||
|
||
[isort] | ||
force_single_line=True | ||
known_first_party=aeropath | ||
line_length=160 | ||
profile=black | ||
|
||
[flake8] | ||
# imported but unused in __init__.py, that's ok. | ||
per-file-ignores=*__init__.py:F401 | ||
ignore=E203,W503,W605,F632,E266,E731,E712,E741 | ||
max-line-length=160 |
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,4 @@ | ||
#!/bin/bash | ||
isort --sl demo/src/ demo/app.py | ||
black --line-length 80 demo/src/ demo/app.py | ||
flake8 demo/src/ demo/app.py |
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,23 @@ | ||
#!/bin/bash | ||
isort --check --sl -c demo/src/ demo/app.py | ||
if ! [ $? -eq 0 ] | ||
then | ||
echo "Please run \"sh shell/format.sh\" to format the code." | ||
exit 1 | ||
fi | ||
echo "no issues with isort" | ||
flake8 demo/src/ demo/app.py | ||
if ! [ $? -eq 0 ] | ||
then | ||
echo "Please fix the code style issue." | ||
exit 1 | ||
fi | ||
echo "no issues with flake8" | ||
black --check --line-length 80 demo/src/ demo/app.py | ||
if ! [ $? -eq 0 ] | ||
then | ||
echo "Please run \"sh shell/format.sh\" to format the code." | ||
exit 1 | ||
fi | ||
echo "no issues with black" | ||
echo "linting success!" |
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 @@ | ||
|
Oops, something went wrong.