Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Work In Progress) PR that includes DeadSix27/waifu2x-converter-cpp #286

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cbd7b5d
WIP
devedse Dec 11, 2022
fdc77a2
WIP
devedse Dec 12, 2022
de9f5dd
Added dockerfile updates
devedse Dec 12, 2022
8fa9c57
Some cleanup
devedse Dec 12, 2022
fde0a07
Fix path and added test dockerfile3
devedse Dec 12, 2022
c96094f
Updated dockerfiles to include models in the right directory
devedse Dec 12, 2022
f208bc5
Added support for globs
devedse Dec 12, 2022
d3fb0d9
Fix
devedse Dec 12, 2022
2771323
Some fixes
devedse Dec 12, 2022
e023ff3
Small logging improvement
devedse Dec 12, 2022
8b517c7
fix for str()
devedse Dec 12, 2022
e73024f
Test fix 123
devedse Dec 12, 2022
33adea1
force exit after completion
devedse Dec 12, 2022
412b1e4
Add
devedse Dec 12, 2022
028e85f
test
devedse Dec 12, 2022
76cce96
Fixed container not exiting
devedse Dec 15, 2022
886cc3d
Added builds and stuff
devedse Dec 15, 2022
d33216c
ls
devedse Dec 15, 2022
6bfa74c
This should be better
devedse Dec 15, 2022
23e730b
Made mistake
devedse Dec 15, 2022
21f1bae
Fix windows build
devedse Dec 15, 2022
eb7c1d6
python 3.8
devedse Dec 15, 2022
6423b2a
test new colorlog
devedse Dec 15, 2022
c24bc98
install requirements
devedse Dec 15, 2022
7e8b1cd
back to older colorlog
devedse Dec 15, 2022
ec5fab3
Reverted glob stuff
devedse Dec 15, 2022
52390fe
test nuitka
devedse Dec 16, 2022
5db8962
Added linux build too
devedse Dec 16, 2022
4bfaf79
Fixed some errors
devedse Dec 16, 2022
e86626e
Update githubactionsbuilds.yml
devedse Dec 16, 2022
94ab766
Update githubactionsbuilds.yml
devedse Dec 16, 2022
6d0275b
Merge pull request #1 from akai-katto/master
devedse Dec 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions .github/workflows/githubactionsbuilds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: GitHubActionsBuilds

on: push

jobs:
generate_version_number:
runs-on: ubuntu-latest
outputs:
build_number: ${{ steps.buildnumber.outputs.build_number }}
steps:
- name: Generate build number
id: buildnumber
uses: einaregilsson/build-number@v3
with:
token: ${{secrets.github_token}}

build_docker:
needs: generate_version_number
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: devedse
password: ${{ secrets.DOCKERHUBTOKEN }}
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Builder instance name
run: echo ${{ steps.buildx.outputs.name }}
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Run Buildx
run: |
export VERSION=1.0.${{needs.generate_version_number.outputs.build_number}}
echo Version: $VERSION
#docker buildx build -f Dockerfile --platform linux/arm64,linux/amd64 -t devedse/dandere2x:${{needs.generate_version_number.outputs.build_number}} -t devedse/dandere2x:latest ${{ github.ref == 'refs/heads/master' && '--push' || '' }} .
docker buildx build -f Dockerfile --platform linux/amd64 -t devedse/dandere2x:${{needs.generate_version_number.outputs.build_number}} -t devedse/dandere2x:latest ${{ github.ref == 'refs/heads/master' && '--push' || '' }} .

build_windows:
needs: generate_version_number
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'
# - name: Install PyInstaller
# run: pip install pyinstaller
- name: pip install nuitka
run: pip install nuitka
- name: Pip install requirements
run: pip3 install -r src/requirements.txt
- name: Build to single executable
run: |
cd src
#pyinstaller --onefile main.py
pip install orderedset
python -m nuitka --onefile --enable-plugin=numpy --assume-yes-for-downloads main.py
- name: ls
run: ls -R
- uses: actions/upload-artifact@v3
with:
name: dandere2x_windows
path: src/main.exe

build_linux:
needs: generate_version_number
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'
# - name: Install PyInstaller
# run: pip install pyinstaller
- name: pip install nuitka
run: pip install nuitka
- name: Pip install requirements
run: pip3 install -r src/requirements.txt
- name: Build to single executable
run: |
cd src
#pyinstaller --onefile main.py
pip install orderedset
python -m nuitka --onefile --enable-plugin=numpy --assume-yes-for-downloads main.py
- name: ls
run: ls -R
- uses: actions/upload-artifact@v3
with:
name: dandere2x_linux
path: src/main.bin

release_github:
needs: [
generate_version_number,
build_windows,
build_linux]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
path: ./artifacts/

- name: Display structure of downloaded files
run: |
cd ./artifacts/
ls -R
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: 1.0.${{needs.generate_version_number.outputs.build_number}}
release_name: 1.0.${{needs.generate_version_number.outputs.build_number}}
body: |
${{ github.event.head_commit.message }}
draft: false
prerelease: false
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: 1.0.${{needs.generate_version_number.outputs.build_number}}
files: |
./artifacts/dandere2x_windows/main.exe
./artifacts/dandere2x_linux/main.bin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68 changes: 50 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,51 @@
FROM ubuntu:19.10
FROM ubuntu:22.04 as BASEWAIFUX2CPP

# Since ubuntu 19.10 isn't LTS, use LTS sources for the packages we need.
RUN sed -i "s/archive/old-releases/" /etc/apt/sources.list \
&& sed -i "/security/d" /etc/apt/sources.list \
&& apt-get update
ENV DEBIAN_FRONTEND noninteractive

# We need Nvidia Drivers
RUN apt install -y --no-install-recommends apt-utils software-properties-common
RUN add-apt-repository -y ppa:graphics-drivers/ppa
RUN apt-get -y update
RUN apt -y install ocl-icd-opencl-dev
RUN apt -y install libopencv-dev libopencv-imgcodecs-dev libopencv-imgproc-dev libopencv-core-dev
RUN apt -y install nvidia-cuda-toolkit
RUN apt install -y --no-install-recommends apt-utils software-properties-common gpg-agent
RUN add-apt-repository universe
RUN apt-get -y update

# Needed Library for Building Dandere2x (this will be removed later)
RUN apt-get install -y cmake
RUN apt-get install -y git-core
RUN apt-get install -y build-essential

WORKDIR /dandere2x
RUN git clone "https://github.com/DeadSix27/waifu2x-converter-cpp"
WORKDIR /dandere2x/waifu2x-converter-cpp
RUN mkdir out
WORKDIR /dandere2x/waifu2x-converter-cpp/out
RUN cmake ..
RUN make -j4


FROM ubuntu:22.04

# We need Nvidia Drivers
RUN apt-get -y update
RUN apt install -y --no-install-recommends apt-utils software-properties-common gpg-agent
RUN add-apt-repository universe
RUN apt-get -y update

# Set nvidia-driver installation to not ask for keyboard configeration
RUN export DEBIAN_FRONTEND="noninteractive" & apt-get install -y keyboard-configuration
RUN apt-get install -y keyboard-configuration
ENV DEBIAN_FRONTEND noninteractive

# Needed Libraries for Dandere2x
RUN apt install -y --no-install-recommends ffmpeg nvidia-driver-440 python3.8 libvulkan1 libgtk2.0-dev pkg-config
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update
RUN apt-get install python3.8 -y

RUN apt install -y --no-install-recommends ffmpeg nvidia-driver-440 libvulkan1 libgtk2.0-dev pkg-config

# Dependencies for waifu2x-converter-cpp
RUN apt -y install libopencv-dev libopencv-imgcodecs-dev libopencv-imgproc-dev libopencv-core-dev

# Needed Library for Building Dandere2x (this will be removed later)
RUN apt-get install -y cmake
Expand All @@ -25,27 +56,28 @@ RUN apt-get install -y ffmpeg
RUN apt-get install -y wget
RUN apt-get install -y zip


# Move Dandere2x's files to /dandere2x/
RUN mkdir /dandere2x/
RUN git clone --recurse-submodules --progress https://github.com/aka-katto/dandere2x.git /dandere2x/dandere2x
#RUN mkdir /dandere2x/
#RUN git clone --recurse-submodules --progress https://github.com/devedse/dandere2x.git /dandere2x/dandere2x
COPY . /dandere2x/dandere2x

# Begin the building process
RUN cd /dandere2x/dandere2x/src/ && bash /dandere2x/dandere2x/src/linux_setup.sh
RUN cd /dandere2x/dandere2x/src/ && bash /dandere2x/dandere2x/src/unix_setup.sh

# RUN wget https://github.com/nihui/waifu2x-ncnn-vulkan/releases/download/20200606/waifu2x-ncnn-vulkan-20200606-linux.zip
# RUN unzip waifu2x-ncnn-vulkan-20200606-linux.zip
# RUN mv waifu2x-ncnn-vulkan-20200606-linux /dandere2x/dandere2x/src/externals/waifu2x-ncnn-vulkan
# RUN rm waifu2x-ncnn-vulkan-20200606-linux.zip

# Install Python Dependencies (note pyyaml has to be manually installed due to ubuntu:19.10 python3.8 restriction)
# Ubuntu 19.10 will by default use python3.75 rather than the needed 3.8, so we have to manually get pip and refer to python + python as 3.8
RUN apt-get install python3-distutils python3-apt python3-pip -y
RUN pip3 install -r /dandere2x/dandere2x/src/requirements.txt

RUN wget 'https://bootstrap.pypa.io/get-pip.py' && python3.8 get-pip.py
RUN pip3.8 install -U pip
RUN pip3.8 install -r /dandere2x/dandere2x/src/requirements.txt
COPY --from=BASEWAIFUX2CPP /dandere2x/waifu2x-converter-cpp/out /dandere2x/dandere2x/src/externals/waifu2x-converter-cpp
COPY --from=BASEWAIFUX2CPP /dandere2x/waifu2x-converter-cpp/models_rgb /usr/local/share/waifu2x-converter-cpp/

WORKDIR /dandere2x/dandere2x/src/
ENTRYPOINT ["python3.8", "/dandere2x/dandere2x/src/main.py"]
ENTRYPOINT ["python3", "/dandere2x/dandere2x/src/main.py"]

ENV NVIDIA_DRIVER_CAPABILITIES all
ENV DEBIAN_FRONTEND teletype
5 changes: 4 additions & 1 deletion src/dandere2x/dandere2x_service/core/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def run(self):
self.context.residual_upscaled_dir + "output_" + get_lexicon_value(6, 1) + ".png",
self.controller)

logger = logging.getLogger(__name__)

last_frame = False
for x in range(1, self.context.frame_count):
########################################
Expand Down Expand Up @@ -157,6 +159,7 @@ def run(self):
frame_previous = current_frame
current_upscaled_residuals = background_frame_load.loaded_image
self.controller.update_frame_count(x)
logger.info("Completed frame: " + str(x) + "/" + str(self.context.frame_count))

self.pipe.kill()

Expand Down Expand Up @@ -201,4 +204,4 @@ def make_merge_image(context: Dandere2xServiceContext, frame_residual: Frame, fr
out_image = fade_image(context, out_image, list_fade)
out_image = pframe_image(context, out_image, frame_previous, frame_residual, list_residual, list_predictive)

return out_image
return out_image
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def __fix_waifu2x_converter_cpp_names(self):
file_names.append("output_" + get_lexicon_value(6, x))

for file in file_names:
dirty_name = self.context.residual_upscaled_dir + file + '_[NS-L' + str(
dirty_name = self.context.residual_upscaled_dir + file + '_[L' + str(
self.context.service_request.denoise_level) + '][x' + str(
self.context.service_request.scale_factor) + '.000000]' + ".png"
self.context.service_request.scale_factor) + '.00]' + ".png"
clean_name = self.context.residual_upscaled_dir + file + ".png"

wait_on_either_file(clean_name, dirty_name)
Expand Down
1 change: 0 additions & 1 deletion src/dandere2x/dandere2xlib/utils/dandere2x_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def wait_on_file(file_string: str):
count += 1
time.sleep(.001)


# for renaming function, break when either file exists
def wait_on_either_file(file_1: str, file_2: str):
logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/dandere2x/dandere2xlib/wrappers/frame/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,4 @@ def create_bleeded_image(self, bleed):
return im_out

def mean(self, other):
return numpy.mean((self.frame - other.frame) ** 2)
return numpy.mean((self.frame - other.frame) ** 2)
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ def main():
print("Total runtime duration:", time.time() - start)


main()
main()