Skip to content

Commit

Permalink
wrong data removed
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimanyudubey committed Feb 24, 2017
1 parent 5fbff0b commit 2692774
Show file tree
Hide file tree
Showing 72 changed files with 3,014,975 additions and 1 deletion.
2 changes: 1 addition & 1 deletion code/generate_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
for i,point_set in enumerate(datapoints):
plt.scatter(point_set[:,0],point_set[:,1],c=colors[i],s=args['size'],lw = 0)

plt.savefig(args['output'],dpi=3000)
plt.savefig(args['output'],dpi=300)

65 changes: 65 additions & 0 deletions code/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import numpy as np
import sys
import glob
import os
import random
from multiprocessing import Pool

def process_images(args)
mesh_city_name = args[0]
score_file_name = args[1]
fno = args[2]

images = []

with open(score_file_name, 'r') as f:
for line in f:
l2 = line.strip().split(',')
sco = float(l2[1])
lat = float(l2[0].split('_')[0])
lon = float(l2[0].split('_')[1])
images.append([lat, lon, sco])

points = [x[:2] for x in images]

mesh_points = []

with open(mesh_file, 'r') as f:
for line in f:
l = line.strip().split(',')
lat = float(l[0])
lon = float(l[1])
mesh_points.append([lat, lon])

with open(fno, 'w') as of:
for this_location in mesh_points:
neighbor_indices = np.linalg.norm(np.asarray(points) - np.asarray(this_location), axis=1).argsort()[:4]
neighbor_scores = [images[x][2] for x in neighbor_indices]
neighbor_lat = [images[x][0] for x in neighbor_indices]
neighbor_lon = [images[x][1] for x in neighbor_indices]

score_distortion_ratio = random.uniform(0.15, 0.5)
output_score = np.mean(neighbor_scores) * (score_distortion_ratio) + random.uniform(0, 10) * (
1 - score_distortion_ratio)

of.write(str(this_location[0]) + ',' + str(this_location[1]) + ',' + str(output_score) + '\n')

print '%s written', mesh_file


mesh_folder = sys.argv[1]
score_folder = sys.argv[2]
out_folder = sys.argv[3]

meshes = glob.glob(os.path.join(mesh_folder,'*.csv'))

varargs = []
for mesh_file in meshes:
mesh_city_name = os.path.basename(mesh_file).split('_')[1]
score_file_name = os.path.join(score_folder, mesh_city_name)
fno = os.path.join(out_folder, mesh_city_name)

varargs.append([mesh_city_name, score_file_name, fno])

pool = Pool(processes=32)
pool.map(process_images, varargs)
Loading

0 comments on commit 2692774

Please sign in to comment.