Files
custom-nodes-security-scan/docs/comfyui-reactor-node-bandit.html
zeekay 6bdea42e64 rebrand: Hanzo AI Inc — full rebrand from ComfyUI/Comfy-Org
- Updated copyright to Hanzo AI, Inc.
- Replaced ComfyUI references with Hanzo Studio
- Updated GitHub org URLs (Comfy-Org → hanzoui)
- Updated domains (comfy.org → hanzo.ai)
- Updated package names and npm scopes
- Updated LICENSE with Hanzo AI copyright header
2026-02-23 10:54:25 -08:00

4229 lines
186 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>
Bandit Report
</title>
<style>
html * {
font-family: "Arial", sans-serif;
}
pre {
font-family: "Monaco", monospace;
}
.bordered-box {
border: 1px solid black;
padding-top:.5em;
padding-bottom:.5em;
padding-left:1em;
}
.metrics-box {
font-size: 1.1em;
line-height: 130%;
}
.metrics-title {
font-size: 1.5em;
font-weight: 500;
margin-bottom: .25em;
}
.issue-description {
font-size: 1.3em;
font-weight: 500;
}
.candidate-issues {
margin-left: 2em;
border-left: solid 1px; LightGray;
padding-left: 5%;
margin-top: .2em;
margin-bottom: .2em;
}
.issue-block {
border: 1px solid LightGray;
padding-left: .5em;
padding-top: .5em;
padding-bottom: .5em;
margin-bottom: .5em;
}
.issue-sev-high {
background-color: Pink;
}
.issue-sev-medium {
background-color: NavajoWhite;
}
.issue-sev-low {
background-color: LightCyan;
}
</style>
</head>
<body>
<div id="metrics">
<div class="metrics-box bordered-box">
<div class="metrics-title">
Metrics:<br>
</div>
Total lines of code: <span id="loc">18669</span><br>
Total lines skipped (#nosec): <span id="nosec">0</span>
</div>
</div>
<br>
<div id="results">
<div id="issue-0">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Consider possible security implications associated with the subprocess module.<br>
<b>Test ID:</b> B404<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/install.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/install.py</a><br>
<b>Line number: </b>4<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b404-import-subprocess" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b404-import-subprocess</a><br>
<div class="code">
<pre>
1 import warnings
2 warnings.filterwarnings(&quot;ignore&quot;, category=DeprecationWarning)
3
4 import subprocess
5 import os, sys
6 try:
7 from pkg_resources import get_distribution as distributions
8 except:
</pre>
</div>
</div>
</div>
<div id="issue-1">
<div class="issue-block issue-sev-low">
<b>subprocess_without_shell_equals_true: </b> subprocess call - check for execution of untrusted input.<br>
<b>Test ID:</b> B603<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/install.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/install.py</a><br>
<b>Line number: </b>29<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b603_subprocess_without_shell_equals_true.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b603_subprocess_without_shell_equals_true.html</a><br>
<div class="code">
<pre>
25 models_dir_path = os.path.join(models_dir, &quot;insightface&quot;)
26 model_path = os.path.join(models_dir_path, model_name)
27
28 def run_pip(*args):
29 subprocess.run([sys.executable, &quot;-m&quot;, &quot;pip&quot;, &quot;install&quot;, &quot;--no-warn-script-location&quot;, *args])
30
31 def is_installed (
32 package: str, version: str = None, strict: bool = True
</pre>
</div>
</div>
</div>
<div id="issue-2">
<div class="issue-block issue-sev-medium">
<b>blacklist: </b> Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.<br>
<b>Test ID:</b> B310<br>
<b>Severity: </b>MEDIUM<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/22.html" target="_blank">CWE-22</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/install.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/install.py</a><br>
<b>Line number: </b>53<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b310-urllib-urlopen" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b310-urllib-urlopen</a><br>
<div class="code">
<pre>
49 print(f&quot;Status: {e}&quot;)
50 return False
51
52 def download(url, path, name):
53 request = urllib.request.urlopen(url)
54 total = int(request.headers.get(&#x27;Content-Length&#x27;, 0))
55 with tqdm(total=total, desc=f&#x27;[ReActor] Downloading {name} to {path}&#x27;, unit=&#x27;B&#x27;, unit_scale=True, unit_divisor=1024) as progress:
56 urllib.request.urlretrieve(url, path, reporthook=lambda count, block_size, total_size: progress.update(block_size))
</pre>
</div>
</div>
</div>
<div id="issue-3">
<div class="issue-block issue-sev-medium">
<b>blacklist: </b> Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.<br>
<b>Test ID:</b> B310<br>
<b>Severity: </b>MEDIUM<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/22.html" target="_blank">CWE-22</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/install.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/install.py</a><br>
<b>Line number: </b>56<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b310-urllib-urlopen" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b310-urllib-urlopen</a><br>
<div class="code">
<pre>
52 def download(url, path, name):
53 request = urllib.request.urlopen(url)
54 total = int(request.headers.get(&#x27;Content-Length&#x27;, 0))
55 with tqdm(total=total, desc=f&#x27;[ReActor] Downloading {name} to {path}&#x27;, unit=&#x27;B&#x27;, unit_scale=True, unit_divisor=1024) as progress:
56 urllib.request.urlretrieve(url, path, reporthook=lambda count, block_size, total_size: progress.update(block_size))
57
58 if not os.path.exists(models_dir_path):
59 os.makedirs(models_dir_path)
</pre>
</div>
</div>
</div>
<div id="issue-4">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/nodes.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/nodes.py</a><br>
<b>Line number: </b>789<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
785 mask = torch.nn.functional.interpolate(mask.unsqueeze(1), size=(H, W), mode=&#x27;nearest&#x27;)[:,0,:,:]
786 MB, _, _ = mask.shape
787
788 if MB &lt; B:
789 assert(B % MB == 0)
790 mask = mask.repeat(B // MB, 1, 1)
791
792 # masks_to_boxes errors if the tensor is all zeros, so we&#x27;ll add a single pixel and zero it out at the end
</pre>
</div>
</div>
</div>
<div id="issue-5">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/nodes.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/nodes.py</a><br>
<b>Line number: </b>849<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
845 MB = mask.shape[0]
846 PB = image_to_paste.shape[0]
847
848 if B &lt; PB:
849 assert(PB % B == 0)
850 image_base = image_base.repeat(PB // B, 1, 1, 1)
851 B, H, W, C = image_base.shape
852 if MB &lt; B:
</pre>
</div>
</div>
</div>
<div id="issue-6">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/nodes.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/nodes.py</a><br>
<b>Line number: </b>853<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
849 assert(PB % B == 0)
850 image_base = image_base.repeat(PB // B, 1, 1, 1)
851 B, H, W, C = image_base.shape
852 if MB &lt; B:
853 assert(B % MB == 0)
854 mask = mask.repeat(B // MB, 1, 1)
855 elif B &lt; MB:
856 assert(MB % B == 0)
</pre>
</div>
</div>
</div>
<div id="issue-7">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/nodes.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/nodes.py</a><br>
<b>Line number: </b>856<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
852 if MB &lt; B:
853 assert(B % MB == 0)
854 mask = mask.repeat(B // MB, 1, 1)
855 elif B &lt; MB:
856 assert(MB % B == 0)
857 image_base = image_base.repeat(MB // B, 1, 1, 1)
858 if PB &lt; B:
859 assert(B % PB == 0)
</pre>
</div>
</div>
</div>
<div id="issue-8">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/nodes.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/nodes.py</a><br>
<b>Line number: </b>859<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
855 elif B &lt; MB:
856 assert(MB % B == 0)
857 image_base = image_base.repeat(MB // B, 1, 1, 1)
858 if PB &lt; B:
859 assert(B % PB == 0)
860 image_to_paste = image_to_paste.repeat(B // PB, 1, 1, 1)
861
862 mask = torch.nn.functional.interpolate(mask.unsqueeze(1), size=(H, W), mode=&#x27;nearest&#x27;)[:,0,:,:]
</pre>
</div>
</div>
</div>
<div id="issue-9">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/arch_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/arch_util.py</a><br>
<b>Line number: </b>133<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
129
130 Returns:
131 Tensor: Warped image or feature map.
132 &quot;&quot;&quot;
133 assert x.size()[-2:] == flow.size()[1:3]
134 _, _, h, w = x.size()
135 # create mesh grid
136 grid_y, grid_x = torch.meshgrid(torch.arange(0, h).type_as(x), torch.arange(0, w).type_as(x))
</pre>
</div>
</div>
</div>
<div id="issue-10">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/arch_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/arch_util.py</a><br>
<b>Line number: </b>202<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
198 Tensor: the pixel unshuffled feature.
199 &quot;&quot;&quot;
200 b, c, hh, hw = x.size()
201 out_channel = c * (scale**2)
202 assert hh % scale == 0 and hw % scale == 0
203 h = hh // scale
204 w = hw // scale
205 x_view = x.view(b, c, h, scale, w, scale)
</pre>
</div>
</div>
</div>
<div id="issue-11">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/basicvsrpp_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/basicvsrpp_arch.py</a><br>
<b>Line number: </b>311<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
307 feats_ = feats_.view(n, t, -1, h, w)
308 feats[&#x27;spatial&#x27;] = [feats_[:, i, :, :, :] for i in range(0, t)]
309
310 # compute optical flow using the low-res inputs
311 assert lqs_downsample.size(3) &gt;= 64 and lqs_downsample.size(4) &gt;= 64, (
312 &#x27;The height and width of low-res inputs must be at least 64, &#x27;
313 f&#x27;but got {h} and {w}.&#x27;)
314 flows_forward, flows_backward = self.compute_flow(lqs_downsample)
315
316 # feature propgation
</pre>
</div>
</div>
</div>
<div id="issue-12">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/dfdnet_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/dfdnet_util.py</a><br>
<b>Line number: </b>66<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
62 eps (float): A small value added to the variance to avoid
63 divide-by-zero. Default: 1e-5.
64 &quot;&quot;&quot;
65 size = feat.size()
66 assert len(size) == 4, &#x27;The input feature should be 4D tensor.&#x27;
67 n, c = size[:2]
68 feat_var = feat.view(n, c, -1).var(dim=2) + eps
69 feat_std = feat_var.sqrt().view(n, c, 1, 1)
</pre>
</div>
</div>
</div>
<div id="issue-13">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/discriminator_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/discriminator_arch.py</a><br>
<b>Line number: </b>22<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
18
19 def __init__(self, num_in_ch, num_feat, input_size=128):
20 super(VGGStyleDiscriminator, self).__init__()
21 self.input_size = input_size
22 assert self.input_size == 128 or self.input_size == 256, (
23 f&#x27;input size must be 128 or 256, but received {input_size}&#x27;)
24
25 self.conv0_0 = nn.Conv2d(num_in_ch, num_feat, 3, 1, 1, bias=True)
26 self.conv0_1 = nn.Conv2d(num_feat, num_feat, 4, 2, 1, bias=False)
</pre>
</div>
</div>
</div>
<div id="issue-14">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/discriminator_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/discriminator_arch.py</a><br>
<b>Line number: </b>62<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
58 # activation function
59 self.lrelu = nn.LeakyReLU(negative_slope=0.2, inplace=True)
60
61 def forward(self, x):
62 assert x.size(2) == self.input_size, (f&#x27;Input size must be identical to input_size, but received {x.size()}.&#x27;)
63
64 feat = self.lrelu(self.conv0_0(x))
65 feat = self.lrelu(self.bn0_1(self.conv0_1(feat))) # output spatial size: /2
</pre>
</div>
</div>
</div>
<div id="issue-15">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/edvr_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/edvr_arch.py</a><br>
<b>Line number: </b>329<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
325
326 def forward(self, x):
327 b, t, c, h, w = x.size()
328 if self.hr_in:
329 assert h % 16 == 0 and w % 16 == 0, (&#x27;The height and width must be multiple of 16.&#x27;)
330 else:
331 assert h % 4 == 0 and w % 4 == 0, (&#x27;The height and width must be multiple of 4.&#x27;)
332
</pre>
</div>
</div>
</div>
<div id="issue-16">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/edvr_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/edvr_arch.py</a><br>
<b>Line number: </b>331<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
327 b, t, c, h, w = x.size()
328 if self.hr_in:
329 assert h % 16 == 0 and w % 16 == 0, (&#x27;The height and width must be multiple of 16.&#x27;)
330 else:
331 assert h % 4 == 0 and w % 4 == 0, (&#x27;The height and width must be multiple of 4.&#x27;)
332
333 x_center = x[:, self.center_frame_idx, :, :, :].contiguous()
334
</pre>
</div>
</div>
</div>
<div id="issue-17">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/hifacegan_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/hifacegan_util.py</a><br>
<b>Line number: </b>17<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
13
14 def __init__(self, config_text, norm_nc, label_nc):
15 super().__init__()
16
17 assert config_text.startswith(&#x27;spade&#x27;)
18 parsed = re.search(&#x27;spade(\\D+)(\\d)x\\d&#x27;, config_text)
19 param_free_norm_type = str(parsed.group(1))
20 ks = int(parsed.group(2))
</pre>
</div>
</div>
</div>
<div id="issue-18">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/inception.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/inception.py</a><br>
<b>Line number: </b>74<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
70 self.normalize_input = normalize_input
71 self.output_blocks = sorted(output_blocks)
72 self.last_needed_block = max(output_blocks)
73
74 assert self.last_needed_block &lt;= 3, (&#x27;Last possible output block index is 3&#x27;)
75
76 self.blocks = nn.ModuleList()
77
</pre>
</div>
</div>
</div>
<div id="issue-19">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/spynet_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/spynet_arch.py</a><br>
<b>Line number: </b>82<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
78
79 return flow
80
81 def forward(self, ref, supp):
82 assert ref.size() == supp.size()
83
84 h, w = ref.size(2), ref.size(3)
85 w_floor = math.floor(math.ceil(w / 32.0) * 32.0)
</pre>
</div>
</div>
</div>
<div id="issue-20">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/stylegan2_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/stylegan2_arch.py</a><br>
<b>Line number: </b>563<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
559 else: # used for encoder with different latent code for each layer
560 latent = styles[0]
561 elif len(styles) == 2: # mixing noises
562 if inject_index is None:
563 inject_index = random.randint(1, self.num_latent - 1)
564 latent1 = styles[0].unsqueeze(1).repeat(1, inject_index, 1)
565 latent2 = styles[1].unsqueeze(1).repeat(1, self.num_latent - inject_index, 1)
566 latent = torch.cat([latent1, latent2], 1)
</pre>
</div>
</div>
</div>
<div id="issue-21">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/swinir_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/swinir_arch.py</a><br>
<b>Line number: </b>238<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
234 if min(self.input_resolution) &lt;= self.window_size:
235 # if window size is larger than input resolution, we don&#x27;t partition windows
236 self.shift_size = 0
237 self.window_size = min(self.input_resolution)
238 assert 0 &lt;= self.shift_size &lt; self.window_size, &#x27;shift_size must in 0-window_size&#x27;
239
240 self.norm1 = norm_layer(dim)
241 self.attn = WindowAttention(
</pre>
</div>
</div>
</div>
<div id="issue-22">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/swinir_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/swinir_arch.py</a><br>
<b>Line number: </b>366<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
362 x: b, h*w, c
363 &quot;&quot;&quot;
364 h, w = self.input_resolution
365 b, seq_len, c = x.shape
366 assert seq_len == h * w, &#x27;input feature has wrong size&#x27;
367 assert h % 2 == 0 and w % 2 == 0, f&#x27;x size ({h}*{w}) are not even.&#x27;
368
369 x = x.view(b, h, w, c)
</pre>
</div>
</div>
</div>
<div id="issue-23">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/swinir_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/swinir_arch.py</a><br>
<b>Line number: </b>367<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
363 &quot;&quot;&quot;
364 h, w = self.input_resolution
365 b, seq_len, c = x.shape
366 assert seq_len == h * w, &#x27;input feature has wrong size&#x27;
367 assert h % 2 == 0 and w % 2 == 0, f&#x27;x size ({h}*{w}) are not even.&#x27;
368
369 x = x.view(b, h, w, c)
370
</pre>
</div>
</div>
</div>
<div id="issue-24">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/swinir_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/archs/swinir_arch.py</a><br>
<b>Line number: </b>845<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
841 self.upsample = UpsampleOneStep(upscale, embed_dim, num_out_ch,
842 (patches_resolution[0], patches_resolution[1]))
843 elif self.upsampler == &#x27;nearest+conv&#x27;:
844 # for real-world SR (less artifacts)
845 assert self.upscale == 4, &#x27;only support x4 now.&#x27;
846 self.conv_before_upsample = nn.Sequential(
847 nn.Conv2d(embed_dim, num_feat, 3, 1, 1), nn.LeakyReLU(inplace=True))
848 self.conv_up1 = nn.Conv2d(num_feat, num_feat, 3, 1, 1)
</pre>
</div>
</div>
</div>
<div id="issue-25">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_sampler.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_sampler.py</a><br>
<b>Line number: </b>40<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
36 indices = [v % dataset_size for v in indices]
37
38 # subsample
39 indices = indices[self.rank:self.total_size:self.num_replicas]
40 assert len(indices) == self.num_samples
41
42 return iter(indices)
43
</pre>
</div>
</div>
</div>
<div id="issue-26">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>63<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
59
60 Returns:
61 list[int]: A list of indices.
62 &quot;&quot;&quot;
63 assert num_frames % 2 == 1, &#x27;num_frames should be an odd number.&#x27;
64 assert padding in (&#x27;replicate&#x27;, &#x27;reflection&#x27;, &#x27;reflection_circle&#x27;, &#x27;circle&#x27;), f&#x27;Wrong padding mode: {padding}.&#x27;
65
66 max_frame_num = max_frame_num - 1 # start from 0
</pre>
</div>
</div>
</div>
<div id="issue-27">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>64<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
60 Returns:
61 list[int]: A list of indices.
62 &quot;&quot;&quot;
63 assert num_frames % 2 == 1, &#x27;num_frames should be an odd number.&#x27;
64 assert padding in (&#x27;replicate&#x27;, &#x27;reflection&#x27;, &#x27;reflection_circle&#x27;, &#x27;circle&#x27;), f&#x27;Wrong padding mode: {padding}.&#x27;
65
66 max_frame_num = max_frame_num - 1 # start from 0
67 num_pad = num_frames // 2
</pre>
</div>
</div>
</div>
<div id="issue-28">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>130<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
126
127 Returns:
128 list[str]: Returned path list.
129 &quot;&quot;&quot;
130 assert len(folders) == 2, (&#x27;The len of folders should be 2 with [input_folder, gt_folder]. &#x27;
131 f&#x27;But got {len(folders)}&#x27;)
132 assert len(keys) == 2, f&#x27;The len of keys should be 2 with [input_key, gt_key]. But got {len(keys)}&#x27;
133 input_folder, gt_folder = folders
134 input_key, gt_key = keys
</pre>
</div>
</div>
</div>
<div id="issue-29">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>132<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
128 list[str]: Returned path list.
129 &quot;&quot;&quot;
130 assert len(folders) == 2, (&#x27;The len of folders should be 2 with [input_folder, gt_folder]. &#x27;
131 f&#x27;But got {len(folders)}&#x27;)
132 assert len(keys) == 2, f&#x27;The len of keys should be 2 with [input_key, gt_key]. But got {len(keys)}&#x27;
133 input_folder, gt_folder = folders
134 input_key, gt_key = keys
135
</pre>
</div>
</div>
</div>
<div id="issue-30">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>179<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
175
176 Returns:
177 list[str]: Returned path list.
178 &quot;&quot;&quot;
179 assert len(folders) == 2, (&#x27;The len of folders should be 2 with [input_folder, gt_folder]. &#x27;
180 f&#x27;But got {len(folders)}&#x27;)
181 assert len(keys) == 2, f&#x27;The len of keys should be 2 with [input_key, gt_key]. But got {len(keys)}&#x27;
182 input_folder, gt_folder = folders
183 input_key, gt_key = keys
</pre>
</div>
</div>
</div>
<div id="issue-31">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>181<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
177 list[str]: Returned path list.
178 &quot;&quot;&quot;
179 assert len(folders) == 2, (&#x27;The len of folders should be 2 with [input_folder, gt_folder]. &#x27;
180 f&#x27;But got {len(folders)}&#x27;)
181 assert len(keys) == 2, f&#x27;The len of keys should be 2 with [input_key, gt_key]. But got {len(keys)}&#x27;
182 input_folder, gt_folder = folders
183 input_key, gt_key = keys
184
</pre>
</div>
</div>
</div>
<div id="issue-32">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>213<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
209
210 Returns:
211 list[str]: Returned path list.
212 &quot;&quot;&quot;
213 assert len(folders) == 2, (&#x27;The len of folders should be 2 with [input_folder, gt_folder]. &#x27;
214 f&#x27;But got {len(folders)}&#x27;)
215 assert len(keys) == 2, f&#x27;The len of keys should be 2 with [input_key, gt_key]. But got {len(keys)}&#x27;
216 input_folder, gt_folder = folders
217 input_key, gt_key = keys
</pre>
</div>
</div>
</div>
<div id="issue-33">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>215<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
211 list[str]: Returned path list.
212 &quot;&quot;&quot;
213 assert len(folders) == 2, (&#x27;The len of folders should be 2 with [input_folder, gt_folder]. &#x27;
214 f&#x27;But got {len(folders)}&#x27;)
215 assert len(keys) == 2, f&#x27;The len of keys should be 2 with [input_key, gt_key]. But got {len(keys)}&#x27;
216 input_folder, gt_folder = folders
217 input_key, gt_key = keys
218
</pre>
</div>
</div>
</div>
<div id="issue-34">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>221<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
217 input_key, gt_key = keys
218
219 input_paths = list(scandir(input_folder))
220 gt_paths = list(scandir(gt_folder))
221 assert len(input_paths) == len(gt_paths), (f&#x27;{input_key} and {gt_key} datasets have different number of images: &#x27;
222 f&#x27;{len(input_paths)}, {len(gt_paths)}.&#x27;)
223 paths = []
224 for gt_path in gt_paths:
225 basename, ext = osp.splitext(osp.basename(gt_path))
</pre>
</div>
</div>
</div>
<div id="issue-35">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>228<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
224 for gt_path in gt_paths:
225 basename, ext = osp.splitext(osp.basename(gt_path))
226 input_name = f&#x27;{filename_tmpl.format(basename)}{ext}&#x27;
227 input_path = osp.join(input_folder, input_name)
228 assert input_name in input_paths, f&#x27;{input_name} is not in {input_key}_paths.&#x27;
229 gt_path = osp.join(gt_folder, gt_path)
230 paths.append(dict([(f&#x27;{input_key}_path&#x27;, input_path), (f&#x27;{gt_key}_path&#x27;, gt_path)]))
231 return paths
</pre>
</div>
</div>
</div>
<div id="issue-36">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/data_util.py</a><br>
<b>Line number: </b>295<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
291
292 Returns:
293 Tensor: DUF downsampled frames.
294 &quot;&quot;&quot;
295 assert scale in (2, 3, 4), f&#x27;Only support scale (2, 3, 4), but got {scale}.&#x27;
296
297 squeeze_flag = False
298 if x.ndim == 4:
</pre>
</div>
</div>
</div>
<div id="issue-37">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>203<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
199
200 Returns:
201 kernel (ndarray):
202 &quot;&quot;&quot;
203 assert kernel_size % 2 == 1, &#x27;Kernel size must be an odd number.&#x27;
204 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
205 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
206 if isotropic is False:
</pre>
</div>
</div>
</div>
<div id="issue-38">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>204<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
200 Returns:
201 kernel (ndarray):
202 &quot;&quot;&quot;
203 assert kernel_size % 2 == 1, &#x27;Kernel size must be an odd number.&#x27;
204 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
205 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
206 if isotropic is False:
207 assert sigma_y_range[0] &lt; sigma_y_range[1], &#x27;Wrong sigma_y_range.&#x27;
</pre>
</div>
</div>
</div>
<div id="issue-39">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>207<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
203 assert kernel_size % 2 == 1, &#x27;Kernel size must be an odd number.&#x27;
204 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
205 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
206 if isotropic is False:
207 assert sigma_y_range[0] &lt; sigma_y_range[1], &#x27;Wrong sigma_y_range.&#x27;
208 assert rotation_range[0] &lt; rotation_range[1], &#x27;Wrong rotation_range.&#x27;
209 sigma_y = np.random.uniform(sigma_y_range[0], sigma_y_range[1])
210 rotation = np.random.uniform(rotation_range[0], rotation_range[1])
</pre>
</div>
</div>
</div>
<div id="issue-40">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>208<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
204 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
205 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
206 if isotropic is False:
207 assert sigma_y_range[0] &lt; sigma_y_range[1], &#x27;Wrong sigma_y_range.&#x27;
208 assert rotation_range[0] &lt; rotation_range[1], &#x27;Wrong rotation_range.&#x27;
209 sigma_y = np.random.uniform(sigma_y_range[0], sigma_y_range[1])
210 rotation = np.random.uniform(rotation_range[0], rotation_range[1])
211 else:
</pre>
</div>
</div>
</div>
<div id="issue-41">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>219<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
215 kernel = bivariate_Gaussian(kernel_size, sigma_x, sigma_y, rotation, isotropic=isotropic)
216
217 # add multiplicative noise
218 if noise_range is not None:
219 assert noise_range[0] &lt; noise_range[1], &#x27;Wrong noise range.&#x27;
220 noise = np.random.uniform(noise_range[0], noise_range[1], size=kernel.shape)
221 kernel = kernel * noise
222 kernel = kernel / np.sum(kernel)
</pre>
</div>
</div>
</div>
<div id="issue-42">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>249<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
245
246 Returns:
247 kernel (ndarray):
248 &quot;&quot;&quot;
249 assert kernel_size % 2 == 1, &#x27;Kernel size must be an odd number.&#x27;
250 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
251 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
252 if isotropic is False:
</pre>
</div>
</div>
</div>
<div id="issue-43">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>250<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
246 Returns:
247 kernel (ndarray):
248 &quot;&quot;&quot;
249 assert kernel_size % 2 == 1, &#x27;Kernel size must be an odd number.&#x27;
250 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
251 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
252 if isotropic is False:
253 assert sigma_y_range[0] &lt; sigma_y_range[1], &#x27;Wrong sigma_y_range.&#x27;
</pre>
</div>
</div>
</div>
<div id="issue-44">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>253<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
249 assert kernel_size % 2 == 1, &#x27;Kernel size must be an odd number.&#x27;
250 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
251 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
252 if isotropic is False:
253 assert sigma_y_range[0] &lt; sigma_y_range[1], &#x27;Wrong sigma_y_range.&#x27;
254 assert rotation_range[0] &lt; rotation_range[1], &#x27;Wrong rotation_range.&#x27;
255 sigma_y = np.random.uniform(sigma_y_range[0], sigma_y_range[1])
256 rotation = np.random.uniform(rotation_range[0], rotation_range[1])
</pre>
</div>
</div>
</div>
<div id="issue-45">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>254<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
250 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
251 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
252 if isotropic is False:
253 assert sigma_y_range[0] &lt; sigma_y_range[1], &#x27;Wrong sigma_y_range.&#x27;
254 assert rotation_range[0] &lt; rotation_range[1], &#x27;Wrong rotation_range.&#x27;
255 sigma_y = np.random.uniform(sigma_y_range[0], sigma_y_range[1])
256 rotation = np.random.uniform(rotation_range[0], rotation_range[1])
257 else:
</pre>
</div>
</div>
</div>
<div id="issue-46">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>271<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
267 kernel = bivariate_generalized_Gaussian(kernel_size, sigma_x, sigma_y, rotation, beta, isotropic=isotropic)
268
269 # add multiplicative noise
270 if noise_range is not None:
271 assert noise_range[0] &lt; noise_range[1], &#x27;Wrong noise range.&#x27;
272 noise = np.random.uniform(noise_range[0], noise_range[1], size=kernel.shape)
273 kernel = kernel * noise
274 kernel = kernel / np.sum(kernel)
</pre>
</div>
</div>
</div>
<div id="issue-47">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>301<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
297
298 Returns:
299 kernel (ndarray):
300 &quot;&quot;&quot;
301 assert kernel_size % 2 == 1, &#x27;Kernel size must be an odd number.&#x27;
302 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
303 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
304 if isotropic is False:
</pre>
</div>
</div>
</div>
<div id="issue-48">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>302<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
298 Returns:
299 kernel (ndarray):
300 &quot;&quot;&quot;
301 assert kernel_size % 2 == 1, &#x27;Kernel size must be an odd number.&#x27;
302 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
303 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
304 if isotropic is False:
305 assert sigma_y_range[0] &lt; sigma_y_range[1], &#x27;Wrong sigma_y_range.&#x27;
</pre>
</div>
</div>
</div>
<div id="issue-49">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>305<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
301 assert kernel_size % 2 == 1, &#x27;Kernel size must be an odd number.&#x27;
302 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
303 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
304 if isotropic is False:
305 assert sigma_y_range[0] &lt; sigma_y_range[1], &#x27;Wrong sigma_y_range.&#x27;
306 assert rotation_range[0] &lt; rotation_range[1], &#x27;Wrong rotation_range.&#x27;
307 sigma_y = np.random.uniform(sigma_y_range[0], sigma_y_range[1])
308 rotation = np.random.uniform(rotation_range[0], rotation_range[1])
</pre>
</div>
</div>
</div>
<div id="issue-50">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>306<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
302 assert sigma_x_range[0] &lt; sigma_x_range[1], &#x27;Wrong sigma_x_range.&#x27;
303 sigma_x = np.random.uniform(sigma_x_range[0], sigma_x_range[1])
304 if isotropic is False:
305 assert sigma_y_range[0] &lt; sigma_y_range[1], &#x27;Wrong sigma_y_range.&#x27;
306 assert rotation_range[0] &lt; rotation_range[1], &#x27;Wrong rotation_range.&#x27;
307 sigma_y = np.random.uniform(sigma_y_range[0], sigma_y_range[1])
308 rotation = np.random.uniform(rotation_range[0], rotation_range[1])
309 else:
</pre>
</div>
</div>
</div>
<div id="issue-51">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>322<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
318
319 kernel = bivariate_plateau(kernel_size, sigma_x, sigma_y, rotation, beta, isotropic=isotropic)
320 # add multiplicative noise
321 if noise_range is not None:
322 assert noise_range[0] &lt; noise_range[1], &#x27;Wrong noise range.&#x27;
323 noise = np.random.uniform(noise_range[0], noise_range[1], size=kernel.shape)
324 kernel = kernel * noise
325 kernel = kernel / np.sum(kernel)
</pre>
</div>
</div>
</div>
<div id="issue-52">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>358<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
354
355 Returns:
356 kernel (ndarray):
357 &quot;&quot;&quot;
358 kernel_type = random.choices(kernel_list, kernel_prob)[0]
359 if kernel_type == &#x27;iso&#x27;:
360 kernel = random_bivariate_Gaussian(
361 kernel_size, sigma_x_range, sigma_y_range, rotation_range, noise_range=noise_range, isotropic=True)
</pre>
</div>
</div>
</div>
<div id="issue-53">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/degradations.py</a><br>
<b>Line number: </b>403<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
399 cutoff (float): cutoff frequency in radians (pi is max)
400 kernel_size (int): horizontal and vertical size, must be odd.
401 pad_to (int): pad kernel size to desired size, must be odd or zero.
402 &quot;&quot;&quot;
403 assert kernel_size % 2 == 1, &#x27;Kernel size must be an odd number.&#x27;
404 kernel = np.fromfunction(
405 lambda x, y: cutoff * special.j1(cutoff * np.sqrt(
406 (x - (kernel_size - 1) / 2)**2 + (y - (kernel_size - 1) / 2)**2)) / (2 * np.pi * np.sqrt(
</pre>
</div>
</div>
</div>
<div id="issue-54">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/ffhq_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/ffhq_dataset.py</a><br>
<b>Line number: </b>62<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
58 except Exception as e:
59 logger = get_root_logger()
60 logger.warning(f&#x27;File client error: {e}, remaining retry times: {retry - 1}&#x27;)
61 # change another file to read
62 index = random.randint(0, self.__len__())
63 gt_path = self.paths[index]
64 time.sleep(1) # sleep 1s for occasional server congestion
65 else:
</pre>
</div>
</div>
</div>
<div id="issue-55">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py</a><br>
<b>Line number: </b>100<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
96 except (IOError, OSError) as e:
97 logger = get_root_logger()
98 logger.warn(f&#x27;File client error: {e}, remaining retry times: {retry - 1}&#x27;)
99 # change another file to read
100 index = random.randint(0, self.__len__())
101 gt_path = self.paths[index]
102 time.sleep(1) # sleep 1s for occasional server congestion
103 else:
</pre>
</div>
</div>
</div>
<div id="issue-56">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py</a><br>
<b>Line number: </b>125<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
121 # crop
122 if img_gt.shape[0] &gt; crop_pad_size or img_gt.shape[1] &gt; crop_pad_size:
123 h, w = img_gt.shape[0:2]
124 # randomly choose top and left coordinates
125 top = random.randint(0, h - crop_pad_size)
126 left = random.randint(0, w - crop_pad_size)
127 img_gt = img_gt[top:top + crop_pad_size, left:left + crop_pad_size, ...]
128
</pre>
</div>
</div>
</div>
<div id="issue-57">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py</a><br>
<b>Line number: </b>126<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
122 if img_gt.shape[0] &gt; crop_pad_size or img_gt.shape[1] &gt; crop_pad_size:
123 h, w = img_gt.shape[0:2]
124 # randomly choose top and left coordinates
125 top = random.randint(0, h - crop_pad_size)
126 left = random.randint(0, w - crop_pad_size)
127 img_gt = img_gt[top:top + crop_pad_size, left:left + crop_pad_size, ...]
128
129 # ------------------------ Generate kernels (used in the first degradation) ------------------------ #
</pre>
</div>
</div>
</div>
<div id="issue-58">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py</a><br>
<b>Line number: </b>130<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
126 left = random.randint(0, w - crop_pad_size)
127 img_gt = img_gt[top:top + crop_pad_size, left:left + crop_pad_size, ...]
128
129 # ------------------------ Generate kernels (used in the first degradation) ------------------------ #
130 kernel_size = random.choice(self.kernel_range)
131 if np.random.uniform() &lt; self.opt[&#x27;sinc_prob&#x27;]:
132 # this sinc filter setting is for kernels ranging from [7, 21]
133 if kernel_size &lt; 13:
</pre>
</div>
</div>
</div>
<div id="issue-59">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py</a><br>
<b>Line number: </b>153<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
149 pad_size = (21 - kernel_size) // 2
150 kernel = np.pad(kernel, ((pad_size, pad_size), (pad_size, pad_size)))
151
152 # ------------------------ Generate kernels (used in the second degradation) ------------------------ #
153 kernel_size = random.choice(self.kernel_range)
154 if np.random.uniform() &lt; self.opt[&#x27;sinc_prob2&#x27;]:
155 if kernel_size &lt; 13:
156 omega_c = np.random.uniform(np.pi / 3, np.pi)
</pre>
</div>
</div>
</div>
<div id="issue-60">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/realesrgan_dataset.py</a><br>
<b>Line number: </b>177<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
173 kernel2 = np.pad(kernel2, ((pad_size, pad_size), (pad_size, pad_size)))
174
175 # ------------------------------------- the final sinc kernel ------------------------------------- #
176 if np.random.uniform() &lt; self.opt[&#x27;final_sinc_prob&#x27;]:
177 kernel_size = random.choice(self.kernel_range)
178 omega_c = np.random.uniform(np.pi / 3, np.pi)
179 sinc_kernel = circular_lowpass_kernel(omega_c, kernel_size, pad_to=21)
180 sinc_kernel = torch.FloatTensor(sinc_kernel)
</pre>
</div>
</div>
</div>
<div id="issue-61">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py</a><br>
<b>Line number: </b>58<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
54 super(REDSDataset, self).__init__()
55 self.opt = opt
56 self.gt_root, self.lq_root = Path(opt[&#x27;dataroot_gt&#x27;]), Path(opt[&#x27;dataroot_lq&#x27;])
57 self.flow_root = Path(opt[&#x27;dataroot_flow&#x27;]) if opt[&#x27;dataroot_flow&#x27;] is not None else None
58 assert opt[&#x27;num_frame&#x27;] % 2 == 1, (f&#x27;num_frame should be odd number, but got {opt[&quot;num_frame&quot;]}&#x27;)
59 self.num_frame = opt[&#x27;num_frame&#x27;]
60 self.num_half_frames = opt[&#x27;num_frame&#x27;] // 2
61
</pre>
</div>
</div>
</div>
<div id="issue-62">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py</a><br>
<b>Line number: </b>110<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
106 clip_name, frame_name = key.split(&#x27;/&#x27;) # key example: 000/00000000
107 center_frame_idx = int(frame_name)
108
109 # determine the neighboring frames
110 interval = random.choice(self.interval_list)
111
112 # ensure not exceeding the borders
113 start_frame_idx = center_frame_idx - self.num_half_frames * interval
</pre>
</div>
</div>
</div>
<div id="issue-63">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py</a><br>
<b>Line number: </b>117<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
113 start_frame_idx = center_frame_idx - self.num_half_frames * interval
114 end_frame_idx = center_frame_idx + self.num_half_frames * interval
115 # each clip has 100 frames starting from 0 to 99
116 while (start_frame_idx &lt; 0) or (end_frame_idx &gt; 99):
117 center_frame_idx = random.randint(0, 99)
118 start_frame_idx = (center_frame_idx - self.num_half_frames * interval)
119 end_frame_idx = center_frame_idx + self.num_half_frames * interval
120 frame_name = f&#x27;{center_frame_idx:08d}&#x27;
</pre>
</div>
</div>
</div>
<div id="issue-64">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py</a><br>
<b>Line number: </b>123<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
119 end_frame_idx = center_frame_idx + self.num_half_frames * interval
120 frame_name = f&#x27;{center_frame_idx:08d}&#x27;
121 neighbor_list = list(range(start_frame_idx, end_frame_idx + 1, interval))
122 # random reverse
123 if self.random_reverse and random.random() &lt; 0.5:
124 neighbor_list.reverse()
125
126 assert len(neighbor_list) == self.num_frame, (f&#x27;Wrong length of neighbor list: {len(neighbor_list)}&#x27;)
</pre>
</div>
</div>
</div>
<div id="issue-65">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py</a><br>
<b>Line number: </b>126<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
122 # random reverse
123 if self.random_reverse and random.random() &lt; 0.5:
124 neighbor_list.reverse()
125
126 assert len(neighbor_list) == self.num_frame, (f&#x27;Wrong length of neighbor list: {len(neighbor_list)}&#x27;)
127
128 # get the GT frame (as the center frame)
129 if self.is_lmdb:
</pre>
</div>
</div>
</div>
<div id="issue-66">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py</a><br>
<b>Line number: </b>308<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
304 key = self.keys[index]
305 clip_name, frame_name = key.split(&#x27;/&#x27;) # key example: 000/00000000
306
307 # determine the neighboring frames
308 interval = random.choice(self.interval_list)
309
310 # ensure not exceeding the borders
311 start_frame_idx = int(frame_name)
</pre>
</div>
</div>
</div>
<div id="issue-67">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py</a><br>
<b>Line number: </b>313<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
309
310 # ensure not exceeding the borders
311 start_frame_idx = int(frame_name)
312 if start_frame_idx &gt; 100 - self.num_frame * interval:
313 start_frame_idx = random.randint(0, 100 - self.num_frame * interval)
314 end_frame_idx = start_frame_idx + self.num_frame * interval
315
316 neighbor_list = list(range(start_frame_idx, end_frame_idx, interval))
</pre>
</div>
</div>
</div>
<div id="issue-68">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/reds_dataset.py</a><br>
<b>Line number: </b>319<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
315
316 neighbor_list = list(range(start_frame_idx, end_frame_idx, interval))
317
318 # random reverse
319 if self.random_reverse and random.random() &lt; 0.5:
320 neighbor_list.reverse()
321
322 # get the neighboring LQ and GT frames
</pre>
</div>
</div>
</div>
<div id="issue-69">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/transforms.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/transforms.py</a><br>
<b>Line number: </b>72<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
68 f&#x27;({lq_patch_size}, {lq_patch_size}). &#x27;
69 f&#x27;Please remove {gt_path}.&#x27;)
70
71 # randomly choose top and left coordinates for lq patch
72 top = random.randint(0, h_lq - lq_patch_size)
73 left = random.randint(0, w_lq - lq_patch_size)
74
75 # crop lq patch
</pre>
</div>
</div>
</div>
<div id="issue-70">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/transforms.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/transforms.py</a><br>
<b>Line number: </b>73<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
69 f&#x27;Please remove {gt_path}.&#x27;)
70
71 # randomly choose top and left coordinates for lq patch
72 top = random.randint(0, h_lq - lq_patch_size)
73 left = random.randint(0, w_lq - lq_patch_size)
74
75 # crop lq patch
76 if input_type == &#x27;Tensor&#x27;:
</pre>
</div>
</div>
</div>
<div id="issue-71">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/transforms.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/transforms.py</a><br>
<b>Line number: </b>116<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
112 list[ndarray] | ndarray: Augmented images and flows. If returned
113 results only have one element, just return ndarray.
114
115 &quot;&quot;&quot;
116 hflip = hflip and random.random() &lt; 0.5
117 vflip = rotation and random.random() &lt; 0.5
118 rot90 = rotation and random.random() &lt; 0.5
119
</pre>
</div>
</div>
</div>
<div id="issue-72">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/transforms.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/transforms.py</a><br>
<b>Line number: </b>117<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
113 results only have one element, just return ndarray.
114
115 &quot;&quot;&quot;
116 hflip = hflip and random.random() &lt; 0.5
117 vflip = rotation and random.random() &lt; 0.5
118 rot90 = rotation and random.random() &lt; 0.5
119
120 def _augment(img):
</pre>
</div>
</div>
</div>
<div id="issue-73">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/transforms.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/transforms.py</a><br>
<b>Line number: </b>118<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
114
115 &quot;&quot;&quot;
116 hflip = hflip and random.random() &lt; 0.5
117 vflip = rotation and random.random() &lt; 0.5
118 rot90 = rotation and random.random() &lt; 0.5
119
120 def _augment(img):
121 if hflip: # horizontal
</pre>
</div>
</div>
</div>
<div id="issue-74">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/video_test_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/video_test_dataset.py</a><br>
<b>Line number: </b>54<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
50 self.data_info = {&#x27;lq_path&#x27;: [], &#x27;gt_path&#x27;: [], &#x27;folder&#x27;: [], &#x27;idx&#x27;: [], &#x27;border&#x27;: []}
51 # file client (io backend)
52 self.file_client = None
53 self.io_backend_opt = opt[&#x27;io_backend&#x27;]
54 assert self.io_backend_opt[&#x27;type&#x27;] != &#x27;lmdb&#x27;, &#x27;No need to use lmdb during validation/test.&#x27;
55
56 logger = get_root_logger()
57 logger.info(f&#x27;Generate data info for VideoTestDataset - {opt[&quot;name&quot;]}&#x27;)
</pre>
</div>
</div>
</div>
<div id="issue-75">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/video_test_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/video_test_dataset.py</a><br>
<b>Line number: </b>76<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
72 img_paths_lq = sorted(list(scandir(subfolder_lq, full_path=True)))
73 img_paths_gt = sorted(list(scandir(subfolder_gt, full_path=True)))
74
75 max_idx = len(img_paths_lq)
76 assert max_idx == len(img_paths_gt), (f&#x27;Different number of images in lq ({max_idx})&#x27;
77 f&#x27; and gt folders ({len(img_paths_gt)})&#x27;)
78
79 self.data_info[&#x27;lq_path&#x27;].extend(img_paths_lq)
80 self.data_info[&#x27;gt_path&#x27;].extend(img_paths_gt)
</pre>
</div>
</div>
</div>
<div id="issue-76">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/video_test_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/video_test_dataset.py</a><br>
<b>Line number: </b>166<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
162
163 # file client (io backend)
164 self.file_client = None
165 self.io_backend_opt = opt[&#x27;io_backend&#x27;]
166 assert self.io_backend_opt[&#x27;type&#x27;] != &#x27;lmdb&#x27;, &#x27;No need to use lmdb during validation/test.&#x27;
167
168 logger = get_root_logger()
169 logger.info(f&#x27;Generate data info for VideoTestDataset - {opt[&quot;name&quot;]}&#x27;)
</pre>
</div>
</div>
</div>
<div id="issue-77">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/vimeo90k_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/vimeo90k_dataset.py</a><br>
<b>Line number: </b>82<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
78 if self.file_client is None:
79 self.file_client = FileClient(self.io_backend_opt.pop(&#x27;type&#x27;), **self.io_backend_opt)
80
81 # random reverse
82 if self.random_reverse and random.random() &lt; 0.5:
83 self.neighbor_list.reverse()
84
85 scale = self.opt[&#x27;scale&#x27;]
</pre>
</div>
</div>
</div>
<div id="issue-78">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/vimeo90k_dataset.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/data/vimeo90k_dataset.py</a><br>
<b>Line number: </b>143<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
139 if self.file_client is None:
140 self.file_client = FileClient(self.io_backend_opt.pop(&#x27;type&#x27;), **self.io_backend_opt)
141
142 # random reverse
143 if self.random_reverse and random.random() &lt; 0.5:
144 self.neighbor_list.reverse()
145
146 scale = self.opt[&#x27;scale&#x27;]
</pre>
</div>
</div>
</div>
<div id="issue-79">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/losses/loss_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/losses/loss_util.py</a><br>
<b>Line number: </b>40<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
36 Tensor: Loss values.
37 &quot;&quot;&quot;
38 # if weight is specified, apply element-wise weight
39 if weight is not None:
40 assert weight.dim() == loss.dim()
41 assert weight.size(1) == 1 or weight.size(1) == loss.size(1)
42 loss = loss * weight
43
</pre>
</div>
</div>
</div>
<div id="issue-80">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/losses/loss_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/losses/loss_util.py</a><br>
<b>Line number: </b>41<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
37 &quot;&quot;&quot;
38 # if weight is specified, apply element-wise weight
39 if weight is not None:
40 assert weight.dim() == loss.dim()
41 assert weight.size(1) == 1 or weight.size(1) == loss.size(1)
42 loss = loss * weight
43
44 # if weight is not specified or reduction is sum, just reduce the loss
</pre>
</div>
</div>
</div>
<div id="issue-81">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/fid.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/fid.py</a><br>
<b>Line number: </b>70<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
66
67 Returns:
68 float: The Frechet Distance.
69 &quot;&quot;&quot;
70 assert mu1.shape == mu2.shape, &#x27;Two mean vectors have different lengths&#x27;
71 assert sigma1.shape == sigma2.shape, (&#x27;Two covariances have different dimensions&#x27;)
72
73 cov_sqrt, _ = linalg.sqrtm(sigma1 @ sigma2, disp=False)
</pre>
</div>
</div>
</div>
<div id="issue-82">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/fid.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/fid.py</a><br>
<b>Line number: </b>71<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
67 Returns:
68 float: The Frechet Distance.
69 &quot;&quot;&quot;
70 assert mu1.shape == mu2.shape, &#x27;Two mean vectors have different lengths&#x27;
71 assert sigma1.shape == sigma2.shape, (&#x27;Two covariances have different dimensions&#x27;)
72
73 cov_sqrt, _ = linalg.sqrtm(sigma1 @ sigma2, disp=False)
74
</pre>
</div>
</div>
</div>
<div id="issue-83">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/niqe.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/niqe.py</a><br>
<b>Line number: </b>97<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
93 Default: 96 (the official recommended value).
94 block_size_w (int): Width of the blocks in to which image is divided.
95 Default: 96 (the official recommended value).
96 &quot;&quot;&quot;
97 assert img.ndim == 2, (&#x27;Input image must be a gray or Y (of YCbCr) image with shape (h, w).&#x27;)
98 # crop image
99 h, w = img.shape
100 num_block_h = math.floor(h / block_size_h)
</pre>
</div>
</div>
</div>
<div id="issue-84">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/psnr_ssim.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/psnr_ssim.py</a><br>
<b>Line number: </b>28<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
24 Returns:
25 float: PSNR result.
26 &quot;&quot;&quot;
27
28 assert img.shape == img2.shape, (f&#x27;Image shapes are different: {img.shape}, {img2.shape}.&#x27;)
29 if input_order not in [&#x27;HWC&#x27;, &#x27;CHW&#x27;]:
30 raise ValueError(f&#x27;Wrong input_order {input_order}. Supported input_orders are &quot;HWC&quot; and &quot;CHW&quot;&#x27;)
31 img = reorder_image(img, input_order=input_order)
</pre>
</div>
</div>
</div>
<div id="issue-85">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/psnr_ssim.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/psnr_ssim.py</a><br>
<b>Line number: </b>67<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
63 Returns:
64 float: PSNR result.
65 &quot;&quot;&quot;
66
67 assert img.shape == img2.shape, (f&#x27;Image shapes are different: {img.shape}, {img2.shape}.&#x27;)
68
69 if crop_border != 0:
70 img = img[:, :, crop_border:-crop_border, crop_border:-crop_border]
</pre>
</div>
</div>
</div>
<div id="issue-86">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/psnr_ssim.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/psnr_ssim.py</a><br>
<b>Line number: </b>109<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
105 Returns:
106 float: SSIM result.
107 &quot;&quot;&quot;
108
109 assert img.shape == img2.shape, (f&#x27;Image shapes are different: {img.shape}, {img2.shape}.&#x27;)
110 if input_order not in [&#x27;HWC&#x27;, &#x27;CHW&#x27;]:
111 raise ValueError(f&#x27;Wrong input_order {input_order}. Supported input_orders are &quot;HWC&quot; and &quot;CHW&quot;&#x27;)
112 img = reorder_image(img, input_order=input_order)
</pre>
</div>
</div>
</div>
<div id="issue-87">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/psnr_ssim.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/metrics/psnr_ssim.py</a><br>
<b>Line number: </b>155<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
151 Returns:
152 float: SSIM result.
153 &quot;&quot;&quot;
154
155 assert img.shape == img2.shape, (f&#x27;Image shapes are different: {img.shape}, {img2.shape}.&#x27;)
156
157 if crop_border != 0:
158 img = img[:, :, crop_border:-crop_border, crop_border:-crop_border]
</pre>
</div>
</div>
</div>
<div id="issue-88">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/base_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/base_model.py</a><br>
<b>Line number: </b>213<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
209 save_path = os.path.join(self.opt[&#x27;path&#x27;][&#x27;models&#x27;], save_filename)
210
211 net = net if isinstance(net, list) else [net]
212 param_key = param_key if isinstance(param_key, list) else [param_key]
213 assert len(net) == len(param_key), &#x27;The lengths of net and param_key should be the same.&#x27;
214
215 save_dict = {}
216 for net_, param_key_ in zip(net, param_key):
</pre>
</div>
</div>
</div>
<div id="issue-89">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/base_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/base_model.py</a><br>
<b>Line number: </b>348<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
344 resume_state (dict): Resume state.
345 &quot;&quot;&quot;
346 resume_optimizers = resume_state[&#x27;optimizers&#x27;]
347 resume_schedulers = resume_state[&#x27;schedulers&#x27;]
348 assert len(resume_optimizers) == len(self.optimizers), &#x27;Wrong lengths of optimizers&#x27;
349 assert len(resume_schedulers) == len(self.schedulers), &#x27;Wrong lengths of schedulers&#x27;
350 for i, o in enumerate(resume_optimizers):
351 self.optimizers[i].load_state_dict(o)
</pre>
</div>
</div>
</div>
<div id="issue-90">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/base_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/base_model.py</a><br>
<b>Line number: </b>349<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
345 &quot;&quot;&quot;
346 resume_optimizers = resume_state[&#x27;optimizers&#x27;]
347 resume_schedulers = resume_state[&#x27;schedulers&#x27;]
348 assert len(resume_optimizers) == len(self.optimizers), &#x27;Wrong lengths of optimizers&#x27;
349 assert len(resume_schedulers) == len(self.schedulers), &#x27;Wrong lengths of schedulers&#x27;
350 for i, o in enumerate(resume_optimizers):
351 self.optimizers[i].load_state_dict(o)
352 for i, s in enumerate(resume_schedulers):
</pre>
</div>
</div>
</div>
<div id="issue-91">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/lr_scheduler.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/lr_scheduler.py</a><br>
<b>Line number: </b>24<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
20 self.milestones = Counter(milestones)
21 self.gamma = gamma
22 self.restarts = restarts
23 self.restart_weights = restart_weights
24 assert len(self.restarts) == len(self.restart_weights), &#x27;restarts and their weights do not match.&#x27;
25 super(MultiStepRestartLR, self).__init__(optimizer, last_epoch)
26
27 def get_lr(self):
</pre>
</div>
</div>
</div>
<div id="issue-92">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/lr_scheduler.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/lr_scheduler.py</a><br>
<b>Line number: </b>81<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
77 def __init__(self, optimizer, periods, restart_weights=(1, ), eta_min=0, last_epoch=-1):
78 self.periods = periods
79 self.restart_weights = restart_weights
80 self.eta_min = eta_min
81 assert (len(self.periods) == len(
82 self.restart_weights)), &#x27;periods and restart_weights should have the same length.&#x27;
83 self.cumulative_period = [sum(self.periods[0:i + 1]) for i in range(0, len(self.periods))]
84 super(CosineAnnealingRestartLR, self).__init__(optimizer, last_epoch)
85
</pre>
</div>
</div>
</div>
<div id="issue-93">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py</a><br>
<b>Line number: </b>42<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
38 &quot;&quot;&quot;
39 # initialize
40 b, c, h, w = self.lq.size()
41 if not hasattr(self, &#x27;queue_lr&#x27;):
42 assert self.queue_size % b == 0, f&#x27;queue size {self.queue_size} should be divisible by batch size {b}&#x27;
43 self.queue_lr = torch.zeros(self.queue_size, c, h, w).cuda()
44 _, c, h, w = self.gt.size()
45 self.queue_gt = torch.zeros(self.queue_size, c, h, w).cuda()
</pre>
</div>
</div>
</div>
<div id="issue-94">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py</a><br>
<b>Line number: </b>87<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
83 # ----------------------- The first degradation process ----------------------- #
84 # blur
85 out = filter2D(self.gt_usm, self.kernel1)
86 # random resize
87 updown_type = random.choices([&#x27;up&#x27;, &#x27;down&#x27;, &#x27;keep&#x27;], self.opt[&#x27;resize_prob&#x27;])[0]
88 if updown_type == &#x27;up&#x27;:
89 scale = np.random.uniform(1, self.opt[&#x27;resize_range&#x27;][1])
90 elif updown_type == &#x27;down&#x27;:
</pre>
</div>
</div>
</div>
<div id="issue-95">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py</a><br>
<b>Line number: </b>94<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
90 elif updown_type == &#x27;down&#x27;:
91 scale = np.random.uniform(self.opt[&#x27;resize_range&#x27;][0], 1)
92 else:
93 scale = 1
94 mode = random.choice([&#x27;area&#x27;, &#x27;bilinear&#x27;, &#x27;bicubic&#x27;])
95 out = F.interpolate(out, scale_factor=scale, mode=mode)
96 # add noise
97 gray_noise_prob = self.opt[&#x27;gray_noise_prob&#x27;]
</pre>
</div>
</div>
</div>
<div id="issue-96">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py</a><br>
<b>Line number: </b>118<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
114 # blur
115 if np.random.uniform() &lt; self.opt[&#x27;second_blur_prob&#x27;]:
116 out = filter2D(out, self.kernel2)
117 # random resize
118 updown_type = random.choices([&#x27;up&#x27;, &#x27;down&#x27;, &#x27;keep&#x27;], self.opt[&#x27;resize_prob2&#x27;])[0]
119 if updown_type == &#x27;up&#x27;:
120 scale = np.random.uniform(1, self.opt[&#x27;resize_range2&#x27;][1])
121 elif updown_type == &#x27;down&#x27;:
</pre>
</div>
</div>
</div>
<div id="issue-97">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py</a><br>
<b>Line number: </b>125<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
121 elif updown_type == &#x27;down&#x27;:
122 scale = np.random.uniform(self.opt[&#x27;resize_range2&#x27;][0], 1)
123 else:
124 scale = 1
125 mode = random.choice([&#x27;area&#x27;, &#x27;bilinear&#x27;, &#x27;bicubic&#x27;])
126 out = F.interpolate(
127 out, size=(int(ori_h / self.opt[&#x27;scale&#x27;] * scale), int(ori_w / self.opt[&#x27;scale&#x27;] * scale)), mode=mode)
128 # add noise
</pre>
</div>
</div>
</div>
<div id="issue-98">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py</a><br>
<b>Line number: </b>150<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
146 # 2. JPEG compression + [resize back + sinc filter]
147 # Empirically, we find other combinations (sinc + JPEG + Resize) will introduce twisted lines.
148 if np.random.uniform() &lt; 0.5:
149 # resize back + the final sinc filter
150 mode = random.choice([&#x27;area&#x27;, &#x27;bilinear&#x27;, &#x27;bicubic&#x27;])
151 out = F.interpolate(out, size=(ori_h // self.opt[&#x27;scale&#x27;], ori_w // self.opt[&#x27;scale&#x27;]), mode=mode)
152 out = filter2D(out, self.sinc_kernel)
153 # JPEG compression
</pre>
</div>
</div>
</div>
<div id="issue-99">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrgan_model.py</a><br>
<b>Line number: </b>163<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
159 jpeg_p = out.new_zeros(out.size(0)).uniform_(*self.opt[&#x27;jpeg_range2&#x27;])
160 out = torch.clamp(out, 0, 1)
161 out = self.jpeger(out, quality=jpeg_p)
162 # resize back + the final sinc filter
163 mode = random.choice([&#x27;area&#x27;, &#x27;bilinear&#x27;, &#x27;bicubic&#x27;])
164 out = F.interpolate(out, size=(ori_h // self.opt[&#x27;scale&#x27;], ori_w // self.opt[&#x27;scale&#x27;]), mode=mode)
165 out = filter2D(out, self.sinc_kernel)
166
</pre>
</div>
</div>
</div>
<div id="issue-100">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py</a><br>
<b>Line number: </b>41<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
37 &quot;&quot;&quot;
38 # initialize
39 b, c, h, w = self.lq.size()
40 if not hasattr(self, &#x27;queue_lr&#x27;):
41 assert self.queue_size % b == 0, f&#x27;queue size {self.queue_size} should be divisible by batch size {b}&#x27;
42 self.queue_lr = torch.zeros(self.queue_size, c, h, w).cuda()
43 _, c, h, w = self.gt.size()
44 self.queue_gt = torch.zeros(self.queue_size, c, h, w).cuda()
</pre>
</div>
</div>
</div>
<div id="issue-101">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py</a><br>
<b>Line number: </b>88<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
84 # ----------------------- The first degradation process ----------------------- #
85 # blur
86 out = filter2D(self.gt, self.kernel1)
87 # random resize
88 updown_type = random.choices([&#x27;up&#x27;, &#x27;down&#x27;, &#x27;keep&#x27;], self.opt[&#x27;resize_prob&#x27;])[0]
89 if updown_type == &#x27;up&#x27;:
90 scale = np.random.uniform(1, self.opt[&#x27;resize_range&#x27;][1])
91 elif updown_type == &#x27;down&#x27;:
</pre>
</div>
</div>
</div>
<div id="issue-102">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py</a><br>
<b>Line number: </b>95<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
91 elif updown_type == &#x27;down&#x27;:
92 scale = np.random.uniform(self.opt[&#x27;resize_range&#x27;][0], 1)
93 else:
94 scale = 1
95 mode = random.choice([&#x27;area&#x27;, &#x27;bilinear&#x27;, &#x27;bicubic&#x27;])
96 out = F.interpolate(out, scale_factor=scale, mode=mode)
97 # add noise
98 gray_noise_prob = self.opt[&#x27;gray_noise_prob&#x27;]
</pre>
</div>
</div>
</div>
<div id="issue-103">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py</a><br>
<b>Line number: </b>119<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
115 # blur
116 if np.random.uniform() &lt; self.opt[&#x27;second_blur_prob&#x27;]:
117 out = filter2D(out, self.kernel2)
118 # random resize
119 updown_type = random.choices([&#x27;up&#x27;, &#x27;down&#x27;, &#x27;keep&#x27;], self.opt[&#x27;resize_prob2&#x27;])[0]
120 if updown_type == &#x27;up&#x27;:
121 scale = np.random.uniform(1, self.opt[&#x27;resize_range2&#x27;][1])
122 elif updown_type == &#x27;down&#x27;:
</pre>
</div>
</div>
</div>
<div id="issue-104">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py</a><br>
<b>Line number: </b>126<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
122 elif updown_type == &#x27;down&#x27;:
123 scale = np.random.uniform(self.opt[&#x27;resize_range2&#x27;][0], 1)
124 else:
125 scale = 1
126 mode = random.choice([&#x27;area&#x27;, &#x27;bilinear&#x27;, &#x27;bicubic&#x27;])
127 out = F.interpolate(
128 out, size=(int(ori_h / self.opt[&#x27;scale&#x27;] * scale), int(ori_w / self.opt[&#x27;scale&#x27;] * scale)), mode=mode)
129 # add noise
</pre>
</div>
</div>
</div>
<div id="issue-105">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py</a><br>
<b>Line number: </b>151<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
147 # 2. JPEG compression + [resize back + sinc filter]
148 # Empirically, we find other combinations (sinc + JPEG + Resize) will introduce twisted lines.
149 if np.random.uniform() &lt; 0.5:
150 # resize back + the final sinc filter
151 mode = random.choice([&#x27;area&#x27;, &#x27;bilinear&#x27;, &#x27;bicubic&#x27;])
152 out = F.interpolate(out, size=(ori_h // self.opt[&#x27;scale&#x27;], ori_w // self.opt[&#x27;scale&#x27;]), mode=mode)
153 out = filter2D(out, self.sinc_kernel)
154 # JPEG compression
</pre>
</div>
</div>
</div>
<div id="issue-106">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/realesrnet_model.py</a><br>
<b>Line number: </b>164<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
160 jpeg_p = out.new_zeros(out.size(0)).uniform_(*self.opt[&#x27;jpeg_range2&#x27;])
161 out = torch.clamp(out, 0, 1)
162 out = self.jpeger(out, quality=jpeg_p)
163 # resize back + the final sinc filter
164 mode = random.choice([&#x27;area&#x27;, &#x27;bilinear&#x27;, &#x27;bicubic&#x27;])
165 out = F.interpolate(out, size=(ori_h // self.opt[&#x27;scale&#x27;], ori_w // self.opt[&#x27;scale&#x27;]), mode=mode)
166 out = filter2D(out, self.sinc_kernel)
167
</pre>
</div>
</div>
</div>
<div id="issue-107">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/stylegan2_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/stylegan2_model.py</a><br>
<b>Line number: </b>180<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
176 noises = torch.randn(num_noise, batch, self.num_style_feat, device=self.device).unbind(0)
177 return noises
178
179 def mixing_noise(self, batch, prob):
180 if random.random() &lt; prob:
181 return self.make_noise(batch, 2)
182 else:
183 return [self.make_noise(batch, 1)]
</pre>
</div>
</div>
</div>
<div id="issue-108">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/stylegan2_model.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/models/stylegan2_model.py</a><br>
<b>Line number: </b>266<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
262 if self.opt[&#x27;rank&#x27;] == 0:
263 self.nondist_validation(dataloader, current_iter, tb_logger, save_img)
264
265 def nondist_validation(self, dataloader, current_iter, tb_logger, save_img):
266 assert dataloader is None, &#x27;Validation dataloader should be None.&#x27;
267 self.test()
268 result = tensor2img(self.output, min_max=(-1, 1))
269 if self.opt[&#x27;is_train&#x27;]:
</pre>
</div>
</div>
</div>
<div id="issue-109">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/ops/dcn/deform_conv.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/ops/dcn/deform_conv.py</a><br>
<b>Line number: </b>65<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
61 if not input.is_cuda:
62 raise NotImplementedError
63 else:
64 cur_im2col_step = min(ctx.im2col_step, input.shape[0])
65 assert (input.shape[0] % cur_im2col_step) == 0, &#x27;im2col step must divide batchsize&#x27;
66 deform_conv_ext.deform_conv_forward(input, weight,
67 offset, output, ctx.bufs_[0], ctx.bufs_[1], weight.size(3),
68 weight.size(2), ctx.stride[1], ctx.stride[0], ctx.padding[1],
</pre>
</div>
</div>
</div>
<div id="issue-110">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/ops/dcn/deform_conv.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/ops/dcn/deform_conv.py</a><br>
<b>Line number: </b>84<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
80 if not grad_output.is_cuda:
81 raise NotImplementedError
82 else:
83 cur_im2col_step = min(ctx.im2col_step, input.shape[0])
84 assert (input.shape[0] % cur_im2col_step) == 0, &#x27;im2col step must divide batchsize&#x27;
85
86 if ctx.needs_input_grad[0] or ctx.needs_input_grad[1]:
87 grad_input = torch.zeros_like(input)
</pre>
</div>
</div>
</div>
<div id="issue-111">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/ops/dcn/deform_conv.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/ops/dcn/deform_conv.py</a><br>
<b>Line number: </b>205<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
201 deformable_groups=1,
202 bias=False):
203 super(DeformConv, self).__init__()
204
205 assert not bias
206 assert in_channels % groups == 0, f&#x27;in_channels {in_channels} is not divisible by groups {groups}&#x27;
207 assert out_channels % groups == 0, f&#x27;out_channels {out_channels} is not divisible by groups {groups}&#x27;
208
</pre>
</div>
</div>
</div>
<div id="issue-112">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/ops/dcn/deform_conv.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/ops/dcn/deform_conv.py</a><br>
<b>Line number: </b>206<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
202 bias=False):
203 super(DeformConv, self).__init__()
204
205 assert not bias
206 assert in_channels % groups == 0, f&#x27;in_channels {in_channels} is not divisible by groups {groups}&#x27;
207 assert out_channels % groups == 0, f&#x27;out_channels {out_channels} is not divisible by groups {groups}&#x27;
208
209 self.in_channels = in_channels
</pre>
</div>
</div>
</div>
<div id="issue-113">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/ops/dcn/deform_conv.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/ops/dcn/deform_conv.py</a><br>
<b>Line number: </b>207<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
203 super(DeformConv, self).__init__()
204
205 assert not bias
206 assert in_channels % groups == 0, f&#x27;in_channels {in_channels} is not divisible by groups {groups}&#x27;
207 assert out_channels % groups == 0, f&#x27;out_channels {out_channels} is not divisible by groups {groups}&#x27;
208
209 self.in_channels = in_channels
210 self.out_channels = out_channels
</pre>
</div>
</div>
</div>
<div id="issue-114">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/train.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/train.py</a><br>
<b>Line number: </b>21<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
17 def init_tb_loggers(opt):
18 # initialize wandb logger before tensorboard logger to allow proper sync
19 if (opt[&#x27;logger&#x27;].get(&#x27;wandb&#x27;) is not None) and (opt[&#x27;logger&#x27;][&#x27;wandb&#x27;].get(&#x27;project&#x27;)
20 is not None) and (&#x27;debug&#x27; not in opt[&#x27;name&#x27;]):
21 assert opt[&#x27;logger&#x27;].get(&#x27;use_tb_logger&#x27;) is True, (&#x27;should turn on tensorboard when using wandb&#x27;)
22 init_wandb_logger(opt)
23 tb_logger = None
24 if opt[&#x27;logger&#x27;].get(&#x27;use_tb_logger&#x27;) and &#x27;debug&#x27; not in opt[&#x27;name&#x27;]:
</pre>
</div>
</div>
</div>
<div id="issue-115">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Consider possible security implications associated with the subprocess module.<br>
<b>Test ID:</b> B404<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/dist_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/dist_util.py</a><br>
<b>Line number: </b>4<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b404-import-subprocess" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b404-import-subprocess</a><br>
<div class="code">
<pre>
1 # Modified from https://github.com/open-mmlab/mmcv/blob/master/mmcv/runner/dist_utils.py # noqa: E501
2 import functools
3 import os
4 import subprocess
5 import torch
6 import torch.distributed as dist
7 import torch.multiprocessing as mp
8
</pre>
</div>
</div>
</div>
<div id="issue-116">
<div class="issue-block issue-sev-high">
<b>start_process_with_a_shell: </b> Starting a process with a shell, possible injection detected, security issue.<br>
<b>Test ID:</b> B605<br>
<b>Severity: </b>HIGH<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/dist_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/dist_util.py</a><br>
<b>Line number: </b>44<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b605_start_process_with_a_shell.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b605_start_process_with_a_shell.html</a><br>
<div class="code">
<pre>
40 ntasks = int(os.environ[&#x27;SLURM_NTASKS&#x27;])
41 node_list = os.environ[&#x27;SLURM_NODELIST&#x27;]
42 num_gpus = torch.cuda.device_count()
43 torch.cuda.set_device(proc_id % num_gpus)
44 addr = subprocess.getoutput(f&#x27;scontrol show hostname {node_list} | head -n1&#x27;)
45 # specify master port
46 if port is not None:
47 os.environ[&#x27;MASTER_PORT&#x27;] = str(port)
</pre>
</div>
</div>
</div>
<div id="issue-117">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/file_client.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/file_client.py</a><br>
<b>Line number: </b>107<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
103 if isinstance(db_paths, list):
104 self.db_paths = [str(v) for v in db_paths]
105 elif isinstance(db_paths, str):
106 self.db_paths = [str(db_paths)]
107 assert len(client_keys) == len(self.db_paths), (&#x27;client_keys and db_paths should have the same length, &#x27;
108 f&#x27;but received {len(client_keys)} and {len(self.db_paths)}.&#x27;)
109
110 self._client = {}
111 for client, path in zip(client_keys, self.db_paths):
</pre>
</div>
</div>
</div>
<div id="issue-118">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/file_client.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/file_client.py</a><br>
<b>Line number: </b>122<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
118 filepath (str | obj:`Path`): Here, filepath is the lmdb key.
119 client_key (str): Used for distinguishing different lmdb envs.
120 &quot;&quot;&quot;
121 filepath = str(filepath)
122 assert client_key in self._client, (f&#x27;client_key {client_key} is not in lmdb clients.&#x27;)
123 client = self._client[client_key]
124 with client.begin(write=False) as txn:
125 value_buf = txn.get(filepath.encode(&#x27;ascii&#x27;))
</pre>
</div>
</div>
</div>
<div id="issue-119">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/flow_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/flow_util.py</a><br>
<b>Line number: </b>21<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
17 Returns:
18 ndarray: Optical flow represented as a (h, w, 2) numpy array
19 &quot;&quot;&quot;
20 if quantize:
21 assert concat_axis in [0, 1]
22 cat_flow = cv2.imread(flow_path, cv2.IMREAD_UNCHANGED)
23 if cat_flow.ndim != 2:
24 raise IOError(f&#x27;{flow_path} is not a valid quantized flow file, its dimension is {cat_flow.ndim}.&#x27;)
</pre>
</div>
</div>
</div>
<div id="issue-120">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/flow_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/flow_util.py</a><br>
<b>Line number: </b>25<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
21 assert concat_axis in [0, 1]
22 cat_flow = cv2.imread(flow_path, cv2.IMREAD_UNCHANGED)
23 if cat_flow.ndim != 2:
24 raise IOError(f&#x27;{flow_path} is not a valid quantized flow file, its dimension is {cat_flow.ndim}.&#x27;)
25 assert cat_flow.shape[concat_axis] % 2 == 0
26 dx, dy = np.split(cat_flow, 2, axis=concat_axis)
27 flow = dequantize_flow(dx, dy, *args, **kwargs)
28 else:
</pre>
</div>
</div>
</div>
<div id="issue-121">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/flow_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/flow_util.py</a><br>
<b>Line number: </b>69<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
65 flow = flow.astype(np.float32)
66 flow.tofile(f)
67 f.flush()
68 else:
69 assert concat_axis in [0, 1]
70 dx, dy = quantize_flow(flow, *args, **kwargs)
71 dxdy = np.concatenate((dx, dy), axis=concat_axis)
72 os.makedirs(os.path.dirname(filename), exist_ok=True)
</pre>
</div>
</div>
</div>
<div id="issue-122">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/flow_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/flow_util.py</a><br>
<b>Line number: </b>114<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
110
111 Returns:
112 ndarray: Dequantized flow.
113 &quot;&quot;&quot;
114 assert dx.shape == dy.shape
115 assert dx.ndim == 2 or (dx.ndim == 3 and dx.shape[-1] == 1)
116
117 dx, dy = [dequantize(d, -max_val, max_val, 255) for d in [dx, dy]]
</pre>
</div>
</div>
</div>
<div id="issue-123">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/flow_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/flow_util.py</a><br>
<b>Line number: </b>115<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
111 Returns:
112 ndarray: Dequantized flow.
113 &quot;&quot;&quot;
114 assert dx.shape == dy.shape
115 assert dx.ndim == 2 or (dx.ndim == 3 and dx.shape[-1] == 1)
116
117 dx, dy = [dequantize(d, -max_val, max_val, 255) for d in [dx, dy]]
118
</pre>
</div>
</div>
</div>
<div id="issue-124">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/lmdb_util.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/lmdb_util.py</a><br>
<b>Line number: </b>61<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
57 map_size (int | None): Map size for lmdb env. If None, use the
58 estimated size from images. Default: None
59 &quot;&quot;&quot;
60
61 assert len(img_path_list) == len(keys), (&#x27;img_path_list and keys should have the same length, &#x27;
62 f&#x27;but got {len(img_path_list)} and {len(keys)}&#x27;)
63 print(f&#x27;Create lmdb for {data_path}, save to {lmdb_path}...&#x27;)
64 print(f&#x27;Totoal images: {len(img_path_list)}&#x27;)
65 if not lmdb_path.endswith(&#x27;.lmdb&#x27;):
</pre>
</div>
</div>
</div>
<div id="issue-125">
<div class="issue-block issue-sev-medium">
<b>blacklist: </b> Use of possibly insecure function - consider using safer ast.literal_eval.<br>
<b>Test ID:</b> B307<br>
<b>Severity: </b>MEDIUM<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/options.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/options.py</a><br>
<b>Line number: </b>77<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval</a><br>
<div class="code">
<pre>
73 elif value.replace(&#x27;.&#x27;, &#x27;&#x27;, 1).isdigit() and value.count(&#x27;.&#x27;) &lt; 2:
74 return float(value)
75 # list
76 if value.startswith(&#x27;[&#x27;):
77 return eval(value)
78 # str
79 return value
80
</pre>
</div>
</div>
</div>
<div id="issue-126">
<div class="issue-block issue-sev-medium">
<b>yaml_load: </b> Use of unsafe yaml load. Allows instantiation of arbitrary objects. Consider yaml.safe_load().<br>
<b>Test ID:</b> B506<br>
<b>Severity: </b>MEDIUM<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/20.html" target="_blank">CWE-20</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/options.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/options.py</a><br>
<b>Line number: </b>95<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b506_yaml_load.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b506_yaml_load.html</a><br>
<div class="code">
<pre>
91 args = parser.parse_args()
92
93 # parse yml to dict
94 with open(args.opt, mode=&#x27;r&#x27;) as f:
95 opt = yaml.load(f, Loader=ordered_yaml()[0])
96
97 # distributed settings
98 if args.launcher == &#x27;none&#x27;:
</pre>
</div>
</div>
</div>
<div id="issue-127">
<div class="issue-block issue-sev-low">
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
<b>Test ID:</b> B311<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/options.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/options.py</a><br>
<b>Line number: </b>112<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
<div class="code">
<pre>
108
109 # random seed
110 seed = opt.get(&#x27;manual_seed&#x27;)
111 if seed is None:
112 seed = random.randint(1, 10000)
113 opt[&#x27;manual_seed&#x27;] = seed
114 set_random_seed(seed + opt[&#x27;rank&#x27;])
115
</pre>
</div>
</div>
</div>
<div id="issue-128">
<div class="issue-block issue-sev-medium">
<b>exec_used: </b> Use of exec detected.<br>
<b>Test ID:</b> B102<br>
<b>Severity: </b>MEDIUM<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/options.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/options.py</a><br>
<b>Line number: </b>128<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b102_exec_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b102_exec_used.html</a><br>
<div class="code">
<pre>
124 for key in keys.split(&#x27;:&#x27;):
125 eval_str += f&#x27;[&quot;{key}&quot;]&#x27;
126 eval_str += &#x27;=value&#x27;
127 # using exec function
128 exec(eval_str)
129
130 opt[&#x27;auto_resume&#x27;] = args.auto_resume
131 opt[&#x27;is_train&#x27;] = is_train
</pre>
</div>
</div>
</div>
<div id="issue-129">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/registry.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_basicsr/utils/registry.py</a><br>
<b>Line number: </b>42<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
38 def _do_register(self, name, obj, suffix=None):
39 if isinstance(suffix, str):
40 name = name + &#x27;_&#x27; + suffix
41
42 assert (name not in self._obj_map), (f&quot;An object named &#x27;{name}&#x27; was already registered &quot;
43 f&quot;in &#x27;{self._name}&#x27; registry!&quot;)
44 self._obj_map[name] = obj
45
46 def register(self, obj=None, suffix=None):
</pre>
</div>
</div>
</div>
<div id="issue-130">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_facelib/detection/retinaface/retinaface_net.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_facelib/detection/retinaface/retinaface_net.py</a><br>
<b>Line number: </b>40<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
36 class SSH(nn.Module):
37
38 def __init__(self, in_channel, out_channel):
39 super(SSH, self).__init__()
40 assert out_channel % 4 == 0
41 leaky = 0
42 if (out_channel &lt;= 64):
43 leaky = 0.1
</pre>
</div>
</div>
</div>
<div id="issue-131">
<div class="issue-block issue-sev-medium">
<b>blacklist: </b> Use of possibly insecure function - consider using safer ast.literal_eval.<br>
<b>Test ID:</b> B307<br>
<b>Severity: </b>MEDIUM<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_facelib/detection/yolov5face/models/yolo.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_facelib/detection/yolov5face/models/yolo.py</a><br>
<b>Line number: </b>188<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval</a><br>
<div class="code">
<pre>
184 no = na * (nc + 5) # number of outputs = anchors * (classes + 5)
185
186 layers, save, c2 = [], [], ch[-1] # layers, savelist, ch out
187 for i, (f, n, m, args) in enumerate(d[&quot;backbone&quot;] + d[&quot;head&quot;]): # from, number, module, args
188 m = eval(m) if isinstance(m, str) else m # eval strings
189 for j, a in enumerate(args):
190 try:
191 args[j] = eval(a) if isinstance(a, str) else a # eval strings
</pre>
</div>
</div>
</div>
<div id="issue-132">
<div class="issue-block issue-sev-medium">
<b>blacklist: </b> Use of possibly insecure function - consider using safer ast.literal_eval.<br>
<b>Test ID:</b> B307<br>
<b>Severity: </b>MEDIUM<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_facelib/detection/yolov5face/models/yolo.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_facelib/detection/yolov5face/models/yolo.py</a><br>
<b>Line number: </b>191<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval</a><br>
<div class="code">
<pre>
187 for i, (f, n, m, args) in enumerate(d[&quot;backbone&quot;] + d[&quot;head&quot;]): # from, number, module, args
188 m = eval(m) if isinstance(m, str) else m # eval strings
189 for j, a in enumerate(args):
190 try:
191 args[j] = eval(a) if isinstance(a, str) else a # eval strings
192 except:
193 pass
194
</pre>
</div>
</div>
</div>
<div id="issue-133">
<div class="issue-block issue-sev-low">
<b>try_except_pass: </b> Try, Except, Pass detected.<br>
<b>Test ID:</b> B110<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_facelib/detection/yolov5face/models/yolo.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_facelib/detection/yolov5face/models/yolo.py</a><br>
<b>Line number: </b>192<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b110_try_except_pass.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b110_try_except_pass.html</a><br>
<div class="code">
<pre>
188 m = eval(m) if isinstance(m, str) else m # eval strings
189 for j, a in enumerate(args):
190 try:
191 args[j] = eval(a) if isinstance(a, str) else a # eval strings
192 except:
193 pass
194
195 n = max(round(n * gd), 1) if n &gt; 1 else n # depth gain
196 if m in [
</pre>
</div>
</div>
</div>
<div id="issue-134">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_facelib/parsing/parsenet.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_facelib/parsing/parsenet.py</a><br>
<b>Line number: </b>33<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
29 self.norm = nn.LayerNorm(normalize_shape)
30 elif norm_type == &#x27;none&#x27;:
31 self.norm = lambda x: x * 1.0
32 else:
33 assert 1 == 0, f&#x27;Norm type {norm_type} not support.&#x27;
34
35 def forward(self, x, ref=None):
36 if self.norm_type == &#x27;spade&#x27;:
</pre>
</div>
</div>
</div>
<div id="issue-135">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_facelib/parsing/parsenet.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_facelib/parsing/parsenet.py</a><br>
<b>Line number: </b>68<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
64 self.func = nn.SELU(True)
65 elif relu_type == &#x27;none&#x27;:
66 self.func = lambda x: x * 1.0
67 else:
68 assert 1 == 0, f&#x27;Relu type {relu_type} not support.&#x27;
69
70 def forward(self, x):
71 return self.func(x)
</pre>
</div>
</div>
</div>
<div id="issue-136">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_facelib/utils/face_restoration_helper.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_facelib/utils/face_restoration_helper.py</a><br>
<b>Line number: </b>65<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
61 self.template_3points = template_3points # improve robustness
62 self.upscale_factor = upscale_factor
63 # the cropped face ratio based on the square face
64 self.crop_ratio = crop_ratio # (h, w)
65 assert (self.crop_ratio[0] &gt;= 1 and self.crop_ratio[1] &gt;= 1), &#x27;crop ration only supports &gt;=1&#x27;
66 self.face_size = (int(face_size * self.crop_ratio[1]), int(face_size * self.crop_ratio[0]))
67
68 if self.template_3points:
</pre>
</div>
</div>
</div>
<div id="issue-137">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_facelib/utils/face_restoration_helper.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_facelib/utils/face_restoration_helper.py</a><br>
<b>Line number: </b>257<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
253 def align_warp_face(self, save_cropped_path=None, border_mode=&#x27;constant&#x27;):
254 &quot;&quot;&quot;Align and warp faces with face template.
255 &quot;&quot;&quot;
256 if self.pad_blur:
257 assert len(self.pad_input_imgs) == len(
258 self.all_landmarks_5), f&#x27;Mismatched samples: {len(self.pad_input_imgs)} and {len(self.all_landmarks_5)}&#x27;
259 for idx, landmark in enumerate(self.all_landmarks_5):
260 # use 5 landmarks to get affine matrix
261 # use cv2.LMEDS method for the equivalence to skimage transform
</pre>
</div>
</div>
</div>
<div id="issue-138">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/r_facelib/utils/face_restoration_helper.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/r_facelib/utils/face_restoration_helper.py</a><br>
<b>Line number: </b>313<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
309 upsample_img = cv2.resize(self.input_img, (w_up, h_up), interpolation=cv2.INTER_LINEAR)
310 else:
311 upsample_img = cv2.resize(upsample_img, (w_up, h_up), interpolation=cv2.INTER_LANCZOS4)
312
313 assert len(self.restored_faces) == len(
314 self.inverse_affine_matrices), (&#x27;length of restored_faces and affine_matrices are different.&#x27;)
315
316 inv_mask_borders = []
317 for restored_face, inverse_affine in zip(self.restored_faces, self.inverse_affine_matrices):
</pre>
</div>
</div>
</div>
<div id="issue-139">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/reactor_patcher.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/reactor_patcher.py</a><br>
<b>Line number: </b>59<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
55 self.models[model.taskname] = model
56 else:
57 print(&#x27;duplicated model task type, ignore:&#x27;, onnx_file, model.taskname)
58 del model
59 assert &#x27;detection&#x27; in self.models
60 self.det_model = self.models[&#x27;detection&#x27;]
61
62
</pre>
</div>
</div>
</div>
<div id="issue-140">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/reactor_patcher.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/reactor_patcher.py</a><br>
<b>Line number: </b>65<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
61
62
63 def patched_faceanalysis_prepare(self, ctx_id, det_thresh=0.5, det_size=(640, 640)):
64 self.det_thresh = det_thresh
65 assert det_size is not None
66 self.det_size = det_size
67 for taskname, model in self.models.items():
68 if taskname == &#x27;detection&#x27;:
</pre>
</div>
</div>
</div>
<div id="issue-141">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/reactor_patcher.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/reactor_patcher.py</a><br>
<b>Line number: </b>93<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
89 output_names = []
90 for out in outputs:
91 output_names.append(out.name)
92 self.output_names = output_names
93 assert len(self.output_names) == 1
94 input_cfg = inputs[0]
95 input_shape = input_cfg.shape
96 self.input_shape = input_shape
</pre>
</div>
</div>
</div>
<div id="issue-142">
<div class="issue-block issue-sev-medium">
<b>blacklist: </b> Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.<br>
<b>Test ID:</b> B310<br>
<b>Severity: </b>MEDIUM<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/22.html" target="_blank">CWE-22</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/reactor_utils.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/reactor_utils.py</a><br>
<b>Line number: </b>113<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b310-urllib-urlopen" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b310-urllib-urlopen</a><br>
<div class="code">
<pre>
109 return torch.stack([r, g, b], dim=3)
110
111
112 def download(url, path, name):
113 request = urllib.request.urlopen(url)
114 total = int(request.headers.get(&#x27;Content-Length&#x27;, 0))
115 with tqdm(total=total, desc=f&#x27;[ReActor] Downloading {name} to {path}&#x27;, unit=&#x27;B&#x27;, unit_scale=True, unit_divisor=1024) as progress:
116 urllib.request.urlretrieve(url, path, reporthook=lambda count, block_size, total_size: progress.update(block_size))
</pre>
</div>
</div>
</div>
<div id="issue-143">
<div class="issue-block issue-sev-medium">
<b>blacklist: </b> Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.<br>
<b>Test ID:</b> B310<br>
<b>Severity: </b>MEDIUM<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/22.html" target="_blank">CWE-22</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/reactor_utils.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/reactor_utils.py</a><br>
<b>Line number: </b>116<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b310-urllib-urlopen" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b310-urllib-urlopen</a><br>
<div class="code">
<pre>
112 def download(url, path, name):
113 request = urllib.request.urlopen(url)
114 total = int(request.headers.get(&#x27;Content-Length&#x27;, 0))
115 with tqdm(total=total, desc=f&#x27;[ReActor] Downloading {name} to {path}&#x27;, unit=&#x27;B&#x27;, unit_scale=True, unit_divisor=1024) as progress:
116 urllib.request.urlretrieve(url, path, reporthook=lambda count, block_size, total_size: progress.update(block_size))
117
118
119 def move_path(old_path, new_path):
</pre>
</div>
</div>
</div>
<div id="issue-144">
<div class="issue-block issue-sev-high">
<b>hashlib: </b> Use of weak MD5 hash for security. Consider usedforsecurity=False<br>
<b>Test ID:</b> B324<br>
<b>Severity: </b>HIGH<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/327.html" target="_blank">CWE-327</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/reactor_utils.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/reactor_utils.py</a><br>
<b>Line number: </b>151<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b324_hashlib.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b324_hashlib.html</a><br>
<div class="code">
<pre>
147 setattr(logging, methodName, logToRoot)
148
149
150 def get_image_md5hash(image: Image.Image):
151 md5hash = hashlib.md5(image.tobytes())
152 return md5hash.hexdigest()
153
154
</pre>
</div>
</div>
</div>
<div id="issue-145">
<div class="issue-block issue-sev-low">
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
<b>Test ID:</b> B101<br>
<b>Severity: </b>LOW<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/scripts/r_archs/codeformer_arch.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/scripts/r_archs/codeformer_arch.py</a><br>
<b>Line number: </b>22<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
<div class="code">
<pre>
18 eps (float): A small value added to the variance to avoid
19 divide-by-zero. Default: 1e-5.
20 &quot;&quot;&quot;
21 size = feat.size()
22 assert len(size) == 4, &#x27;The input feature should be 4D tensor.&#x27;
23 b, c = size[:2]
24 feat_var = feat.view(b, c, -1).var(dim=2) + eps
25 feat_std = feat_var.sqrt().view(b, c, 1, 1)
</pre>
</div>
</div>
</div>
<div id="issue-146">
<div class="issue-block issue-sev-medium">
<b>blacklist: </b> Use of possibly insecure function - consider using safer ast.literal_eval.<br>
<b>Test ID:</b> B307<br>
<b>Severity: </b>MEDIUM<br>
<b>Confidence: </b>HIGH<br>
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
<b>File: </b><a href="/custom_nodes/hanzo-studio-reactor-node/scripts/r_masking/core.py" target="_blank">/custom_nodes/hanzo-studio-reactor-node/scripts/r_masking/core.py</a><br>
<b>Line number: </b>110<br>
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval</a><br>
<div class="code">
<pre>
106 &#x27;__builtins__&#x27;: {},
107 &#x27;__name__&#x27;: f&#x27;namedtuple_{typename}&#x27;,
108 }
109 code = f&#x27;lambda _cls, {arg_list}: _tuple_new(_cls, ({arg_list}))&#x27;
110 __new__ = eval(code, namespace)
111 __new__.__name__ = &#x27;__new__&#x27;
112 __new__.__doc__ = f&#x27;Create new instance of {typename}({arg_list})&#x27;
113 if defaults is not None:
</pre>
</div>
</div>
</div>
</div>
</body>
</html>