-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11dc49d
commit 56c7ff4
Showing
1 changed file
with
107 additions
and
0 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,107 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pc_name = \"BrunoMacM1Air\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import yaml\n", | ||
"\n", | ||
"import numpy as np\n", | ||
"from nanopyx.core.transform import NLMDenoising\n", | ||
"\n", | ||
"def concatenate_benchmarks(results, args_repr, previous_dict):\n", | ||
" if args_repr not in previous_dict:\n", | ||
" previous_dict[args_repr] = {}\n", | ||
" \n", | ||
" for t2run,name,_ in results:\n", | ||
" if name in previous_dict[args_repr]:\n", | ||
" previous_dict[args_repr][name].append(t2run)\n", | ||
" else:\n", | ||
" previous_dict[args_repr][name] = [t2run]\n", | ||
" \n", | ||
" return previous_dict\n", | ||
"\n", | ||
"\n", | ||
"denoising = NLMDenoising(verbose=False,testing=True)\n", | ||
"denoising._run_types.pop('threaded_dynamic')\n", | ||
"denoising._run_types.pop('threaded_static')\n", | ||
"denoising._run_types.pop('threaded_guided')\n", | ||
"denoising._run_types.pop('python')\n", | ||
"\n", | ||
"denoising_results = {}\n", | ||
"\n", | ||
"n_repeats = 5" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"nlm_image_1 = np.random.random((1, 1000, 1000)).astype(np.float32)\n", | ||
"nlm_image_2 = np.random.random((1, 500, 500)).astype(np.float32)\n", | ||
"nlm_image_3 = np.random.random((1, 200, 200)).astype(np.float32)\n", | ||
"\n", | ||
"args_1 = [nlm_image_1]\n", | ||
"kwargs_1 = {'patch_size': 50, 'patch_distance': 50, 'h': 0.1, 'sigma': 1.0}\n", | ||
"args_repr_1,_ = conv._get_args_repr_score(*args_1, **kwargs_1)\n", | ||
"\n", | ||
"args_2 = [nlm_image_2]\n", | ||
"kwargs_2 = {'patch_size': 5, 'patch_distance': 100, 'h': 0.1, 'sigma': 1.0}\n", | ||
"args_repr_2,_ = conv._get_args_repr_score(*args_2, **kwargs_2)\n", | ||
"\n", | ||
"args_3 = [nlm_image_3]\n", | ||
"kwargs_3 = {'patch_size': 5, 'patch_distance': 10, 'h': 0.1, 'sigma': 1.0}\n", | ||
"args_repr_3,_ = conv._get_args_repr_score(*args_3, **kwargs_3)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for i in range(n_repeats): \n", | ||
" results = denoising.benchmark(*args_1, **kwargs_1)\n", | ||
" denoising_results = concatenate_benchmarks(results, args_repr_1, denoising_results)\n", | ||
" results = denoising.benchmark(*args_2, **kwargs_2)\n", | ||
" denoising_results = concatenate_benchmarks(results, args_repr_2, denoising_results)\n", | ||
" results = denoising.benchmark(*args_3, **kwargs_3)\n", | ||
" denoising_results = concatenate_benchmarks(results, args_repr_3, denoising_results)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if not os.path.exists(\"Benchmark_results\"):\n", | ||
" os.mkdir(\"Benchmark_results\")\n", | ||
"\n", | ||
"with open(f\"Benchmark_results/{pc_name}_Results_denoising.yaml\", 'w') as f:\n", | ||
" yaml.dump(denoising_results, f)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |