-
Notifications
You must be signed in to change notification settings - Fork 12
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
Unknown
committed
Apr 9, 2024
0 parents
commit 0b696e8
Showing
56 changed files
with
8,786 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,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: b87c29c3f7e59f3356fa0ff6e39e6a41 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Empty file.
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,188 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="English" data-content_root="../../"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>deepdespeckling.denoiser — deepdespeckling 0.3 documentation</title> | ||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=d1102ebc" /> | ||
<link rel="stylesheet" type="text/css" href="../../_static/alabaster.css?v=12dfc556" /> | ||
<script src="../../_static/documentation_options.js?v=cb255500"></script> | ||
<script src="../../_static/doctools.js?v=888ff710"></script> | ||
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script> | ||
<link rel="index" title="Index" href="../../genindex.html" /> | ||
<link rel="search" title="Search" href="../../search.html" /> | ||
|
||
<link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> | ||
|
||
|
||
|
||
|
||
|
||
</head><body> | ||
|
||
|
||
<div class="document"> | ||
<div class="documentwrapper"> | ||
<div class="bodywrapper"> | ||
|
||
|
||
<div class="body" role="main"> | ||
|
||
<h1>Source code for deepdespeckling.denoiser</h1><div class="highlight"><pre> | ||
<span></span><span class="kn">import</span> <span class="nn">logging</span> | ||
<span class="kn">import</span> <span class="nn">torch</span> | ||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> | ||
|
||
|
||
<div class="viewcode-block" id="Denoiser"> | ||
<a class="viewcode-back" href="../../modules.html#deepdespeckling.denoiser.Denoiser">[docs]</a> | ||
<span class="k">class</span> <span class="nc">Denoiser</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""Class to share parameters beyond denoising functions</span> | ||
<span class="sd"> """</span> | ||
|
||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">device</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_device</span><span class="p">()</span> | ||
|
||
<div class="viewcode-block" id="Denoiser.get_device"> | ||
<a class="viewcode-back" href="../../modules.html#deepdespeckling.denoiser.Denoiser.get_device">[docs]</a> | ||
<span class="k">def</span> <span class="nf">get_device</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""Get torch device to use depending on gpu's availability</span> | ||
|
||
<span class="sd"> Returns:</span> | ||
<span class="sd"> device (str): device to be used by torch</span> | ||
<span class="sd"> """</span> | ||
<span class="k">if</span> <span class="n">torch</span><span class="o">.</span><span class="n">backends</span><span class="o">.</span><span class="n">mps</span><span class="o">.</span><span class="n">is_available</span><span class="p">()</span> <span class="ow">and</span> <span class="n">torch</span><span class="o">.</span><span class="n">backends</span><span class="o">.</span><span class="n">mps</span><span class="o">.</span><span class="n">is_built</span><span class="p">():</span> | ||
<span class="n">device</span> <span class="o">=</span> <span class="s2">"mps"</span> | ||
<span class="k">elif</span> <span class="n">torch</span><span class="o">.</span><span class="n">cuda</span><span class="o">.</span><span class="n">is_available</span><span class="p">():</span> | ||
<span class="n">device</span> <span class="o">=</span> <span class="s2">"cuda:0"</span> | ||
<span class="k">else</span><span class="p">:</span> | ||
<span class="n">device</span> <span class="o">=</span> <span class="s2">"cpu"</span> | ||
<span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">device</span><span class="si">}</span><span class="s2"> device is used by torch"</span><span class="p">)</span> | ||
|
||
<span class="k">return</span> <span class="n">device</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="Denoiser.initialize_axis_range"> | ||
<a class="viewcode-back" href="../../modules.html#deepdespeckling.denoiser.Denoiser.initialize_axis_range">[docs]</a> | ||
<span class="k">def</span> <span class="nf">initialize_axis_range</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">image_axis_dim</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">patch_size</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">stride_size</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""Initialize the convolution range for x or y axis</span> | ||
|
||
<span class="sd"> Args:</span> | ||
<span class="sd"> image_axis_dim (int): axis size</span> | ||
<span class="sd"> patch_size (int): patch size</span> | ||
<span class="sd"> stride_size (int): stride size</span> | ||
|
||
<span class="sd"> Returns:</span> | ||
<span class="sd"> axis_range (list) : pixel borders of each convolution</span> | ||
<span class="sd"> """</span> | ||
<span class="k">if</span> <span class="n">image_axis_dim</span> <span class="o">==</span> <span class="n">patch_size</span><span class="p">:</span> | ||
<span class="n">axis_range</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">]))</span> | ||
<span class="k">else</span><span class="p">:</span> | ||
<span class="n">axis_range</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span> | ||
<span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">image_axis_dim</span> <span class="o">-</span> <span class="n">patch_size</span><span class="p">,</span> <span class="n">stride_size</span><span class="p">))</span> | ||
<span class="k">if</span> <span class="p">(</span><span class="n">axis_range</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">patch_size</span><span class="p">)</span> <span class="o"><</span> <span class="n">image_axis_dim</span><span class="p">:</span> | ||
<span class="n">axis_range</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span> | ||
<span class="nb">range</span><span class="p">(</span><span class="n">image_axis_dim</span> <span class="o">-</span> <span class="n">patch_size</span><span class="p">,</span> <span class="n">image_axis_dim</span> <span class="o">-</span> <span class="n">patch_size</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))</span> | ||
|
||
<span class="k">return</span> <span class="n">axis_range</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="Denoiser.save_despeckled_images"> | ||
<a class="viewcode-back" href="../../modules.html#deepdespeckling.denoiser.Denoiser.save_despeckled_images">[docs]</a> | ||
<span class="k">def</span> <span class="nf">save_despeckled_images</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="k">raise</span> <span class="ne">NotImplementedError</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="Denoiser.denoise_image_kernel"> | ||
<a class="viewcode-back" href="../../modules.html#deepdespeckling.denoiser.Denoiser.denoise_image_kernel">[docs]</a> | ||
<span class="k">def</span> <span class="nf">denoise_image_kernel</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="k">raise</span> <span class="ne">NotImplementedError</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="Denoiser.preprocess_denoised_image"> | ||
<a class="viewcode-back" href="../../modules.html#deepdespeckling.denoiser.Denoiser.preprocess_denoised_image">[docs]</a> | ||
<span class="k">def</span> <span class="nf">preprocess_denoised_image</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="k">raise</span> <span class="ne">NotImplementedError</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="Denoiser.denoise_image"> | ||
<a class="viewcode-back" href="../../modules.html#deepdespeckling.denoiser.Denoiser.denoise_image">[docs]</a> | ||
<span class="k">def</span> <span class="nf">denoise_image</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="k">raise</span> <span class="ne">NotImplementedError</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="Denoiser.denoise_images"> | ||
<a class="viewcode-back" href="../../modules.html#deepdespeckling.denoiser.Denoiser.denoise_images">[docs]</a> | ||
<span class="k">def</span> <span class="nf">denoise_images</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="k">raise</span> <span class="ne">NotImplementedError</span></div> | ||
</div> | ||
|
||
</pre></div> | ||
|
||
</div> | ||
|
||
</div> | ||
</div> | ||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation"> | ||
<div class="sphinxsidebarwrapper"> | ||
<h1 class="logo"><a href="../../index.html">deepdespeckling</a></h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h3>Navigation</h3> | ||
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">deepdespeckling</a></li> | ||
</ul> | ||
|
||
<div class="relations"> | ||
<h3>Related Topics</h3> | ||
<ul> | ||
<li><a href="../../index.html">Documentation overview</a><ul> | ||
<li><a href="../index.html">Module code</a><ul> | ||
</ul></li> | ||
</ul></li> | ||
</ul> | ||
</div> | ||
<div id="searchbox" style="display: none" role="search"> | ||
<h3 id="searchlabel">Quick search</h3> | ||
<div class="searchformwrapper"> | ||
<form class="search" action="../../search.html" method="get"> | ||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> | ||
<input type="submit" value="Go" /> | ||
</form> | ||
</div> | ||
</div> | ||
<script>document.getElementById('searchbox').style.display = "block"</script> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</div> | ||
</div> | ||
<div class="clearer"></div> | ||
</div> | ||
<div class="footer"> | ||
©2024, Hadrien Mariaccia, Emanuele Delsasso. | ||
|
||
| | ||
Powered by <a href="https://www.sphinx-doc.org/">Sphinx 7.2.6</a> | ||
& <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a> | ||
|
||
</div> | ||
|
||
|
||
|
||
|
||
</body> | ||
</html> |
Oops, something went wrong.