forked from mapbox/robosat
-
Notifications
You must be signed in to change notification settings - Fork 26
/
test.py
45 lines (33 loc) · 1.45 KB
/
test.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
36
37
38
39
40
41
42
43
44
45
from datetime import datetime
import time
import json
from robosat_pink.geoc import RSPtrain, RSPpredict, utils
from app.libs import utils_geom
def train(extent, dataPath, dsPath, epochs=10, map="google", auto_delete=False):
return RSPtrain.main(extent, dataPath, dsPath, epochs, map, auto_delete)
def predict(extent, dataPath, dsPath, map="google", auto_delete=False):
return RSPpredict.main(extent, dataPath, dsPath, map, auto_delete)
if __name__ == "__main__":
# config.toml & checkpoint.pth data directory
# dataPath = "data"
dataPath = "/data/datamodel"
# training dataset directory
startTime = datetime.now()
ts = time.time()
# map extent for training or predicting
#extent = "116.286626640306,39.93972566103653,116.29035683687295,39.942521109411445"
#extent = "104.7170 31.5125 104.7834 31.4430"#mianyang
extent = "116.3094,39.9313,116.3114,39.9323"
# extent = "116.2159,39.7963,116.5240,40.0092"
result = ""
# trainging
# result = train(extent, dataPath, "ds/train_" + str(ts), 1)
# predicting
result = predict(extent, dataPath, "ds/predict_" + str(ts))
# print(result)
# geojson 转 shapefile
building_predcit_path = "ds/predict_" + str(ts)+"/building1_predict.shp"
utils_geom.geojson2shp(result, building_predcit_path)
endTime = datetime.now()
timeSpend = (endTime-startTime).seconds
print("Training or Predicting DONE!All spends:", timeSpend, "seconds!")