-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from SiLiKhon/refactoring
Refactoring
- Loading branch information
Showing
39 changed files
with
2,524 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import argparse | ||
from pathlib import Path | ||
|
||
from PIL import Image | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('path_to_images', type=str) | ||
parser.add_argument('--output_name', type=str, default='plots.png') | ||
|
||
args = parser.parse_args() | ||
|
||
variables = [ | ||
'crossing_angle', | ||
'dip_angle', | ||
'drift_length', | ||
'pad_coord_fraction', | ||
'time_bin_fraction', | ||
] | ||
|
||
stats = [ | ||
'Mean0', | ||
'Mean1', | ||
'Sigma0^2', | ||
'Sigma1^2', | ||
'Cov01', | ||
'Sum', | ||
] | ||
|
||
img_path = Path(args.path_to_images) | ||
images = [[Image.open(img_path / f'{s} vs {v}_amp_gt_1.png') for v in variables] for s in stats] | ||
|
||
width, height = images[0][0].size | ||
|
||
new_image = Image.new('RGB', (width * len(stats), height * len(variables))) | ||
|
||
x_offset = 0 | ||
for img_line in images: | ||
y_offset = 0 | ||
for img in img_line: | ||
new_image.paste(img, (x_offset, y_offset)) | ||
y_offset += img.size[1] | ||
x_offset += img.size[0] | ||
|
||
new_image.save(img_path / args.output_name) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
|
||
import tensorflow as tf | ||
|
||
def setup_gpu(gpu_num=None): | ||
os.environ['CUDA_DEVICE_ORDER'] = 'PCI_BUS_ID' | ||
if gpu_num is not None: | ||
os.environ['CUDA_VISIBLE_DEVICES'] = gpu_num | ||
|
||
gpus = tf.config.experimental.list_physical_devices('GPU') | ||
for gpu in gpus: | ||
tf.config.experimental.set_memory_growth(gpu, True) | ||
|
||
logical_devices = tf.config.experimental.list_logical_devices('GPU') | ||
assert len(logical_devices) > 0, "Not enough GPU hardware devices available" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.