diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9c6b1ec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM pytorch/pytorch:1.0.1-cuda10.0-cudnn7-runtime + +# Install things needed for easygui, tkinter and opencv +RUN apt-get update -y && \ + apt-get install -y build-essential libsm6 libxext6 libxrender-dev libxrender1 libfontconfig1 tk libglib2.0-0 + +RUN pip install --upgrade pip + +ADD . /app + +WORKDIR /app + +RUN pip install -r requirements.txt + +#CMD ["python" "tool_draw.py" "-p" "models/getchu-anime" "-r"] diff --git a/Dockerfile_tkinter b/Dockerfile_tkinter new file mode 100644 index 0000000..d5ce671 --- /dev/null +++ b/Dockerfile_tkinter @@ -0,0 +1,13 @@ +# Slim version of Python +FROM python:3.8.12-slim + +# Download Package Information +RUN apt-get update -y + +# Install Tkinter +RUN apt-get install tk -y + +RUN pip install easygui==0.98.1 +# Commands to run Tkinter application +CMD ["/app/tkinter_app.py"] +ENTRYPOINT ["python3"] diff --git a/README.md b/README.md index af41647..0519621 100644 --- a/README.md +++ b/README.md @@ -211,3 +211,16 @@ Code structure is modified from [Anime-InPainting](https://github.com/youyuge34/ year={2019} } ``` + + +build by `docker build --progress=plain -t pirec .`, run by +`docker run -u=$(id -u $USER):$(id -g $USER) -e DISPLAY=$DISPLAY -e MPLBACKEND='Agg' -v /tmp/.X11-unix:/tmp/.X11-unix:rw --gpus=all pirec python tool_draw.py -p models/getchu-anime -r` + +on windows host, run x server, e.g. https://medium.com/@potatowagon/how-to-use-gui-apps-in-linux-docker-container-from-windows-host-485d3e1c64a3 + + +testing basic python gui stuff before we make this all work: +```bash +docker build -f Dockerfile_tkinter --progress=plain -t tkinter_in_docker . +docker run -u=$(id -u $USER):$(id -g $USER) -e PYTHONIOENCODING=UTF-8 -e DISPLAY=$DISPLAY -e MPLBACKEND='Agg' -v /tmp/.X11-unix:/tmp/.X11-unix:rw --gpus=all pirec python tool_draw.py -p models/getchu-anime -r +``` diff --git a/USAGE.md b/USAGE.md index 0ac9a56..a91daed 100644 --- a/USAGE.md +++ b/USAGE.md @@ -82,7 +82,7 @@ both lead to the awful edges. 2. **Drawing from color domain and edge (Recommended).**
We strongly recommend you to start drawing using this mode. Some anime edges and color domains are provided drawn by myself in `./examples/getchu`. If you use examples from `./examples/getchu`, you need to run the corresponding command: ```bash - python tool_draw.py -p models/getchu-anime -r + python tool_draw.py -p models/getchu-anime -r ``` You can also get more edges and color domains by yourself using the **Command Line Mode** above. The testing results contain extracted edges and color domains by default (`DEBUG: 1` in `config.yml`). If you are not interested in the edges and color domains drawn by myself, using the edges and color domains from testing results may be a good choice. diff --git a/requirements.txt b/requirements.txt index ee7ea7e..6353478 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ pyaml future==0.16.0 scikit-image pyparsing +torchvision==0.2.2 diff --git a/tkinter_app.py b/tkinter_app.py new file mode 100644 index 0000000..12c99ba --- /dev/null +++ b/tkinter_app.py @@ -0,0 +1,19 @@ +import tkinter as tk + +from easygui import * +# Tkinter Window +root_window = tk.Tk() + +# Window Settings +root_window.title('Application Title') +root_window.geometry('300x100') +root_window.configure(background = '#353535') + +# Text +tk.Label(root_window, text='Hello World', fg='White', bg='#353535').pack() + +# Exit Button +tk.Button(root_window, text='Exit', width=10, command=root_window.destroy).pack() + +# Main loop +root_window.mainloop() \ No newline at end of file diff --git a/tool_draw.py b/tool_draw.py index 48e36f4..1413083 100644 --- a/tool_draw.py +++ b/tool_draw.py @@ -36,12 +36,11 @@ =============================================================================== """ -# Python 2/3 compatibility -from __future__ import print_function - import argparse import glob +# we need to import tkinter before easygui, because reasons https://stackoverflow.com/questions/66355637/pycharm-error-with-easygui-no-module-named-global-state +import tkinter from easygui import * import numpy as np import cv2 as cv