Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final tests andre #6

Open
wants to merge 186 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
d279bc0
change droupout rate
ablacan Jul 26, 2019
e4c863c
Create bh
ablacan Jul 26, 2019
3da10ea
Delete bh
ablacan Jul 26, 2019
cf655c0
update network
ablacan Jul 29, 2019
456136d
add run_bh
ablacan Jul 29, 2019
bccc818
add prep_data
ablacan Jul 29, 2019
2cad67c
resolve conflicts
ablacan Jul 29, 2019
ea0fe2d
dropout rate to 0
ablacan Jul 29, 2019
f63f9e8
extract fwhm, sm, blend params
ablacan Jul 30, 2019
b5072fb
up to date
ablacan Aug 1, 2019
013b0f8
augmentation to True
ablacan Aug 6, 2019
20cb1e0
keras initializer
ablacan Aug 6, 2019
b3e8e6e
import keras and initializers
ablacan Aug 6, 2019
9416506
constant initializer
ablacan Aug 6, 2019
1f5deac
initializer
ablacan Aug 7, 2019
67f1a39
seed
ablacan Aug 7, 2019
fc981ff
bias_initialier
ablacan Aug 7, 2019
665dede
random_normal
ablacan Aug 7, 2019
c65eb68
glorot_normal and dropout to 0
ablacan Aug 7, 2019
f9e77cf
he_uniform
ablacan Aug 8, 2019
add51dc
w/out bias_initializer
ablacan Aug 8, 2019
716c2e7
softmax
ablacan Aug 8, 2019
e74a52d
sigmoid
ablacan Aug 8, 2019
c7d0d13
he_normal
ablacan Aug 8, 2019
c50fa4e
seeds
ablacan Aug 8, 2019
2406f03
seeds
ablacan Aug 8, 2019
321912d
random.seed()
ablacan Aug 8, 2019
c842142
random.seed()
ablacan Aug 8, 2019
0b4736f
regularizers
ablacan Aug 8, 2019
9a00fc7
regularizers to 0.0001
ablacan Aug 8, 2019
316afb7
w/out random seeds
ablacan Aug 9, 2019
816528e
activity_regulizer
ablacan Aug 9, 2019
f24ef91
default fully connected model
ablacan Aug 19, 2019
14a22bc
Freezing 15 layers w/out second freezing
ablacan Aug 20, 2019
f4464f2
save final weights
ablacan Aug 20, 2019
4a729f8
17 not trainable layers
ablacan Aug 20, 2019
090b474
default fine tuning
ablacan Aug 20, 2019
3411b7a
default fine tuning
ablacan Aug 20, 2019
bbb0fc0
default fine tuning
ablacan Aug 20, 2019
680026e
15 frozen layers
ablacan Aug 21, 2019
84025e9
17 frozen layers
ablacan Aug 21, 2019
d9e9aa7
lower lr and momentum
ablacan Aug 21, 2019
2eb8105
SGD instead of ADAM optimizer
ablacan Aug 22, 2019
a6362a5
drpout to 0.3 and lr to 1e-6
ablacan Aug 22, 2019
863b6dd
14 frozen layers
ablacan Aug 22, 2019
d521ca5
verbose = 2
ablacan Aug 22, 2019
363c463
train layer 18
ablacan Aug 23, 2019
64a2bf3
epochs_fine to 80
ablacan Aug 23, 2019
b223074
layers 17 and 18 trainable
ablacan Aug 23, 2019
a6c811f
15 frozen layers
ablacan Aug 26, 2019
140200d
plot fine tune history
ablacan Aug 26, 2019
f7ce86f
plot history2
ablacan Aug 26, 2019
867b106
Adam optimizer
ablacan Aug 26, 2019
464b9f7
Adam optimizer
ablacan Aug 27, 2019
3fbfa61
Layers 16, 17, 18 trainable
ablacan Aug 27, 2019
2f525be
decay rate at 1e-6 and 17,18 layers trainable
ablacan Aug 28, 2019
8412a5c
dropout to 0.4
ablacan Sep 12, 2019
d4aea8f
Add features_visualization script
ablacan Sep 12, 2019
b209cb1
Add SExtractor script
ablacan Sep 12, 2019
7ed6c67
Add comparison between bh and sextractor script
ablacan Sep 12, 2019
adbcd1c
Clean features_visualization script
ablacan Sep 12, 2019
e56151a
Clean comparison bh and sextractor script
ablacan Sep 12, 2019
8e8f0ca
Clean sextractor script
ablacan Sep 12, 2019
3c2cf89
adding results
ablacan Sep 12, 2019
ade8e81
Add bh_results script
ablacan Sep 13, 2019
1788322
dropout to 0.6
ablacan Sep 13, 2019
5ba3197
adding missed blends by bh
ablacan Sep 16, 2019
731fda2
clean
ablacan Sep 16, 2019
93badd2
clean
ablacan Sep 16, 2019
e43e1d4
save
ablacan Sep 17, 2019
3946cff
save
ablacan Sep 17, 2019
873ff0c
save
ablacan Sep 17, 2019
5c63de2
save
ablacan Sep 17, 2019
281db93
add missed_blends_visualisation notebook
ablacan Sep 27, 2019
9efc628
place to notebooks folder
ablacan Sep 27, 2019
1491ac9
delete file
ablacan Sep 27, 2019
df4160d
place to notebooks folder
ablacan Sep 27, 2019
8160958
delete
ablacan Sep 27, 2019
ce46a56
clean prep_axel method
ablacan Oct 1, 2019
e436ef5
clean prep_axel method
ablacan Oct 1, 2019
4d02809
clean
ablacan Oct 1, 2019
cd19c6b
clean
ablacan Oct 1, 2019
f465f18
first draft
ablacan Oct 1, 2019
005acb6
add
ablacan Oct 1, 2019
66d5f9f
additional plots
ablacan Oct 4, 2019
d30a140
blends examples
ablacan Oct 4, 2019
79cc8c9
test on denoised img
ablacan Oct 14, 2019
b799dfd
add to git
ablacan Oct 14, 2019
7085467
add dense layer
ablacan Oct 15, 2019
757f562
add dense layer
ablacan Oct 15, 2019
042aae1
add to repo
Nov 22, 2019
4f0f604
add notebook
Dec 17, 2019
7205f04
add sep_script
Dec 17, 2019
4ddaa3a
add save_errors_script
Dec 17, 2019
cc3f23a
add run_sextractor
Dec 17, 2019
511cf9c
add SExtractor_test_img notebook
Dec 17, 2019
b7a99ac
add snr_computation script
Dec 17, 2019
95b5daa
vis_sep_errors
Dec 17, 2019
a436691
vis_bh_errors
Dec 17, 2019
e1f5bc3
Remove old SExtractor notebook
ablacan Dec 18, 2019
3e8057c
update local
ablacan Dec 18, 2019
393aa04
remove old SExtractor notebook
ablacan Dec 18, 2019
4564999
remove old comparison plots notebook
ablacan Dec 18, 2019
a4e07fa
remove old notebook
ablacan Dec 18, 2019
40ec167
change script directory
ablacan Dec 18, 2019
0f3b141
add to repo
ablacan Dec 18, 2019
a5c19ed
add to repo
ablacan Dec 20, 2019
58eba3b
modifications
ablacan Dec 20, 2019
8dd7999
add to repo
ablacan Dec 20, 2019
6e11fa9
add to repo
ablacan Dec 20, 2019
e3e5be6
add to repo
ablacan Dec 20, 2019
50adf7e
add to repo
ablacan Dec 20, 2019
7a6296d
add to repo
ablacan Dec 20, 2019
9449f65
add to repo
ablacan Dec 20, 2019
a1a3be8
Update
ablacan Jan 3, 2020
175813b
Update
ablacan Jan 3, 2020
21463d1
clean
ablacan Jan 3, 2020
44ab5ae
clean
ablacan Jan 3, 2020
05d1d8a
clean
ablacan Jan 3, 2020
81f9121
clean
ablacan Jan 3, 2020
99c50d5
clean
ablacan Jan 3, 2020
0493fc9
clean
ablacan Jan 3, 2020
cd69549
clean
ablacan Jan 3, 2020
dbd23a9
clean
ablacan Jan 3, 2020
2ff9b54
create folder and import scripts
ablacan Feb 7, 2020
9c3281f
add to repo
ablacan Feb 7, 2020
98488f3
add to repo
ablacan Feb 7, 2020
ff037c4
add to repo
ablacan Feb 7, 2020
3eba748
clean
ablacan Feb 7, 2020
f6e9609
clean
ablacan Feb 7, 2020
ddcf303
additional functions
ablacan Feb 7, 2020
ca4afb4
clean
ablacan Feb 7, 2020
e6242cf
clean
ablacan Feb 7, 2020
80b9f35
clean
ablacan Feb 7, 2020
1298aba
clean
ablacan Feb 7, 2020
e0043e2
clean
ablacan Feb 7, 2020
0f0e521
clean
ablacan Feb 7, 2020
da32c13
clean
ablacan Feb 7, 2020
f63882a
clean
ablacan Feb 7, 2020
ecb06c5
clean
ablacan Feb 7, 2020
ea5c5d0
clean
ablacan Feb 7, 2020
8b32dda
remove notebook
ablacan Feb 7, 2020
663ae6a
remove notebook
ablacan Feb 7, 2020
b291524
remove notebook
ablacan Feb 7, 2020
ced28a7
remove notebook
ablacan Feb 7, 2020
154a56c
clean
ablacan Feb 7, 2020
6ee82bf
add to repo
ablacan Feb 7, 2020
35380da
both padded and non padded imgs
ablacan Feb 7, 2020
e72a62b
both padded and non padded imgs
ablacan Feb 7, 2020
88bc90f
add to repo
ablacan Feb 10, 2020
ace4103
clean
ablacan Feb 10, 2020
61ff1c4
clean
ablacan Feb 10, 2020
5a16846
clean
ablacan Feb 10, 2020
fc428f2
clean
ablacan Feb 10, 2020
4576b02
clean
ablacan Feb 10, 2020
e56510c
add params x y and e1 e2
ablacan Feb 10, 2020
dc77706
update readme
ablacan Feb 12, 2020
5ec5359
update weights accuracy
ablacan Feb 21, 2020
878d340
Merge branch 'master' of https://github.com/ablacan/BlendHunter
ablacan Feb 21, 2020
df43f27
clean
ablacan Feb 21, 2020
e959900
clean
ablacan Feb 21, 2020
c45593b
clean
ablacan Feb 21, 2020
d2f4f31
Créé avec Colaboratory
ablacan Oct 22, 2020
c883685
Créé avec Colaboratory
ablacan Oct 22, 2020
6fbfa10
Créé avec Colaboratory
ablacan Oct 22, 2020
9a1cbae
prep for new run
sfarrens Jan 8, 2021
55d5c69
fixed script
sfarrens Jan 8, 2021
76f1e49
updated sep scripts
sfarrens Jan 11, 2021
487b055
updated scripts
sfarrens Jan 11, 2021
b8b2162
fixed sep script bug
sfarrens Jan 12, 2021
e681122
fixed typo
sfarrens Jan 12, 2021
a4f6e82
added accuracy notebook
sfarrens Jan 12, 2021
9fa3ed4
updated notebooks
sfarrens Jan 14, 2021
dfbf21f
fixed cosmos script
sfarrens Jan 19, 2021
0df575d
update scripts
sfarrens Jan 20, 2021
5fdb639
minor updates
sfarrens Jan 20, 2021
24408e1
only pad data
sfarrens Jan 20, 2021
3f54f5e
fixed bug
sfarrens Jan 20, 2021
959858b
updated
sfarrens Jan 20, 2021
2f1d59a
test cosmos fix
sfarrens Feb 8, 2021
b242ef9
fixed formatting error
sfarrens Feb 8, 2021
3cf1211
updated notebook
sfarrens Feb 8, 2021
0682328
test noise padding
sfarrens Feb 12, 2021
104f131
fixed typo
sfarrens Feb 12, 2021
32e760c
updated script
sfarrens Feb 13, 2021
a679ad6
Add files via upload
andrevitorelli Apr 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# BlendHunter
Deep learning tool for identifying blended galaxy images in survey images.

### blendhunter
Find the codes for the data preparation and the network in that folder.

### notebooks
Find the jupyter notebooks for results visualization.

### sextractor
Find the scripts to run SExtractor.


28 changes: 28 additions & 0 deletions blendhunter/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import yaml


class BHConfig:

def __init__(self, config_file='data/bhconfig.yml'):

self.config_file = config_file
self._read_config()

def _read_config(self):

if os.path.isfile(self.config_file):
with open(self.config_file) as file:
self.config = yaml.load(file, Loader=yaml.FullLoader)
else:
self.config = {}

def _update_config(self):

with open(self.config_file, 'w') as file:
yaml.dump(self.config, file)

def _add_params(self, params):

self.config = {**self.config, **params}
self._update_config()
70 changes: 59 additions & 11 deletions blendhunter/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os
import numpy as np
import cv2
from .blend import Blender
from blendhunter.blend import Blender


class CreateTrainData(object):
Expand All @@ -26,7 +26,7 @@ class CreateTrainData(object):
output_path : str
Path to where the data will be saved
train_fractions : tuple, optional
Fraction of trainig, validation and testing samples from the input
Fraction of training, validation and testing samples from the input
images, default is (0.45, 0.45, .1)
classes : tuple, optional
Names of the various data classes, default is ('blended',
Expand All @@ -44,7 +44,7 @@ class CreateTrainData(object):

"""

def __init__(self, images, output_path, train_fractions=(0.45, 0.45, .1),
def __init__(self, images, output_path, train_fractions=(0.45, 0.45, 0.1),
classes=('blended', 'not_blended'),
class_fractions=(0.5, 0.5), blend_images=True,
blend_fractions=(0.5, 0.5), blend_method='sf'):
Expand All @@ -61,7 +61,6 @@ def __init__(self, images, output_path, train_fractions=(0.45, 0.45, .1),
self.blend_images = blend_images
self.blend_fractions = blend_fractions
self.blend_method = blend_method
self._image_num = 0

self._make_output_dirs()

Expand Down Expand Up @@ -122,7 +121,7 @@ def _make_output_dirs(self):
def _get_slices(array, fractions):
""" Get Slices

This method converts sample fractions into slice elemets for a given
This method converts sample fractions into slice elements for a given
array.

Parameters
Expand Down Expand Up @@ -230,8 +229,9 @@ def _write_images(self, images, path):
"""

min_shape = np.array([48, 48])
zero_pad = np.log10(images.shape[0]).astype(int) + 1

for image in images:
for image_num, image in enumerate(images):

image = self._rescale(image)

Expand All @@ -240,8 +240,8 @@ def _write_images(self, images, path):
if np.sum(shape_diff) > 0:
image = self._pad(image, shape_diff)

cv2.imwrite('{}/image_{}.png'.format(path, self._image_num), image)
self._image_num += 1
cv2.imwrite('{0}/image_{2:0{1}d}.png'.format(path, zero_pad,
image_num), image)

def _write_data_set(self, data_list, path_list):
""" Write Data Set
Expand Down Expand Up @@ -360,19 +360,67 @@ def generate(self):
test_set = np.vstack(test_set)
self._write_images(test_set, self._test_path)

def prep_axel(self):
def prep_axel(self, path_to_output=None, psf=None, param_1=None,
param_2=None, map=None):
# Can add parameters : psf, param_1, param_2, map

self.images[0] = np.random.permutation(self.images[0])
self.images[1] = np.random.permutation(self.images[1])
# self.images[0] = np.random.permutation(self.images[0])
# self.images[1] = np.random.permutation(self.images[1])

split1 = self._split_array(self.images[0], self.train_fractions)
split2 = self._split_array(self.images[1], self.train_fractions)

# Split fwhm
train_fractions = (0.45, 0.45, 0.1)
# psf_split1 = CreateTrainData._split_array(psf[0], train_fractions)
# psf_split2 = CreateTrainData._split_array(psf[1], train_fractions)

# Split shift params
# x_split = CreateTrainData._split_array(param_1[0], train_fractions)
# y_split = CreateTrainData._split_array(param_2[0], train_fractions)

# Split segmentation map
# map_split = CreateTrainData._split_array(map[0], train_fractions)

train_set = split1[0], split2[0]
valid_set = split1[1], split2[1]
test_set = split1[2], split2[2]

# test_psf = psf_split1[2], psf_split2[2]
# test_param_x = x_split[2]
# test_param_y = y_split[2]
# test_im_blended = split1[2] #blended test images
# test_im_nb = split2[2]
# test_map = map_split[2]

self._write_data_set(train_set, self._train_paths)
self._write_data_set(valid_set, self._valid_paths)
self._write_labels(test_set)
self._write_images(np.vstack(test_set), self._test_path)

# Save test_psf
# np.save(path_to_output+'/test_psf.npy', test_psf)

# Save test_params
# np.save(path_to_output+'/test_param_x.npy', test_param_x)
# np.save(path_to_output+'/test_param_y.npy', test_param_y)

# Save blended test images
# np.save(path_to_output+'/gal_im_blended.npy', test_im_blended)
# np.save(path_to_output+'/gal_im_nb.npy', test_im_nb)
# np.save(path_to_output+'/test_images.npy', test_set)

# Save seg_map
# np.save(path_to_output+'/test_seg_map.npy', test_map)

def prep_cosmos(self):

split1 = self._split_array(self.images[0], self.train_fractions)
split2 = self._split_array(self.images[1], self.train_fractions)

train_set = split1[0], split2[0]
valid_set = split1[1], split2[1]
test_set = split1[2], split2[2]

self._write_labels(test_set)
self._write_images(np.vstack(test_set), self._test_path)
Loading