File dataset_script/jhucrowd_density_map.py changed (mode: 100644) (index 2b87023..e8ba00c) |
... |
... |
def load_density_label(label_txt_path): |
21 |
21 |
:param label_txt_path: path to txt |
:param label_txt_path: path to txt |
22 |
22 |
:return: numpy array, p[sample, a] with a is 0 for x and 1 for y |
:return: numpy array, p[sample, a] with a is 0 for x and 1 for y |
23 |
23 |
""" |
""" |
24 |
|
df = pd.read_csv(label_txt_path, sep=" ", header=None) |
|
25 |
|
p = df.to_numpy() |
|
|
24 |
|
p = None |
|
25 |
|
try: |
|
26 |
|
df = pd.read_csv(label_txt_path, sep=" ", header=None) |
|
27 |
|
p = df.to_numpy() |
|
28 |
|
except Exception: |
|
29 |
|
print("exception load csv ", label_txt_path) |
26 |
30 |
return p |
return p |
27 |
31 |
|
|
28 |
32 |
|
|
|
... |
... |
def generate_density_map(img_path, label_path, output_path): |
82 |
86 |
|
|
83 |
87 |
# empty matrix zero |
# empty matrix zero |
84 |
88 |
k = np.zeros((img.shape[0], img.shape[1])) |
k = np.zeros((img.shape[0], img.shape[1])) |
85 |
|
for i in range(0, len(gt)): |
|
86 |
|
if int(gt[i][1]) < img.shape[0] and int(gt[i][0]) < img.shape[1]: |
|
87 |
|
k[int(gt[i][1]), int(gt[i][0])] = 1 |
|
88 |
|
k = gaussian_filter_density(k) |
|
|
89 |
|
if gt is not None: |
|
90 |
|
for i in range(0, len(gt)): |
|
91 |
|
if int(gt[i][1]) < img.shape[0] and int(gt[i][0]) < img.shape[1]: |
|
92 |
|
k[int(gt[i][1]), int(gt[i][0])] = 1 |
|
93 |
|
k = gaussian_filter_density(k) |
|
94 |
|
# if gt is null, so we don't have count, let it be zero matrix |
|
95 |
|
|
89 |
96 |
with h5py.File(output_path, 'w') as hf: |
with h5py.File(output_path, 'w') as hf: |
90 |
97 |
hf['density'] = k |
hf['density'] = k |
91 |
98 |
return output_path |
return output_path |
|
... |
... |
def full_flow_jhucrowd_parallel(root_path, experiment=None): |
172 |
179 |
print("exception at ", name) |
print("exception at ", name) |
173 |
180 |
|
|
174 |
181 |
|
|
175 |
|
Parallel(n_jobs=8)(delayed(jhucrowd_single_file)(img_name) for img_name in img_list) |
|
|
182 |
|
Parallel(n_jobs=20)(delayed(jhucrowd_single_file)(img_name) for img_name in img_list) |
176 |
183 |
|
|
177 |
184 |
print("done") |
print("done") |
178 |
185 |
|
|
File dataset_script/jhucrowd_train.sh changed (mode: 100644) (index 8177f2d..bf08e29) |
1 |
1 |
HTTPS_PROXY="http://10.60.28.99:86" nohup python dataset_script/jhucrowd_density_map.py \ |
HTTPS_PROXY="http://10.60.28.99:86" nohup python dataset_script/jhucrowd_density_map.py \ |
2 |
2 |
--task_id jhu_train \ |
--task_id jhu_train \ |
3 |
3 |
--input /data/rnd/thient/thient_data/jhu_crowd_plusplus/train_data_train_split \ |
--input /data/rnd/thient/thient_data/jhu_crowd_plusplus/train_data_train_split \ |
4 |
|
> logs/jhucrowd_density_map_train_t3.log & |
|
|
4 |
|
> logs/jhucrowd_density_map_train_t4.log & |
5 |
5 |
|
|
6 |
|
echo logs/jhucrowd_density_map_train_t3.log |
|
|
6 |
|
echo logs/jhucrowd_density_map_train_t4.log |
File dataset_script/jhucrowd_val.sh changed (mode: 100644) (index de2fa2e..9a80f3d) |
1 |
1 |
HTTPS_PROXY="http://10.60.28.99:86" nohup python dataset_script/jhucrowd_density_map.py \ |
HTTPS_PROXY="http://10.60.28.99:86" nohup python dataset_script/jhucrowd_density_map.py \ |
2 |
2 |
--task_id jhu_val \ |
--task_id jhu_val \ |
3 |
3 |
--input /data/rnd/thient/thient_data/jhu_crowd_plusplus/train_data_validate_split \ |
--input /data/rnd/thient/thient_data/jhu_crowd_plusplus/train_data_validate_split \ |
4 |
|
> logs/jhucrowd_density_map_val_t3.log & |
|
|
4 |
|
> logs/jhucrowd_density_map_val_t3_to_full.log & |
5 |
5 |
|
|
6 |
|
echo logs/jhucrowd_density_map_val_t3.log |
|
|
6 |
|
echo logs/jhucrowd_density_map_val_t3_to_full.log |