Skip to content

Commit

Permalink
Build script update and windows adaption (#129)
Browse files Browse the repository at this point in the history
* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* ignore generated files

* Homepage enhancements

upgraded bootstrap to 3.3.7
changed to cloudflare for less domain resolving
remove unused DOMs
better reponsive design for mobile phones
resized origin and output img size

* changed to two spaces for better merging

* remove obsoleted styles

* chase master

* remove unused import, fix errors

* remove unused import

* cater for other application extension
add gimpDaemon
add gitignore
generalize platform detection
issue #81

* add information of Gimp plugin

* move images into image folder

* add /images/favicon.ico

* Update browserconfig.xml

* Update manifest.json

* backup squash needed (#13) (#14)

* Use blob format

* Use Bootstrap CDN

* Fix HTML indent

* Fix for HTML5 format

* Remove unuse ID

* Rewrite by Bootstrap

* Fix label

* Add twitter timeline

* Add Google Analytics

* Remove min image

* Reduce memory usage

* Remove save

* fix english

* Use async memcopy

* Use cupy relu

* Update README.md

Added Installation Guide.

* Change Downloads URL to be absolute rather than relative

* Update README.md

delete pillow from requirement
add okuta and ofk in Acknowledgements

* move root to top

* fix move root bug & readme

* Use RGB

* Add file check

* Remove PIL import

* fix English

* update limit file size
read new js

* fix typo

* disable ref image chaching

* add return false at post info lack

* Fix indent

* Fix quote

* Remove set_line_url

* Remove interactive mode

* Move background load callback

* Add ajax request function

* Use ajax event

* Expand ajax event

* Move wPaint canvas getter method

* Remove FileReader

* Change to implementation that prev_image_id is unnecessary

* Change blob reader from canvas base

* Add error status

* Default submit button disabled

* Default img_pane hidden

* Fix column resizing

* add escap in str

* remove line chache ( again

* Change anchor target

* Add special thanks links

* Prevent NameError

* Add Access-Control-Allow-Origin header

* Add random origin

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* Fix typo

* Fix shit bugs

* fix syntax errer

* add folder keep

* add debug servr to CROS

* revert debug

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Added Canvas toBlob polyfill

* added windows OS detection and cv2 detection (#48)

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* move icons to nav bar

* add log & favicon

* change size of logo

* update upload js problem

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* Fix for #34 + #54 (#54)

* Added GPU requirement (#34)

* More robust path finding for issue #55

* Forgot omitting "x86" for 32-bit system

* get UCRT var by winreg (#57)

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* step by step instructions on how to install windows with visual studio (#61)

* step by step instructions on how to install windows with visual studio

* Testing with Anaconda 4.3.0 with Python 3.5

* move install guide to wiki page

* ignore generated files

* Homepage enhancements

upgraded bootstrap to 3.3.7
changed to cloudflare for less domain resolving
remove unused DOMs
better reponsive design for mobile phones
resized origin and output img size

* changed to two spaces for better merging

* remove obsoleted styles

* Enhance homepage layout + add ignore generated imagefiles (#65)

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* ignore generated files

* Homepage enhancements

upgraded bootstrap to 3.3.7
changed to cloudflare for less domain resolving
remove unused DOMs
better reponsive design for mobile phones
resized origin and output img size

* changed to two spaces for better merging

* remove obsoleted styles

* IE11 Colorize Button Disable problem (#66)

□operation
1.scketch File choice
2.paints_chainer.js#blobUrlToBlob
xhr.responseType = 'blob'
→InvalidStateError

□environment
JP Win10 IE11 (11.576.14393)

* modify design & add PFN logo

* modify space for paint menu

* allow CROS for error

* remove unused variable (#64)

* chase master

* make Palettle more suitable for generation (#71)

* Added Saturation Mapper to Palettle

* add back version number for wColorPicker

* update palette mapper
update wColorPickerSaturationValueMapper to enable finer tuning

* remove debug message

* add new pallet index

* skintoneColors Palets (#74)

UI wColorPicker Palets Append
#58

* remove unused import, fix errors

* remove unused import

* Favicons and browser compatibility fixes (#75)

* Update GitHub links to point to new pfnet repository location

* Fix favicon behaviour and remove un-needed fake hrefs

* Made alpha channel warning clearer

* Removed un-needed link

* Specify link/script types

* Fix for wPaint not loading in Firefox

* Remove duplicate link rel

* Fix for PaintsChainer not working in IE10

* Improve error message when image is too large to colorize

* CSS before JS so the files can be loaded in parallel

* Improved favicon support for various browsers and OSes

* Optimize PNGs

* Remove unused import, fix errors (#76)

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* ignore generated files

* Homepage enhancements

upgraded bootstrap to 3.3.7
changed to cloudflare for less domain resolving
remove unused DOMs
better reponsive design for mobile phones
resized origin and output img size

* changed to two spaces for better merging

* remove obsoleted styles

* chase master

* remove unused import, fix errors

* remove unused import

* ColorPicker Selected HistoryItem max 8. (#78)

max Item defined & HistoryColorsList
→ wColorPicker.min $.fn.wColorPicker.selectedHistoryColors

* improve to remain aspect ratio from src img

* cater for other application extension
add gimpDaemon
add gitignore
generalize platform detection
issue #81

* add information of Gimp plugin

* fix bug of image size

* move images into image folder

* add /images/favicon.ico

* Update browserconfig.xml

* Update manifest.json

* Update README.md

* Update README.md

* Cater for adapters (#83)

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* ignore generated files

* Homepage enhancements

upgraded bootstrap to 3.3.7
changed to cloudflare for less domain resolving
remove unused DOMs
better reponsive design for mobile phones
resized origin and output img size

* changed to two spaces for better merging

* remove obsoleted styles

* chase master

* remove unused import, fix errors

* remove unused import

* cater for other application extension
add gimpDaemon
add gitignore
generalize platform detection
issue #81

* add information of Gimp plugin

* move images into image folder

* add /images/favicon.ico

* Update browserconfig.xml

* Update manifest.json

* Improve image convert (#89)

* Server process split (#90)

* split post and paint server

* implement servers

* backup squash needed (#13) (#15)

* Use blob format

* Use Bootstrap CDN

* Fix HTML indent

* Fix for HTML5 format

* Remove unuse ID

* Rewrite by Bootstrap

* Fix label

* Add twitter timeline

* Add Google Analytics

* Remove min image

* Reduce memory usage

* Remove save

* fix english

* Use async memcopy

* Use cupy relu

* Update README.md

Added Installation Guide.

* Change Downloads URL to be absolute rather than relative

* Update README.md

delete pillow from requirement
add okuta and ofk in Acknowledgements

* move root to top

* fix move root bug & readme

* Use RGB

* Add file check

* Remove PIL import

* fix English

* update limit file size
read new js

* fix typo

* disable ref image chaching

* add return false at post info lack

* Fix indent

* Fix quote

* Remove set_line_url

* Remove interactive mode

* Move background load callback

* Add ajax request function

* Use ajax event

* Expand ajax event

* Move wPaint canvas getter method

* Remove FileReader

* Change to implementation that prev_image_id is unnecessary

* Change blob reader from canvas base

* Add error status

* Default submit button disabled

* Default img_pane hidden

* Fix column resizing

* add escap in str

* remove line chache ( again

* Change anchor target

* Add special thanks links

* Prevent NameError

* Add Access-Control-Allow-Origin header

* Add random origin

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* Fix typo

* Fix shit bugs

* fix syntax errer

* add folder keep

* add debug servr to CROS

* revert debug

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Added Canvas toBlob polyfill

* added windows OS detection and cv2 detection (#48)

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* move icons to nav bar

* add log & favicon

* change size of logo

* update upload js problem

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* Fix for #34 + #54 (#54)

* Added GPU requirement (#34)

* More robust path finding for issue #55

* Forgot omitting "x86" for 32-bit system

* get UCRT var by winreg (#57)

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* step by step instructions on how to install windows with visual studio (#61)

* step by step instructions on how to install windows with visual studio

* Testing with Anaconda 4.3.0 with Python 3.5

* move install guide to wiki page

* ignore generated files

* Homepage enhancements

upgraded bootstrap to 3.3.7
changed to cloudflare for less domain resolving
remove unused DOMs
better reponsive design for mobile phones
resized origin and output img size

* changed to two spaces for better merging

* remove obsoleted styles

* Enhance homepage layout + add ignore generated imagefiles (#65)

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* ignore generated files

* Homepage enhancements

upgraded bootstrap to 3.3.7
changed to cloudflare for less domain resolving
remove unused DOMs
better reponsive design for mobile phones
resized origin and output img size

* changed to two spaces for better merging

* remove obsoleted styles

* IE11 Colorize Button Disable problem (#66)

□operation
1.scketch File choice
2.paints_chainer.js#blobUrlToBlob
xhr.responseType = 'blob'
→InvalidStateError

□environment
JP Win10 IE11 (11.576.14393)

* modify design & add PFN logo

* modify space for paint menu

* allow CROS for error

* remove unused variable (#64)

* chase master

* make Palettle more suitable for generation (#71)

* Added Saturation Mapper to Palettle

* add back version number for wColorPicker

* update palette mapper
update wColorPickerSaturationValueMapper to enable finer tuning

* remove debug message

* add new pallet index

* skintoneColors Palets (#74)

UI wColorPicker Palets Append
#58

* remove unused import, fix errors

* remove unused import

* Favicons and browser compatibility fixes (#75)

* Update GitHub links to point to new pfnet repository location

* Fix favicon behaviour and remove un-needed fake hrefs

* Made alpha channel warning clearer

* Removed un-needed link

* Specify link/script types

* Fix for wPaint not loading in Firefox

* Remove duplicate link rel

* Fix for PaintsChainer not working in IE10

* Improve error message when image is too large to colorize

* CSS before JS so the files can be loaded in parallel

* Improved favicon support for various browsers and OSes

* Optimize PNGs

* Remove unused import, fix errors (#76)

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* ignore generated files

* Homepage enhancements

upgraded bootstrap to 3.3.7
changed to cloudflare for less domain resolving
remove unused DOMs
better reponsive design for mobile phones
resized origin and output img size

* changed to two spaces for better merging

* remove obsoleted styles

* chase master

* remove unused import, fix errors

* remove unused import

* ColorPicker Selected HistoryItem max 8. (#78)

max Item defined & HistoryColorsList
→ wColorPicker.min $.fn.wColorPicker.selectedHistoryColors

* improve to remain aspect ratio from src img

* cater for other application extension
add gimpDaemon
add gitignore
generalize platform detection
issue #81

* add information of Gimp plugin

* fix bug of image size

* move images into image folder

* add /images/favicon.ico

* Update browserconfig.xml

* Update manifest.json

* Update README.md

* Update README.md

* Cater for adapters (#83)

* add images folder to prevent no No such file or directory Error

* time logger t should be sharing with ret_result

* fix wrong color

* detect cv2 version to select colorspace

* Update cgi_exe.py

* used .keep

* used .keep

* used .keep

* used .keep

* Enhancment for Windows Detection
add winreg detection for windows UCRT
Fix wrong lib path for UCRT

* making windows arch independent

* better debugging messages

* ignore generated files

* Homepage enhancements

upgraded bootstrap to 3.3.7
changed to cloudflare for less domain resolving
remove unused DOMs
better reponsive design for mobile phones
resized origin and output img size

* changed to two spaces for better merging

* remove obsoleted styles

* chase master

* remove unused import, fix errors

* remove unused import

* cater for other application extension
add gimpDaemon
add gitignore
generalize platform detection
issue #81

* add information of Gimp plugin

* move images into image folder

* add /images/favicon.ico

* Update browserconfig.xml

* Update manifest.json

* Improve image convert (#89)

* Server process split (#90)

* split post and paint server

* implement servers

* normalize colorize

normalized colorize function
trim gimpDaemon
added output format for cataring gimpDaemon

* pylintrc

* resolve conflict

* resolve conflict

* paragraph

* init stand-alone compilation

* move out model folders

* update setup for auto build

* Set theme jekyll-theme-cayman

* move environment warning to batches
add installation messages

* enhance build script to support python 3.6 and current paintschainer

* remove io page config
  • Loading branch information
abbychau authored and taizan committed Aug 5, 2017
1 parent 1c14f9e commit 3c812be
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 66 deletions.
4 changes: 3 additions & 1 deletion .gitignore
@@ -1,3 +1,5 @@
.idea
.pyc
__pycache__
__pycache__
build/*
debug.log
15 changes: 15 additions & 0 deletions .pylintrc
@@ -0,0 +1,15 @@
[MASTER]
init-hook='import sys; sys.path.append("./cgi-bin/paint_x2_unet"); sys.path.append("./cgi-bin/helpers")'
extension-pkg-whitelist=numpy,cv2
[TYPECHECK]

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=numpy,cv2

# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set). This supports can work
# with qualified names.
ignored-classes=numpy,cv2
39 changes: 5 additions & 34 deletions cgi-bin/helpers/platformAdapter.py
@@ -1,40 +1,11 @@
class OSHelper:

def detect_environment():
import os
if os.name == 'nt':
import winreg
import glob
import platform
print("Windows Environment")
try:
ARCH_ARR = ["arm64", "arm", "x64", "x86"]
ARCH_INDEX0 = 0 if ("arm" in platform.machine().lower()) else 2
ARCH_INDEX1 = 0 if ("64" in platform.architecture()[0]) else 1
ARCH_NAME = ARCH_ARR[ARCH_INDEX0 + ARCH_INDEX1]
_ = r'SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0'
WK_WINREG_KEY = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE, _, 0, winreg.KEY_READ)
WK_PATH, _ = winreg.QueryValueEx(WK_WINREG_KEY, 'InstallationFolder')
winreg.CloseKey(WK_WINREG_KEY)

WK_LIB_ROOT = max(glob.glob(WK_PATH + '\\Lib\\*'))
WK_INCLUDE_ROOT = max(glob.glob(WK_PATH + '\\Include\\*'))
WK_INCLUDE = WK_INCLUDE_ROOT + r'\ucrt'
WK_LIB_UM = WK_INCLUDE_ROOT + r'\um'
WK_LIB_UCRT64 = WK_LIB_ROOT + "\\ucrt\\" + ARCH_NAME
if not 'INCLUDE' in os.environ:
print('Include Path INCLUDE for Windows Kit not assigned. Please edit and use run_python.bat or run_exe.bat.')

if os.path.isdir(WK_INCLUDE):
os.environ['INCLUDE'] = WK_INCLUDE
else:
print('Include Path for Windows Kit not exists: ' + WK_INCLUDE)

if os.path.isdir(WK_LIB_UM) and os.path.isdir(WK_LIB_UCRT64):
os.environ['LIB'] = WK_LIB_UM + ';' + WK_LIB_UCRT64
print("Path Found.")
else:
if os.path.isdir(WK_LIB_UM):
print('Lib Path(Windows Kit UCRT64) not exists: ' + WK_LIB_UCRT64)
else:
print('Lib Path(Windows Kit UM) not exists: ' + WK_LIB_UM)
except WindowsError:
print('Cannot get Windows Kit Library path from WINREG')
if not 'LIB' in os.environ:
print('Include Path LIB for Windows Kit is not assigned. Please edit and use run_python.bat or run_exe.bat.')
13 changes: 9 additions & 4 deletions cgi-bin/paint_x2_unet/cgi_exe.py
Expand Up @@ -3,14 +3,14 @@

import numpy as np
import chainer
from chainer import cuda, serializers, Variable # , optimizers, training
import cv2

import os.path
#import chainer.functions as F
#import chainer.links as L
#import six
#import os

from chainer import cuda, serializers, Variable # , optimizers, training
#from chainer.training import extensions
#from train import Image2ImageDataset
from img2imgDataset import ImageAndRefDataset
Expand All @@ -31,6 +31,11 @@ def __init__(self, gpu=0):
self.gpu = gpu
self._dtype = np.float32

if not os.path.isfile("./models/unet_128_standard"):
print("./models/unet_128_standard not found. Please download them from http://paintschainer.preferred.tech/downloads/")
if not os.path.isfile("./models/unet_512_standard"):
print("./models/unet_512_standard not found. Please download them from http://paintschainer.preferred.tech/downloads/")

print("load model")
if self.gpu >= 0:
cuda.get_device(self.gpu).use()
Expand All @@ -45,11 +50,11 @@ def __init__(self, gpu=0):
#serializers.load_npz("./cgi-bin/wnet/models/model_cnn_128_df_4", cnn_128)
#serializers.load_npz("./cgi-bin/paint_x2_unet/models/model_cnn_128_f3_2", cnn_128)
serializers.load_npz(
"./cgi-bin/paint_x2_unet/models/unet_128_standard", self.cnn_128)
"./models/unet_128_standard", self.cnn_128)
#serializers.load_npz("./cgi-bin/paint_x2_unet/models/model_cnn_128_ua_1", self.cnn_128)
#serializers.load_npz("./cgi-bin/paint_x2_unet/models/model_m_1.6", self.cnn)
serializers.load_npz(
"./cgi-bin/paint_x2_unet/models/unet_512_standard", self.cnn_512)
"./models/unet_512_standard", self.cnn_512)
#serializers.load_npz("./cgi-bin/paint_x2_unet/models/model_p2_1", self.cnn)
#serializers.load_npz("./cgi-bin/paint_x2_unet/models/model_10000", self.cnn)
#serializers.load_npz("./cgi-bin/paint_x2_unet/models/liner_f", lnn)
Expand Down
4 changes: 4 additions & 0 deletions models/.gitignore
@@ -0,0 +1,4 @@
*
*/
!.gitignore
!.keep
1 change: 1 addition & 0 deletions models/.keep
@@ -0,0 +1 @@
keep
22 changes: 22 additions & 0 deletions run_dependency_test.bat
@@ -0,0 +1,22 @@
@echo off

SET path=%~dp0;%~dp0bin;%path%

SET vcvarsall="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"

if exist %vcvarsall% (
call %vcvarsall% amd64
) else (
ECHO Microsoft Visual C++ Build Tools 2015 is not found, please install it via http://landinghub.visualstudio.com/visual-cpp-build-tools
)



SET LIB=%~dp0lib;%~dp0lib\x64;%LIB%
SET INCLUDE=%~dp0include;%INCLUDE%
SET LIBPATH=%~dp0lib;%~dp0lib\x64;%LIBPATH%

WHERE nvcc.exe
IF %ERRORLEVEL% NEQ 0 ECHO nvcc not found, please install CUDA via https://developer.nvidia.com/cuda-downloads


5 changes: 5 additions & 0 deletions run_exe.bat
@@ -0,0 +1,5 @@
@echo off

call run_dependency_test.bat

server.exe
5 changes: 5 additions & 0 deletions run_python.bat
@@ -0,0 +1,5 @@
@echo off

call run_dependency_test.bat

python server.py
53 changes: 26 additions & 27 deletions server.py
Expand Up @@ -2,7 +2,6 @@

import http.server

import os
import sys
import time
import re
Expand Down Expand Up @@ -142,29 +141,29 @@ def ret_result(self, success):
self.log_t()

# set args

parser = argparse.ArgumentParser(
description='chainer line drawing colorization server')
parser.add_argument('--gpu', '-g', type=int, default=0,
help='GPU ID (negative value indicates CPU)')
parser.add_argument('--mode', '-m', default="stand_alone",
help='set process mode')
# other mode "post_server" "paint_server"

parser.add_argument('--port', '-p', type=int, default=8000,
help='using port')
parser.add_argument('--debug', dest='debug', action='store_true')
parser.set_defaults(feature=False)

parser.add_argument('--host', '-ho', default='localhost',
help='using host')

args = parser.parse_args()

if( args.mode == "stand_alone" or args.mode == "paint_server" ):
print('GPU: {}'.format(args.gpu))
painter = cgi_exe.Painter(gpu=args.gpu)

httpd = http.server.HTTPServer((args.host, args.port), MyHandler)
print('serving at', args.host, ':', args.port, )
httpd.serve_forever()
if "__main__" in __name__:
parser = argparse.ArgumentParser(
description='chainer line drawing colorization server')
parser.add_argument('--gpu', '-g', type=int, default=0,
help='GPU ID (negative value indicates CPU)')
parser.add_argument('--mode', '-m', default="stand_alone",
help='set process mode')
# other mode "post_server" "paint_server"

parser.add_argument('--port', '-p', type=int, default=8000,
help='using port')
parser.add_argument('--debug', dest='debug', action='store_true')
parser.set_defaults(feature=False)

parser.add_argument('--host', '-ho', default='localhost',
help='using host')

args = parser.parse_args()

if args.mode == "stand_alone" or args.mode == "paint_server":
print('GPU: {}'.format(args.gpu))
painter = cgi_exe.Painter(gpu=args.gpu)

httpd = http.server.HTTPServer((args.host, args.port), MyHandler)
print('serving at', args.host, ':', args.port, )
httpd.serve_forever()
93 changes: 93 additions & 0 deletions setup.py
@@ -0,0 +1,93 @@
'''
This is the setup script for cxfreeze
cxfreeze does not support pkg_resource, to compile,
please modify chainer to hardcode version name and remove pkg_resources
track cxfreeze branch https://github.com/grahamrjuk/cx_Freeze/tree/process_import
for process support
Process.pyc is to be renamed to process.pyc
cupy testing has to be modified to prevent pkg_resources require function
'''
#cx_freeze Dependencies
import sys

#Post-process
import os
import shutil

from cx_Freeze import setup, Executable
sys.path.append('./cgi-bin/paint_x2_unet')
sys.path.append('./cgi-bin/helpers')

# Dependencies fine tuning

MODS = [
'cupy',
'chainer',
'numpy.core._methods', 'numpy.lib.format',
'cgi_exe',
'platformAdapter',
"appdirs",
"packaging.requirements"
]
BUILD_OPTIONS = {"packages": ["os"], "excludes": ["tkinter"], 'includes': MODS}


# GUI applications require a different base on Windows (the default is for a console application).
BASE = None
#if sys.platform == "win32":
# base = "Win32GUI"

setup(
name="PaintsChainer",
version="0.1",
description="PaintsChainer Executable Version!",
options={"build_exe": BUILD_OPTIONS},
executables=[Executable("server.py", base=BASE)]
)

#POST building patching
def copytree(src, dst, symlinks=False, ignore=None):
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)

v = sys.version_info
os.chdir("./build/exe.win-amd64-"+str(v[0])+"."+str(v[1])+"/")
#todo: other platform path

undetected_dirs = ["wPaint", "models", "images","fonts","css"]
for directory in undetected_dirs:
try:
shutil.copytree(os.getcwd()+"/../../"+directory, os.getcwd()+"/"+directory)
except:
print("Folder is created before.")

undetected_files = [
"index.html",
"index_ja.html",
"index_zh.html",
"howto.html",
"howto_ja.html",
"howto_zh.html",
"paints_chainer.js",
"manifest.json",
"main.css",
"LICENSE",
"browserconfig.xml",
"run_dependency_test.bat",
"run_exe.bat"
]
for file in undetected_files:
shutil.copyfile(os.getcwd()+"/../../"+file, os.getcwd()+"/"+file)

os.rename("multiprocessing/Process.pyc", "multiprocessing/process.pyc")

print("All Done.")

0 comments on commit 3c812be

Please sign in to comment.