Skip to content

Commit c6a66d0

Browse files
authored
Merge pull request #250 from dmsl/develop
Anyplace v3.4 Release (June 2018)
2 parents 20fce6b + b3afc5f commit c6a66d0

38 files changed

+1487
-374
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AnyPlace v3.3 (April 2018)
1+
# AnyPlace v3.4 (June 2018)
22

33
[![Join the chat at https://gitter.im/dmsl/anyplace](https://badges.gitter.im/dmsl/anyplace.svg)](https://gitter.im/dmsl/anyplace?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44

server/anyplace_tiler/anyplace-tiler.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ def convertPaddedImage( filename, newW, newH, outputName ):
136136

137137

138138
def resizeImage( srcImage, zoomOriginal, zoomCurrent, destImage ):
139-
resRatio = 50#100.0 / (2 ** (zoomOriginal-zoomCurrent) )
139+
rasRatio=100
140+
if(zoomOriginal!=zoomCurrent):
141+
resRatio = 100.0 / (2 ** (zoomOriginal-zoomCurrent) )
142+
print(resRatio)
140143
dim = subprocess.Popen(["convert", srcImage, "-resize", ('%d%%'%(resRatio)), destImage ], stdout=subprocess.PIPE).communicate()[0]
141144

142145
#####################################################################################
@@ -174,7 +177,7 @@ def fixTileStructure( fixTileStructureScript, ImageFileName ):
174177
def main( argv ):
175178
print( argv )
176179

177-
if(7 != len(sys.argv)):
180+
if(8 != len(sys.argv)):
178181
print(usage())
179182
sys.exit(1)
180183

@@ -184,6 +187,7 @@ def main( argv ):
184187
OriginalZoom = int(sys.argv[4])
185188
ToZoom = int(sys.argv[5])
186189
ImageFileName = sys.argv[6]
190+
UploadZoom = int(sys.argv[7])
187191
ImageDirName = os.path.dirname(os.path.realpath(ImageFileName))
188192

189193
fixTileStructureScript = str(ScriptsDir + '/fix-tile-structure.sh')
@@ -195,13 +199,13 @@ def main( argv ):
195199

196200
# we will run the procedure for every zoom level in range [OriginalZoom..ToZoom]
197201
for currentZoom in range( OriginalZoom, (ToZoom-1), -1 ):
198-
202+
currentImage=ImageFileName
199203
# call the command to resize the image according to the zoom level
200-
if( currentZoom == OriginalZoom ):
204+
if( currentZoom == UploadZoom ):
201205
currentImage=ImageFileName
202206
else:
203207
newName=(('%s-z%d.png') % (CURRENT_ZOOM_IMAGE_NAME, currentZoom))
204-
resizeImage(currentImage, OriginalZoom, currentZoom, newName)
208+
resizeImage(currentImage, UploadZoom, currentZoom, newName)
205209
currentImage = newName
206210

207211
# get the Image top left world coords

server/anyplace_tiler/start-anyplace-tiler.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ check_requirements(){
6262

6363
##################### MAIN
6464

65-
[[ "$#" != "4" ]] && usage
65+
[[ "$#" != "5" ]] && usage
6666

6767
[[ "$4" != "-ENLOG" && "$4" != "-DISLOG" ]] && usage
6868

@@ -96,16 +96,17 @@ echo "Image: $imagePath"
9696

9797
ImageLatitude="$2"
9898
ImageLongitude="$3"
99-
ZoomOriginal=21
99+
ZoomOriginal=22
100100
ZoomDestination=19
101101
ImageFileName="$imagePath"
102+
UploadZoom="$5"
102103

103104

104105
echo
105106
echo ":: Starting anyplace-tiler ..."
106107
anyTiler="$scriptsDir/anyplace-tiler.py"
107108

108-
python "$anyTiler" "$scriptsDir" "$ImageLatitude" "$ImageLongitude" "$ZoomOriginal" "$ZoomDestination" "$ImageFileName"
109+
python "$anyTiler" "$scriptsDir" "$ImageLatitude" "$ImageLongitude" "$ZoomOriginal" "$ZoomDestination" "$ImageFileName" "$UploadZoom"
109110
check_for_errors
110111

111112
echo

server/app/acces/ACCES_RBF.scala

+22-13
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ class AccesRBF(
7171
}
7272
val _selected_features: IndexedSeq[Int] = select_features(Y=Y, Y_min=_Y_min, Y_max=_Y_max,
7373
cut_k_features.getOrElse(Y.cols), drop_redundant = drop_redundant_features)
74-
val _Y_normed = normalize_Y(
75-
Y=(Y(::, _selected_features)).toDenseMatrix,
76-
Y_means=(_Y_means(_selected_features)).toDenseVector)
74+
// val _Y_normed = normalize_Y(
75+
// Y=(Y(::, _selected_features)).toDenseMatrix,
76+
// Y_means=(_Y_means(_selected_features)).toDenseVector)
77+
val _Y_normed = normalize_Y( Y=Y, Y_means=_Y_means)
7778

7879
println("x_min", _X_min)
7980
println("x_max", _X_max)
@@ -113,7 +114,8 @@ class AccesRBF(
113114

114115

115116
def select_features(Y: DenseMatrix[Double], Y_min: DenseVector[Double], Y_max: DenseVector[Double],
116-
k_features: Int, drop_redundant: Boolean = true): IndexedSeq[Int] = {
117+
k_features: Int, drop_redundant: Boolean = true,
118+
rtol: Double = 0.01, atol: Double = 0.00001): IndexedSeq[Int] = {
117119
if (k_features <= 0) { throw new IllegalArgumentException("k_features must be positive")}
118120
val k = if (k_features > Y.cols) Y.cols else k_features
119121

@@ -122,7 +124,7 @@ class AccesRBF(
122124
println("select_features: Y_max", Y_max)
123125
val scores = DenseVector.zeros[Double](k)
124126
for (i <- 0 to k - 1) {
125-
scores(i) = meanAndVariance(Y(::, i)).variance / (Y_max(i) - Y_min(i))
127+
scores(i) = sqrt(meanAndVariance(Y(::, i)).variance) / (Y_max(i) - Y_min(i))
126128
}
127129
var inds = argsort(scores).reverse
128130
println("scores", scores)
@@ -134,35 +136,41 @@ class AccesRBF(
134136
for (i <- 0 to inds.length - 1) {
135137
val ind = inds(i)
136138
println("ind", ind, "var", scores(i))
137-
if (~=(scores(ind), 0.0, 0.00001)) {
139+
if (~=(scores(ind), 0, atol) || scores(ind) / scores(inds(0)) < rtol) {
138140
inds = inds.slice(0, i)
139141
println(inds)
140142
break
141143
}
144+
// if (~=(scores(ind), 0.0, 0.00001)) {
145+
// inds = inds.slice(0, i)
146+
// println(inds)
147+
// break
148+
// }
142149
}
143150
}
144151
}
145152
inds = inds.slice(0, min(inds.length, k))
146153
inds = inds.sorted
147154

148-
println("new inds", inds)
149-
println("new scores", scores(inds).toDenseVector)
155+
// println("new inds", inds)
156+
// println("new scores", scores(inds).toDenseVector)
150157

151158
return inds
152159
}
153160

154161
def fit_gpr(estimate: Boolean = false, use_default_params: Boolean = false) = {
155162
val X: DenseMatrix[Double] = this._X_normed
156163
val Y: DenseMatrix[Double] = this._Y_normed(::, this._selected_features).toDenseMatrix
157-
val X_min = this._X_min
158-
val X_max = this._X_max
164+
val X_min = min(X(::, *)).t
165+
val X_max = max(X(::, *)).t
159166
val Y_min = this._Y_min(this._selected_features).toDenseVector
160167
val Y_max = this._Y_max(this._selected_features).toDenseVector
161168

162169
val n = X.rows
163170
val d = X.cols
164171
val m = Y.cols
165172

173+
println("X.rows, Y.rows: ", X.rows, Y.rows)
166174
assert(X.rows == Y.rows)
167175

168176
if(estimate) {
@@ -176,7 +184,7 @@ class AccesRBF(
176184
println("use default parameters", use_default_params)
177185

178186
val sf_0: DenseVector[Double] = 0.01 * (Y_max - Y_min)
179-
val l_0: DenseVector[Double] = 0.1 * DenseVector.ones[Double](m)
187+
val l_0: DenseVector[Double] = 0.1 * breeze.linalg.norm(X_max - X_min) * DenseVector.ones[Double](m)
180188
val noise_0: DenseVector[Double] = sf_0.copy
181189

182190
println("Default parameters")
@@ -264,6 +272,7 @@ class AccesRBF(
264272
}
265273

266274
def predict_gpr_scalar(X: DenseMatrix[Double], component: Int): (DenseVector[Double],DenseVector[Double]) = {
275+
// WRONG INDEXING HERE, component for M and data is not the same, need to fix
267276
if (!this._selected_features.contains(component)) {
268277
throw new IllegalArgumentException("Feature %d is ignored".format(component))
269278
}
@@ -411,7 +420,7 @@ class AccesRBF(
411420
// println("x", x)
412421
// println("x_normed", x_normed)
413422
val X_normed = this._X_normed
414-
val Y_normed = this._Y_normed
423+
val Y_normed = this._Y_normed(::, this._selected_features).toDenseMatrix
415424
val m = Y_normed.cols
416425
val n = X_normed.rows
417426
val d = X_normed.cols
@@ -420,7 +429,7 @@ class AccesRBF(
420429
// var FIM = DenseMatrix.zeros[Double](d,d)
421430
val FIMs: Array[DenseMatrix[Double]] = Array.ofDim[DenseMatrix[Double]](this._selected_features.length)
422431

423-
for (i <- 0 to this._selected_features.length - 1) {
432+
for (i <- 0 until Y_normed.cols) {
424433
var FIM = DenseMatrix.zeros[Double](d,d)
425434
val M = this._Ms.get(i)
426435
val gamma = this._gammas.get(i)

0 commit comments

Comments
 (0)