-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert_swt.py
More file actions
74 lines (40 loc) · 1.25 KB
/
Copy pathconvert_swt.py
File metadata and controls
74 lines (40 loc) · 1.25 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# coding: utf-8
# In[1]:
from os import listdir
import shlex, subprocess
# In[2]:
import xml.etree.ElementTree as ET
import pickle
import os
from os import listdir, getcwd
from os.path import join
# In[3]:
import json
# In[4]:
import numpy as np
import math
import shutil
import os.path
# In[5]:
def get_swt(file_name,data_path,swt_path):
if file_name[-4:] not in ['.png', '.jpg']:
return
#modify the path to where your stroke-width-transformation package is
command_line = 'python ./stroke-width-transform/main.py ' + data_path + file_name + ' ' + swt_path + file_name
print(command_line)
args = command_line.split(' ')
print(args[-1][:-2])
p = subprocess.Popen(args,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
print(p.communicate())
from joblib import Parallel, delayed
# In[13]:
def load_files(img_dir,out_dir):
img_dir = img_dir[2:]
out_dir = out_dir[3:]
print(img_dir)
print(out_dir)
file_list = listdir(img_dir)
Parallel(n_jobs=32)(delayed(get_swt)(file_list[i],img_dir,out_dir) for i in range(len(file_list)))
#load_files( input folder, output folder)
load_files( ' ./data/pipeline_data/Open_Access/Bar/', ' ./Open_Access_swt/')