forked from susheelsk/image-background-removal
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/latest'
- Loading branch information
Showing
352 changed files
with
18,271 additions
and
12,846 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 @@ | ||
venv |
This file was deleted.
Oops, something went wrong.
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,110 @@ | ||
name: Test Master CPU CI/CD | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
jobs: | ||
test_ubuntu: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
pip3 install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu | ||
pip3 install --no-cache-dir -r requirements_test.txt | ||
- name: Download all models | ||
run: | | ||
python3 -c "from carvekit.ml.files.models_loc import download_all; download_all();" | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest -s -v | ||
# - name: Packing a docs folder in a zip archive | ||
# run: | | ||
# zip -r docs.zip ./docs/ | ||
# - name: Upload docs folder | ||
# uses: actions/upload-artifact@v1 | ||
# with: | ||
# name: generated_docs_examples.zip | ||
# path: docs.zip | ||
# - name: Push to Docker Hub | ||
# uses: docker/build-push-action@v1.1.0 | ||
# with: | ||
# tags: merge-to-nontested | ||
# username: ${{ secrets.DOCKER_USERNAME }} | ||
# password: ${{ secrets.DOCKER_PASSWORD }} | ||
# repository: anodev/image-background-remove-tool | ||
# tag_with_ref: true | ||
test_windows: | ||
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
pip3 install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu | ||
pip3 install --no-cache-dir -r requirements_test.txt | ||
- name: Download all models | ||
run: | | ||
python3 -c "from carvekit.ml.files.models_loc import download_all; download_all();" | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest -s -v | ||
test_macos: | ||
runs-on: macos-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
pip3 install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu | ||
pip3 install --no-cache-dir -r requirements_test.txt | ||
- name: Download all models | ||
run: | | ||
python3 -c "from carvekit.ml.files.models_loc import download_all; download_all();" | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest -s -v |
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,25 @@ | ||
name: Test Docker CPU CI/CD | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
|
||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build the CPU Docker img | ||
run: docker build . --file Dockerfile.cpu --tag carvekit | ||
- name: Test CPU Docker image | ||
run: docker run --rm carvekit pytest | ||
- name: Build the GPU Docker image | ||
run: docker build . --file Dockerfile.cuda --tag carvekit_gpu | ||
- name: Test GPU Docker image on CPU | ||
run: docker run --rm carvekit_gpu pytest | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
FROM python:3.8.2 as builder | ||
WORKDIR /app | ||
|
||
# Models download stage | ||
RUN pip3 install --no-cache-dir tqdm requests | ||
RUN mkdir -p ./carvekit/utils/ | ||
RUN mkdir -p ./carvekit/ml/files | ||
RUN touch ./carvekit/__init__.py | ||
RUN touch ./carvekit/ml/__init__.py | ||
RUN touch ./carvekit/utils/__init__.py | ||
COPY ./carvekit/utils/download_models.py ./carvekit/utils/download_models.py | ||
COPY ./carvekit/ml/files/__init__.py ./carvekit/ml/files/__init__.py | ||
COPY ./carvekit/ml/files/models_loc.py ./carvekit/ml/files/models_loc.py | ||
RUN python3 -c "from carvekit.ml.files.models_loc import download_all; download_all();" | ||
RUN rm -rf ./carvekit | ||
|
||
FROM python:3.8.2 | ||
WORKDIR /app | ||
|
||
RUN apt-get update && apt-get -y install libgl1 # Install cv2 dep. | ||
COPY --from=builder /root/.carvekit /root/.carvekit | ||
|
||
# Install requirements | ||
COPY requirements.txt ./ | ||
RUN pip3 install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu | ||
COPY requirements_test.txt ./ | ||
RUN pip3 install --no-cache-dir -r requirements_test.txt | ||
|
||
# Update code | ||
COPY ./ ./ | ||
|
||
# Install to site-packages to make possible run tests and process images by cli | ||
RUN pip3 install -e ./ | ||
|
||
ENV CARVEKIT_PORT '5000' | ||
ENV CARVEKIT_HOST '0.0.0.0' | ||
ENV CARVEKIT_SEGMENTATION_NETWORK 'u2net' | ||
ENV CARVEKIT_PREPROCESSING_METHOD 'none' | ||
ENV CARVEKIT_POSTPROCESSING_METHOD 'fba' | ||
ENV CARVEKIT_DEVICE 'cpu' | ||
ENV CARVEKIT_BATCH_SIZE_SEG '5' | ||
ENV CARVEKIT_BATCH_SIZE_MATTING '1' | ||
ENV CARVEKIT_SEG_MASK_SIZE '320' | ||
ENV CARVEKIT_MATTING_MASK_SIZE '2048' | ||
ENV CARVEKIT_AUTH_ENABLE '1' | ||
|
||
# Tokens will be generated automatically every time the container is restarted if ENV is not set. | ||
|
||
# ENV CARVEKIT_ADMIN_TOKEN 'admin_token' # Do not use this env when creating an image as it is not safe. | ||
# ENV CARVEKIT_ALLOWED_TOKENS 'test_token1,test_token2' # Do not use this env when creating an image as it is not safe. | ||
|
||
EXPOSE 5000 | ||
|
||
CMD ["/bin/sh", "-c", "uvicorn carvekit.web.app:app --host $CARVEKIT_HOST --port $CARVEKIT_PORT"] |
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,54 @@ | ||
FROM python:3.8.2 as builder | ||
WORKDIR /app | ||
|
||
# Models download stage | ||
RUN pip3 install --no-cache-dir tqdm requests | ||
RUN mkdir -p ./carvekit/utils/ | ||
RUN mkdir -p ./carvekit/ml/files | ||
RUN touch ./carvekit/__init__.py | ||
RUN touch ./carvekit/ml/__init__.py | ||
RUN touch ./carvekit/utils/__init__.py | ||
COPY ./carvekit/utils/download_models.py ./carvekit/utils/download_models.py | ||
COPY ./carvekit/ml/files/__init__.py ./carvekit/ml/files/__init__.py | ||
COPY ./carvekit/ml/files/models_loc.py ./carvekit/ml/files/models_loc.py | ||
RUN python3 -c "from carvekit.ml.files.models_loc import download_all; download_all();" | ||
RUN rm -rf ./carvekit | ||
|
||
FROM pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime | ||
WORKDIR /app | ||
|
||
RUN apt-get update && apt-get -y install libgl1 libglib2.0-0 # Install cv2 dep. | ||
COPY --from=builder /root/.carvekit /root/.carvekit | ||
|
||
# Install requirements | ||
COPY requirements.txt ./ | ||
RUN pip3 install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu113 | ||
COPY requirements_test.txt ./ | ||
RUN pip3 install --no-cache-dir -r requirements_test.txt | ||
|
||
# Update code | ||
COPY ./ ./ | ||
|
||
# Install to site-packages to make possible run tests and process images by cli | ||
RUN pip3 install -e ./ | ||
|
||
ENV CARVEKIT_PORT '5000' | ||
ENV CARVEKIT_HOST '0.0.0.0' | ||
ENV CARVEKIT_SEGMENTATION_NETWORK 'u2net' | ||
ENV CARVEKIT_PREPROCESSING_METHOD 'none' | ||
ENV CARVEKIT_POSTPROCESSING_METHOD 'fba' | ||
ENV CARVEKIT_DEVICE 'cuda' | ||
ENV CARVEKIT_BATCH_SIZE_SEG '5' | ||
ENV CARVEKIT_BATCH_SIZE_MATTING '1' | ||
ENV CARVEKIT_SEG_MASK_SIZE '320' | ||
ENV CARVEKIT_MATTING_MASK_SIZE '2048' | ||
ENV CARVEKIT_AUTH_ENABLE '1' | ||
|
||
# Tokens will be generated automatically every time the container is restarted if ENV is not set. | ||
|
||
# ENV CARVEKIT_ADMIN_TOKEN 'admin_token' # Do not use this env when creating an image as it is not safe. | ||
# ENV CARVEKIT_ALLOWED_TOKENS 'test_token1,test_token2' # Do not use this env when creating an image as it is not safe. | ||
|
||
EXPOSE 5000 | ||
|
||
CMD ["/bin/sh", "-c", "uvicorn carvekit.web.app:app --host $CARVEKIT_HOST --port $CARVEKIT_PORT"] |
Oops, something went wrong.