forked from pfnet/PaintsChainer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gimpDaemon.py
35 lines (25 loc) · 808 Bytes
/
gimpDaemon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
#This Daemon is for Gimp Plugin updated in https://github.com/opaai/PaintsChainer-Gimp
#`python gimpDaemon.py`
import sys
import os
sys.path.append('./cgi-bin/paint_x2_unet')
import cgi_exe
sys.path.append('./cgi-bin/helpers')
from platformAdapter import OSHelper
class GimpDaemon:
def __init__(self, gpu=0):
print("start")
OSHelper.detect_environment()
self.painter = cgi_exe.Painter(gpu=gpu)
def run(self, id_str):
pid_path = "./run/" + id_str + ".pid"
if os.path.exists(pid_path):
self.painter.colorize(id_str,step='C',colorize_format="png")
os.remove(pid_path)
if __name__ == '__main__':
import time
daemon = GimpDaemon(gpu=0)
while True:
daemon.run('main')
time.sleep(1)