-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtrain.py
More file actions
105 lines (77 loc) · 3.11 KB
/
train.py
File metadata and controls
105 lines (77 loc) · 3.11 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# coding=utf-8
import subprocess
from Layer import Layer
from DataBase import DataBase
import os
rootDir = os.path.abspath("") + "/"
wmsUrlTrainSource = "http://localhost:8080/geoserver/sf/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fjpeg&STYLES&LAYERS=sf%3Aflowcount_geometry&tilesOrigin=-180%2C-90&WIDTH=256&HEIGHT=256&SRS=EPSG%3A900913&BBOX=";
wmsUrlTrainTarget = "http://localhost:8080/geoserver/sf/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fjpeg&STYLES&LAYERS=sf%3AlandPolygon5&tilesOrigin=-180%2C-90&WIDTH=256&HEIGHT=256&SRS=EPSG%3A900913&BBOX=";
wmsUrlRoot = "http://123.56.66.184:9092/geoserver/ceshi/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fjpeg&&styles=line&LAYERS=ceshi%3Aflowcount_geometry&tilesOrigin=-180%2C-90&WIDTH=256&HEIGHT=256&SRS=EPSG%3A900913&BBOX=";
layer = Layer(16,rootDir,wmsUrlRoot,wmsUrlTrainSource,wmsUrlTrainTarget)
dataBase = DataBase()
def run(cmd ):
sub = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
sub.wait()
#将原始轨迹导入到flowcount_geometry
def updateToGeometry():
print "UpdateToGeometry开始"
dataBase.deleteAllByIdIsGreaterThan()
dataBase.updateToGeometry()
print "UpdateToGeometry结束"
# 创建训练数据图片
def createTrainTile():
print "Create Image 开始"
start = 0
limit = 1000
while True:
list = dataBase.findTrainPage(start, limit)
if len(list) ==0:
break
for geo in list:
print "id=%d" %(geo[0])
layer.createTrainSourceTile(geo[9], geo[10], geo[11], geo[12])
layer.createTrainTargetTile(geo[9], geo[10], geo[11], geo[12])
start += limit
print "Create Image 结束"
#开始训练
def startTrain(epochs) :
print "开始xunlian图片"
run("python pix2pix.py --mode train --output_dir test/facades_BtoA_train --max_epochs 200 --input_dir /data/official/facades/train --which_direction BtoA --seed 0")
print "DeepCmd结束开始处理图片"
#标记轨迹中要删除的数据
def deepLeaning():
print "DeepLeaning开始"
start = 0
limit = 1000
while True:
list = dataBase.findPage(start, limit)
for geo in list:
print "id=" + geo[0]
isDel = layer.isDelByTrainTestImage(geo)
if isDel:
dataBase.updateTypeById(1, geo[0])
print "删除"
else:
dataBase.updateTypeById(0, geo[0])
print "保留"
print "DeepLeaning结束"
#标记轨迹中要删除的数据
def deepLeaningByDate( date):
print "deepLeaningByDate开始"
date = '2017-11-07'
start = 0
limit = 1000
while True:
list = dataBase.findPageByDate(start, limit, date)
for geo in list:
print "id=" + geo[0]
isDel = layer.isDelByTrainTestImage(geo)
if isDel:
dataBase.updateTypeById(1, geo[0])
print "删除"
else:
dataBase.updateTypeById(0, geo[0])
print "保留"
start += limit
print "deepLeaningByDate结束"
layer.startTrainUnion()