mirror of
https://github.com/hanzoui/custom-nodes-security-scan.git
synced 2026-10-30 20:56:54 +00:00
- 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
2314 lines
97 KiB
HTML
2314 lines
97 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">6400</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_segment_anything/install.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/install.py</a><br>
|
|
<b>Line number: </b>3<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 sys
|
|
2 import os.path
|
|
3 import subprocess
|
|
4
|
|
5 custom_nodes_path = os.path.dirname(os.path.abspath(__file__))
|
|
6
|
|
7 def build_pip_install_cmds(args):
|
|
8 if "python_embeded" in sys.executable or "python_embedded" in sys.executable:
|
|
</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_segment_anything/install.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/install.py</a><br>
|
|
<b>Line number: </b>15<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>
|
|
11 return [sys.executable, '-m', 'pip', 'install'] + args
|
|
12
|
|
13 def ensure_package():
|
|
14 cmds = build_pip_install_cmds(['-r', 'requirements.txt'])
|
|
15 subprocess.run(cmds, cwd=custom_nodes_path)
|
|
16
|
|
17 if __name__ == "__main__":
|
|
18 ensure_package()
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-2">
|
|
<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_segment_anything/local_groundingdino/datasets/transforms.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/datasets/transforms.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#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
187 def __call__(self, img: PIL.Image.Image, target: dict):
|
|
188 init_boxes = len(target["boxes"])
|
|
189 max_patience = 10
|
|
190 for i in range(max_patience):
|
|
191 w = random.randint(self.min_size, min(img.width, self.max_size))
|
|
192 h = random.randint(self.min_size, min(img.height, self.max_size))
|
|
193 region = T.RandomCrop.get_params(img, [h, w])
|
|
194 result_img, result_target = crop(img, target, region)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-3">
|
|
<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_segment_anything/local_groundingdino/datasets/transforms.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/datasets/transforms.py</a><br>
|
|
<b>Line number: </b>192<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>
|
|
188 init_boxes = len(target["boxes"])
|
|
189 max_patience = 10
|
|
190 for i in range(max_patience):
|
|
191 w = random.randint(self.min_size, min(img.width, self.max_size))
|
|
192 h = random.randint(self.min_size, min(img.height, self.max_size))
|
|
193 region = T.RandomCrop.get_params(img, [h, w])
|
|
194 result_img, result_target = crop(img, target, region)
|
|
195 if (
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-4">
|
|
<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_segment_anything/local_groundingdino/datasets/transforms.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/datasets/transforms.py</a><br>
|
|
<b>Line number: </b>221<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>
|
|
217 def __init__(self, p=0.5):
|
|
218 self.p = p
|
|
219
|
|
220 def __call__(self, img, target):
|
|
221 if random.random() < self.p:
|
|
222 return hflip(img, target)
|
|
223 return img, target
|
|
224
|
|
</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_segment_anything/local_groundingdino/datasets/transforms.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/datasets/transforms.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
|
|
225
|
|
226 class RandomResize(object):
|
|
227 def __init__(self, sizes, max_size=None):
|
|
228 assert isinstance(sizes, (list, tuple))
|
|
229 self.sizes = sizes
|
|
230 self.max_size = max_size
|
|
231
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-6">
|
|
<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_segment_anything/local_groundingdino/datasets/transforms.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/datasets/transforms.py</a><br>
|
|
<b>Line number: </b>233<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>
|
|
229 self.sizes = sizes
|
|
230 self.max_size = max_size
|
|
231
|
|
232 def __call__(self, img, target=None):
|
|
233 size = random.choice(self.sizes)
|
|
234 return resize(img, target, size, self.max_size)
|
|
235
|
|
236
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-7">
|
|
<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_segment_anything/local_groundingdino/datasets/transforms.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/datasets/transforms.py</a><br>
|
|
<b>Line number: </b>242<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>
|
|
238 def __init__(self, max_pad):
|
|
239 self.max_pad = max_pad
|
|
240
|
|
241 def __call__(self, img, target):
|
|
242 pad_x = random.randint(0, self.max_pad)
|
|
243 pad_y = random.randint(0, self.max_pad)
|
|
244 return pad(img, target, (pad_x, pad_y))
|
|
245
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-8">
|
|
<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_segment_anything/local_groundingdino/datasets/transforms.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/datasets/transforms.py</a><br>
|
|
<b>Line number: </b>243<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>
|
|
239 self.max_pad = max_pad
|
|
240
|
|
241 def __call__(self, img, target):
|
|
242 pad_x = random.randint(0, self.max_pad)
|
|
243 pad_y = random.randint(0, self.max_pad)
|
|
244 return pad(img, target, (pad_x, pad_y))
|
|
245
|
|
246
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-9">
|
|
<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_segment_anything/local_groundingdino/datasets/transforms.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/datasets/transforms.py</a><br>
|
|
<b>Line number: </b>259<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>
|
|
255 self.transforms2 = transforms2
|
|
256 self.p = p
|
|
257
|
|
258 def __call__(self, img, target):
|
|
259 if random.random() < self.p:
|
|
260 return self.transforms1(img, target)
|
|
261 return self.transforms2(img, target)
|
|
262
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py</a><br>
|
|
<b>Line number: </b>112<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>
|
|
108 xs = self.body(tensor_list.tensors)
|
|
109 out: Dict[str, NestedTensor] = {}
|
|
110 for name, x in xs.items():
|
|
111 m = tensor_list.mask
|
|
112 assert m is not None
|
|
113 mask = F.interpolate(m[None].float(), size=x.shape[-2:]).to(torch.bool)[0]
|
|
114 out[name] = NestedTensor(x, mask)
|
|
115 # import ipdb; ipdb.set_trace()
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py</a><br>
|
|
<b>Line number: </b>139<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>
|
|
135 )
|
|
136 else:
|
|
137 raise NotImplementedError("Why you can get here with name {}".format(name))
|
|
138 # num_channels = 512 if name in ('resnet18', 'resnet34') else 2048
|
|
139 assert name not in ("resnet18", "resnet34"), "Only resnet50 and resnet101 are available."
|
|
140 assert return_interm_indices in [[0, 1, 2, 3], [1, 2, 3], [3]]
|
|
141 num_channels_all = [256, 512, 1024, 2048]
|
|
142 num_channels = num_channels_all[4 - len(return_interm_indices) :]
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py</a><br>
|
|
<b>Line number: </b>140<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>
|
|
136 else:
|
|
137 raise NotImplementedError("Why you can get here with name {}".format(name))
|
|
138 # num_channels = 512 if name in ('resnet18', 'resnet34') else 2048
|
|
139 assert name not in ("resnet18", "resnet34"), "Only resnet50 and resnet101 are available."
|
|
140 assert return_interm_indices in [[0, 1, 2, 3], [1, 2, 3], [3]]
|
|
141 num_channels_all = [256, 512, 1024, 2048]
|
|
142 num_channels = num_channels_all[4 - len(return_interm_indices) :]
|
|
143 super().__init__(backbone, train_backbone, num_channels, return_interm_indices)
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py</a><br>
|
|
<b>Line number: </b>178<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>
|
|
174 train_backbone = True
|
|
175 if not train_backbone:
|
|
176 raise ValueError("Please set lr_backbone > 0")
|
|
177 return_interm_indices = args.return_interm_indices
|
|
178 assert return_interm_indices in [[0, 1, 2, 3], [1, 2, 3], [3]]
|
|
179 args.backbone_freeze_keywords
|
|
180 use_checkpoint = getattr(args, "use_checkpoint", False)
|
|
181
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py</a><br>
|
|
<b>Line number: </b>211<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>
|
|
207 bb_num_channels = backbone.num_features[4 - len(return_interm_indices) :]
|
|
208 else:
|
|
209 raise NotImplementedError("Unknown backbone {}".format(args.backbone))
|
|
210
|
|
211 assert len(bb_num_channels) == len(
|
|
212 return_interm_indices
|
|
213 ), f"len(bb_num_channels) {len(bb_num_channels)} != len(return_interm_indices) {len(return_interm_indices)}"
|
|
214
|
|
215 model = Joiner(backbone, position_embedding)
|
|
216 model.num_channels = bb_num_channels
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/backbone.py</a><br>
|
|
<b>Line number: </b>217<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>
|
|
213 ), f"len(bb_num_channels) {len(bb_num_channels)} != len(return_interm_indices) {len(return_interm_indices)}"
|
|
214
|
|
215 model = Joiner(backbone, position_embedding)
|
|
216 model.num_channels = bb_num_channels
|
|
217 assert isinstance(
|
|
218 bb_num_channels, List
|
|
219 ), "bb_num_channels is expected to be a List but {}".format(type(bb_num_channels))
|
|
220 # import ipdb; ipdb.set_trace()
|
|
221 return model
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/position_encoding.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/position_encoding.py</a><br>
|
|
<b>Line number: </b>50<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>
|
|
46
|
|
47 def forward(self, tensor_list: NestedTensor):
|
|
48 x = tensor_list.tensors
|
|
49 mask = tensor_list.mask
|
|
50 assert mask is not None
|
|
51 not_mask = ~mask
|
|
52 y_embed = not_mask.cumsum(1, dtype=torch.float32)
|
|
53 x_embed = not_mask.cumsum(2, dtype=torch.float32)
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/position_encoding.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/position_encoding.py</a><br>
|
|
<b>Line number: </b>101<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>
|
|
97
|
|
98 def forward(self, tensor_list: NestedTensor):
|
|
99 x = tensor_list.tensors
|
|
100 mask = tensor_list.mask
|
|
101 assert mask is not None
|
|
102 not_mask = ~mask
|
|
103 y_embed = not_mask.cumsum(1, dtype=torch.float32)
|
|
104 x_embed = not_mask.cumsum(2, dtype=torch.float32)
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/swin_transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/swin_transformer.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 self.num_heads = num_heads
|
|
212 self.window_size = window_size
|
|
213 self.shift_size = shift_size
|
|
214 self.mlp_ratio = mlp_ratio
|
|
215 assert 0 <= self.shift_size < self.window_size, "shift_size must in 0-window_size"
|
|
216
|
|
217 self.norm1 = norm_layer(dim)
|
|
218 self.attn = WindowAttention(
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/swin_transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/swin_transformer.py</a><br>
|
|
<b>Line number: </b>247<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>
|
|
243 mask_matrix: Attention mask for cyclic shift.
|
|
244 """
|
|
245 B, L, C = x.shape
|
|
246 H, W = self.H, self.W
|
|
247 assert L == H * W, "input feature has wrong size"
|
|
248
|
|
249 shortcut = x
|
|
250 x = self.norm1(x)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-20">
|
|
<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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/swin_transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/swin_transformer.py</a><br>
|
|
<b>Line number: </b>321<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>
|
|
317 x: Input feature, tensor size (B, H*W, C).
|
|
318 H, W: Spatial resolution of the input feature.
|
|
319 """
|
|
320 B, L, C = x.shape
|
|
321 assert L == H * W, "input feature has wrong size"
|
|
322
|
|
323 x = x.view(B, H, W, C)
|
|
324
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/swin_transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/swin_transformer.py</a><br>
|
|
<b>Line number: </b>750<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>
|
|
746 # collect for nesttensors
|
|
747 outs_dict = {}
|
|
748 for idx, out_i in enumerate(outs):
|
|
749 m = tensor_list.mask
|
|
750 assert m is not None
|
|
751 mask = F.interpolate(m[None].float(), size=out_i.shape[-2:]).to(torch.bool)[0]
|
|
752 outs_dict[idx] = NestedTensor(out_i, mask)
|
|
753
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/backbone/swin_transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/backbone/swin_transformer.py</a><br>
|
|
<b>Line number: </b>763<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>
|
|
759 self._freeze_stages()
|
|
760
|
|
761
|
|
762 def build_swin_transformer(modelname, pretrain_img_size, **kw):
|
|
763 assert modelname in [
|
|
764 "swin_T_224_1k",
|
|
765 "swin_B_224_22k",
|
|
766 "swin_B_384_22k",
|
|
767 "swin_L_224_22k",
|
|
768 "swin_L_384_22k",
|
|
769 ]
|
|
770
|
|
771 model_para_dict = {
|
|
772 "swin_T_224_1k": dict(
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/fuse_modules.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/fuse_modules.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 self.head_dim = embed_dim // num_heads
|
|
106 self.v_dim = v_dim
|
|
107 self.l_dim = l_dim
|
|
108
|
|
109 assert (
|
|
110 self.head_dim * self.num_heads == self.embed_dim
|
|
111 ), f"embed_dim must be divisible by num_heads (got `embed_dim`: {self.embed_dim} and `num_heads`: {self.num_heads})."
|
|
112 self.scale = self.head_dim ** (-0.5)
|
|
113 self.dropout = dropout
|
|
114
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py</a><br>
|
|
<b>Line number: </b>87<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>
|
|
83 self.sub_sentence_present = sub_sentence_present
|
|
84
|
|
85 # setting query dim
|
|
86 self.query_dim = query_dim
|
|
87 assert query_dim == 4
|
|
88
|
|
89 # for dn training
|
|
90 self.num_patterns = num_patterns
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.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 in_channels = hidden_dim
|
|
131 self.input_proj = nn.ModuleList(input_proj_list)
|
|
132 else:
|
|
133 assert two_stage_type == "no", "two_stage_type should be no if num_feature_levels=1 !!!"
|
|
134 self.input_proj = nn.ModuleList(
|
|
135 [
|
|
136 nn.Sequential(
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py</a><br>
|
|
<b>Line number: </b>148<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>
|
|
144 self.aux_loss = aux_loss
|
|
145 self.box_pred_damping = box_pred_damping = None
|
|
146
|
|
147 self.iter_update = iter_update
|
|
148 assert iter_update, "Why not iter_update?"
|
|
149
|
|
150 # prepare pred layers
|
|
151 self.dec_pred_bbox_embed_share = dec_pred_bbox_embed_share
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py</a><br>
|
|
<b>Line number: </b>173<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>
|
|
169 self.transformer.decoder.class_embed = self.class_embed
|
|
170
|
|
171 # two stage
|
|
172 self.two_stage_type = two_stage_type
|
|
173 assert two_stage_type in ["no", "standard"], "unknown param {} of two_stage_type".format(
|
|
174 two_stage_type
|
|
175 )
|
|
176 if two_stage_type != "no":
|
|
177 if two_stage_bbox_embed_share:
|
|
178 assert dec_pred_bbox_embed_share
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py</a><br>
|
|
<b>Line number: </b>178<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>
|
|
174 two_stage_type
|
|
175 )
|
|
176 if two_stage_type != "no":
|
|
177 if two_stage_bbox_embed_share:
|
|
178 assert dec_pred_bbox_embed_share
|
|
179 self.transformer.enc_out_bbox_embed = _bbox_embed
|
|
180 else:
|
|
181 self.transformer.enc_out_bbox_embed = copy.deepcopy(_bbox_embed)
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py</a><br>
|
|
<b>Line number: </b>184<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>
|
|
180 else:
|
|
181 self.transformer.enc_out_bbox_embed = copy.deepcopy(_bbox_embed)
|
|
182
|
|
183 if two_stage_class_embed_share:
|
|
184 assert dec_pred_bbox_embed_share
|
|
185 self.transformer.enc_out_class_embed = _class_embed
|
|
186 else:
|
|
187 self.transformer.enc_out_class_embed = copy.deepcopy(_class_embed)
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/groundingdino.py</a><br>
|
|
<b>Line number: </b>287<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>
|
|
283 for l, feat in enumerate(features):
|
|
284 src, mask = feat.decompose()
|
|
285 srcs.append(self.input_proj[l](src))
|
|
286 masks.append(mask)
|
|
287 assert mask is not None
|
|
288 if self.num_feature_levels > len(srcs):
|
|
289 _len_srcs = len(srcs)
|
|
290 for l in range(_len_srcs, self.num_feature_levels):
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/ms_deform_attn.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/ms_deform_attn.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
|
|
225 bs, num_query, _ = query.shape
|
|
226 bs, num_value, _ = value.shape
|
|
227
|
|
228 assert (spatial_shapes[:, 0] * spatial_shapes[:, 1]).sum() == num_value
|
|
229
|
|
230 value = self.value_proj(value)
|
|
231 if key_padding_mask is not None:
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/transformer.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 self.num_encoder_layers = num_encoder_layers
|
|
78 self.num_unicoder_layers = num_unicoder_layers
|
|
79 self.num_decoder_layers = num_decoder_layers
|
|
80 self.num_queries = num_queries
|
|
81 assert query_dim == 4
|
|
82
|
|
83 # choose encoder layer type
|
|
84 encoder_layer = DeformableTransformerEncoderLayer(
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py</a><br>
|
|
<b>Line number: </b>111<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>
|
|
107 else:
|
|
108 feature_fusion_layer = None
|
|
109
|
|
110 encoder_norm = nn.LayerNorm(d_model) if normalize_before else None
|
|
111 assert encoder_norm is None
|
|
112 self.encoder = TransformerEncoder(
|
|
113 encoder_layer,
|
|
114 num_encoder_layers,
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py</a><br>
|
|
<b>Line number: </b>162<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>
|
|
158 else:
|
|
159 self.level_embed = None
|
|
160
|
|
161 self.learnable_tgt_init = learnable_tgt_init
|
|
162 assert learnable_tgt_init, "why not learnable_tgt_init"
|
|
163 self.embed_init_tgt = embed_init_tgt
|
|
164 if (two_stage_type != "no" and embed_init_tgt) or (two_stage_type == "no"):
|
|
165 self.tgt_embed = nn.Embedding(self.num_queries, d_model)
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py</a><br>
|
|
<b>Line number: </b>172<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>
|
|
168 self.tgt_embed = None
|
|
169
|
|
170 # for two stage
|
|
171 self.two_stage_type = two_stage_type
|
|
172 assert two_stage_type in ["no", "standard"], "unknown param {} of two_stage_type".format(
|
|
173 two_stage_type
|
|
174 )
|
|
175 if two_stage_type == "standard":
|
|
176 # anchor selection at the output of encoder
|
|
177 self.enc_output = nn.Linear(d_model, d_model)
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py</a><br>
|
|
<b>Line number: </b>617<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>
|
|
613 self.layers = []
|
|
614 self.num_layers = num_layers
|
|
615 self.norm = norm
|
|
616 self.return_intermediate = return_intermediate
|
|
617 assert return_intermediate, "support return_intermediate only"
|
|
618 self.query_dim = query_dim
|
|
619 assert query_dim in [2, 4], "query_dim should be 2/4 but {}".format(query_dim)
|
|
620 self.num_feature_levels = num_feature_levels
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py</a><br>
|
|
<b>Line number: </b>619<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>
|
|
615 self.norm = norm
|
|
616 self.return_intermediate = return_intermediate
|
|
617 assert return_intermediate, "support return_intermediate only"
|
|
618 self.query_dim = query_dim
|
|
619 assert query_dim in [2, 4], "query_dim should be 2/4 but {}".format(query_dim)
|
|
620 self.num_feature_levels = num_feature_levels
|
|
621
|
|
622 self.ref_point_head = MLP(query_dim // 2 * d_model, d_model, d_model, 2)
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py</a><br>
|
|
<b>Line number: </b>673<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>
|
|
669 reference_points[:, :, None]
|
|
670 * torch.cat([valid_ratios, valid_ratios], -1)[None, :]
|
|
671 ) # nq, bs, nlevel, 4
|
|
672 else:
|
|
673 assert reference_points.shape[-1] == 2
|
|
674 reference_points_input = reference_points[:, :, None] * valid_ratios[None, :]
|
|
675 query_sine_embed = gen_sineembed_for_position(
|
|
676 reference_points_input[:, :, 0, :]
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/transformer.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 self.norm3 = nn.LayerNorm(d_model)
|
|
846
|
|
847 self.key_aware_proj = None
|
|
848 self.use_text_feat_guide = use_text_feat_guide
|
|
849 assert not use_text_feat_guide
|
|
850 self.use_text_cross_attention = use_text_cross_attention
|
|
851
|
|
852 def rm_self_attn_modules(self):
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/transformer.py</a><br>
|
|
<b>Line number: </b>893<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>
|
|
889 Input:
|
|
890 - tgt/tgt_query_pos: nq, bs, d_model
|
|
891 -
|
|
892 """
|
|
893 assert cross_attn_mask is None
|
|
894
|
|
895 # self attention
|
|
896 if self.self_attn is not None:
|
|
</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_segment_anything/local_groundingdino/models/GroundingDINO/utils.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/GroundingDINO/utils.py</a><br>
|
|
<b>Line number: </b>256<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>
|
|
252 }
|
|
253 Returns:
|
|
254 _type_: _description_
|
|
255 """
|
|
256 assert isinstance(text_dict, dict)
|
|
257
|
|
258 y = text_dict["encoded_text"]
|
|
259 text_token_mask = text_dict["text_token_mask"]
|
|
</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_segment_anything/local_groundingdino/models/__init__.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/models/__init__.py</a><br>
|
|
<b>Line number: </b>15<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>
|
|
11 def build_model(args):
|
|
12 # we use register to maintain models from catdet6 on.
|
|
13 from .registry import MODULE_BUILD_FUNCS
|
|
14
|
|
15 assert args.modelname in MODULE_BUILD_FUNCS._module_dict
|
|
16 build_func = MODULE_BUILD_FUNCS.get(args.modelname)
|
|
17 model = build_func(args)
|
|
18 return model
|
|
</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_segment_anything/local_groundingdino/util/box_ops.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/box_ops.py</a><br>
|
|
<b>Line number: </b>50<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>
|
|
46 and M = len(boxes2)
|
|
47 """
|
|
48 # degenerate boxes gives inf / nan results
|
|
49 # so do an early check
|
|
50 assert (boxes1[:, 2:] >= boxes1[:, :2]).all()
|
|
51 assert (boxes2[:, 2:] >= boxes2[:, :2]).all()
|
|
52 # except:
|
|
53 # import ipdb; ipdb.set_trace()
|
|
</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_segment_anything/local_groundingdino/util/box_ops.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/box_ops.py</a><br>
|
|
<b>Line number: </b>51<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>
|
|
47 """
|
|
48 # degenerate boxes gives inf / nan results
|
|
49 # so do an early check
|
|
50 assert (boxes1[:, 2:] >= boxes1[:, :2]).all()
|
|
51 assert (boxes2[:, 2:] >= boxes2[:, :2]).all()
|
|
52 # except:
|
|
53 # import ipdb; ipdb.set_trace()
|
|
54 iou, union = box_iou(boxes1, boxes2)
|
|
</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_segment_anything/local_groundingdino/util/box_ops.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/box_ops.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 - giou: N, 4
|
|
90 """
|
|
91 # degenerate boxes gives inf / nan results
|
|
92 # so do an early check
|
|
93 assert (boxes1[:, 2:] >= boxes1[:, :2]).all()
|
|
94 assert (boxes2[:, 2:] >= boxes2[:, :2]).all()
|
|
95 assert boxes1.shape == boxes2.shape
|
|
96 iou, union = box_iou_pairwise(boxes1, boxes2) # N, 4
|
|
</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_segment_anything/local_groundingdino/util/box_ops.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/box_ops.py</a><br>
|
|
<b>Line number: </b>94<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>
|
|
90 """
|
|
91 # degenerate boxes gives inf / nan results
|
|
92 # so do an early check
|
|
93 assert (boxes1[:, 2:] >= boxes1[:, :2]).all()
|
|
94 assert (boxes2[:, 2:] >= boxes2[:, :2]).all()
|
|
95 assert boxes1.shape == boxes2.shape
|
|
96 iou, union = box_iou_pairwise(boxes1, boxes2) # N, 4
|
|
97
|
|
</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_segment_anything/local_groundingdino/util/box_ops.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/box_ops.py</a><br>
|
|
<b>Line number: </b>95<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>
|
|
91 # degenerate boxes gives inf / nan results
|
|
92 # so do an early check
|
|
93 assert (boxes1[:, 2:] >= boxes1[:, :2]).all()
|
|
94 assert (boxes2[:, 2:] >= boxes2[:, :2]).all()
|
|
95 assert boxes1.shape == boxes2.shape
|
|
96 iou, union = box_iou_pairwise(boxes1, boxes2) # N, 4
|
|
97
|
|
98 lt = torch.min(boxes1[:, :2], boxes2[:, :2])
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-48">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Consider possible security implications associated with pickle module.<br>
|
|
<b>Test ID:</b> B403<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/502.html" target="_blank">CWE-502</a><br>
|
|
<b>File: </b><a href="/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>13<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b403-import-pickle" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b403-import-pickle</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
9 import functools
|
|
10 import io
|
|
11 import json
|
|
12 import os
|
|
13 import pickle
|
|
14 import subprocess
|
|
15 import time
|
|
16 from collections import OrderedDict, defaultdict, deque
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-49">
|
|
<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_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>14<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>
|
|
10 import io
|
|
11 import json
|
|
12 import os
|
|
13 import pickle
|
|
14 import subprocess
|
|
15 import time
|
|
16 from collections import OrderedDict, defaultdict, deque
|
|
17 from typing import List, Optional
|
|
</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_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>146<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>
|
|
142 print("gathering on cpu")
|
|
143 dist.all_gather(size_list, local_size, group=cpu_group)
|
|
144 size_list = [int(size.item()) for size in size_list]
|
|
145 max_size = max(size_list)
|
|
146 assert isinstance(local_size.item(), int)
|
|
147 local_size = int(local_size.item())
|
|
148
|
|
149 # receiving Tensor from all ranks
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-51">
|
|
<div class="issue-block issue-sev-medium">
|
|
<b>blacklist: </b> Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.<br>
|
|
<b>Test ID:</b> B301<br>
|
|
<b>Severity: </b>MEDIUM<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/502.html" target="_blank">CWE-502</a><br>
|
|
<b>File: </b><a href="/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>215<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b301-pickle" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b301-pickle</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
211
|
|
212 data_list = []
|
|
213 for size, tensor in zip(size_list, tensor_list):
|
|
214 buffer = tensor.cpu().numpy().tobytes()[:size]
|
|
215 data_list.append(pickle.loads(buffer))
|
|
216
|
|
217 return data_list
|
|
218
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-52">
|
|
<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_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>256<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>
|
|
252 def update(self, **kwargs):
|
|
253 for k, v in kwargs.items():
|
|
254 if isinstance(v, torch.Tensor):
|
|
255 v = v.item()
|
|
256 assert isinstance(v, (float, int))
|
|
257 self.meters[k].update(v)
|
|
258
|
|
259 def __getattr__(self, attr):
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-53">
|
|
<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_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>366<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>
|
|
362 def get_sha():
|
|
363 cwd = os.path.dirname(os.path.abspath(__file__))
|
|
364
|
|
365 def _run(command):
|
|
366 return subprocess.check_output(command, cwd=cwd).decode("ascii").strip()
|
|
367
|
|
368 sha = "N/A"
|
|
369 diff = "clean"
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-54">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>start_process_with_partial_path: </b> Starting a process with a partial executable path<br>
|
|
<b>Test ID:</b> B607<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_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>373<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b607_start_process_with_partial_path.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b607_start_process_with_partial_path.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
369 diff = "clean"
|
|
370 branch = "N/A"
|
|
371 try:
|
|
372 sha = _run(["git", "rev-parse", "HEAD"])
|
|
373 subprocess.check_output(["git", "diff"], cwd=cwd)
|
|
374 diff = _run(["git", "diff-index", "HEAD"])
|
|
375 diff = "has uncommited changes" if diff else "clean"
|
|
376 branch = _run(["git", "rev-parse", "--abbrev-ref", "HEAD"])
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-55">
|
|
<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_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>373<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>
|
|
369 diff = "clean"
|
|
370 branch = "N/A"
|
|
371 try:
|
|
372 sha = _run(["git", "rev-parse", "HEAD"])
|
|
373 subprocess.check_output(["git", "diff"], cwd=cwd)
|
|
374 diff = _run(["git", "diff-index", "HEAD"])
|
|
375 diff = "has uncommited changes" if diff else "clean"
|
|
376 branch = _run(["git", "rev-parse", "--abbrev-ref", "HEAD"])
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-56">
|
|
<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_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>377<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>
|
|
373 subprocess.check_output(["git", "diff"], cwd=cwd)
|
|
374 diff = _run(["git", "diff-index", "HEAD"])
|
|
375 diff = "has uncommited changes" if diff else "clean"
|
|
376 branch = _run(["git", "rev-parse", "--abbrev-ref", "HEAD"])
|
|
377 except Exception:
|
|
378 pass
|
|
379 message = f"sha: {sha}, status: {diff}, branch: {branch}"
|
|
380 return message
|
|
381
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-57">
|
|
<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_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>430<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>
|
|
426 # type: (Device) -> NestedTensor # noqa
|
|
427 cast_tensor = self.tensors.to(device)
|
|
428 mask = self.mask
|
|
429 if mask is not None:
|
|
430 assert mask is not None
|
|
431 cast_mask = mask.to(device)
|
|
432 else:
|
|
433 cast_mask = None
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-58">
|
|
<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_segment_anything/local_groundingdino/util/misc.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/misc.py</a><br>
|
|
<b>Line number: </b>437<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>
|
|
433 cast_mask = None
|
|
434 return NestedTensor(cast_tensor, cast_mask)
|
|
435
|
|
436 def to_img_list_single(self, tensor, mask):
|
|
437 assert tensor.dim() == 3, "dim of tensor should be 3 but {}".format(tensor.dim())
|
|
438 maxH = (~mask).sum(0).max()
|
|
439 maxW = (~mask).sum(1).max()
|
|
440 img = tensor[:, :maxH, :maxW]
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-59">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Consider possible security implications associated with pickle module.<br>
|
|
<b>Test ID:</b> B403<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/502.html" target="_blank">CWE-502</a><br>
|
|
<b>File: </b><a href="/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/slio.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/slio.py</a><br>
|
|
<b>Line number: </b>6<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b403-import-pickle" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b403-import-pickle</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
2 # Modified from mmcv
|
|
3 # ==========================================================
|
|
4
|
|
5 import json
|
|
6 import pickle
|
|
7 from abc import ABCMeta, abstractmethod
|
|
8 from pathlib import Path
|
|
9
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-60">
|
|
<div class="issue-block issue-sev-medium">
|
|
<b>blacklist: </b> Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.<br>
|
|
<b>Test ID:</b> B301<br>
|
|
<b>Severity: </b>MEDIUM<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/502.html" target="_blank">CWE-502</a><br>
|
|
<b>File: </b><a href="/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/slio.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/slio.py</a><br>
|
|
<b>Line number: </b>58<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b301-pickle" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b301-pickle</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
54
|
|
55
|
|
56 class PickleHandler(BaseFileHandler):
|
|
57 def load_from_fileobj(self, file, **kwargs):
|
|
58 return pickle.load(file, **kwargs)
|
|
59
|
|
60 def load_from_path(self, filepath, **kwargs):
|
|
61 return super(PickleHandler, self).load_from_path(filepath, mode="rb", **kwargs)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-61">
|
|
<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_segment_anything/local_groundingdino/util/slio.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/slio.py</a><br>
|
|
<b>Line number: </b>78<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>
|
|
74
|
|
75 class YamlHandler(BaseFileHandler):
|
|
76 def load_from_fileobj(self, file, **kwargs):
|
|
77 kwargs.setdefault("Loader", Loader)
|
|
78 return yaml.load(file, **kwargs)
|
|
79
|
|
80 def dump_to_fileobj(self, obj, file, **kwargs):
|
|
81 kwargs.setdefault("Dumper", Dumper)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-62">
|
|
<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_segment_anything/local_groundingdino/util/utils.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/utils.py</a><br>
|
|
<b>Line number: </b>43<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>
|
|
39 img: torch.FloatTensor, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]
|
|
40 ) -> torch.FloatTensor:
|
|
41 # img: tensor(3,H,W) or tensor(B,3,H,W)
|
|
42 # return: same as img
|
|
43 assert img.dim() == 3 or img.dim() == 4, "img.dim() should be 3 or 4 but %d" % img.dim()
|
|
44 if img.dim() == 3:
|
|
45 assert img.size(0) == 3, 'img.size(0) shoule be 3 but "%d". (%s)' % (
|
|
46 img.size(0),
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-63">
|
|
<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_segment_anything/local_groundingdino/util/utils.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/utils.py</a><br>
|
|
<b>Line number: </b>45<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>
|
|
41 # img: tensor(3,H,W) or tensor(B,3,H,W)
|
|
42 # return: same as img
|
|
43 assert img.dim() == 3 or img.dim() == 4, "img.dim() should be 3 or 4 but %d" % img.dim()
|
|
44 if img.dim() == 3:
|
|
45 assert img.size(0) == 3, 'img.size(0) shoule be 3 but "%d". (%s)' % (
|
|
46 img.size(0),
|
|
47 str(img.size()),
|
|
48 )
|
|
49 img_perm = img.permute(1, 2, 0)
|
|
50 mean = torch.Tensor(mean)
|
|
51 std = torch.Tensor(std)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-64">
|
|
<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_segment_anything/local_groundingdino/util/utils.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/utils.py</a><br>
|
|
<b>Line number: </b>55<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>
|
|
51 std = torch.Tensor(std)
|
|
52 img_res = img_perm * std + mean
|
|
53 return img_res.permute(2, 0, 1)
|
|
54 else: # img.dim() == 4
|
|
55 assert img.size(1) == 3, 'img.size(1) shoule be 3 but "%d". (%s)' % (
|
|
56 img.size(1),
|
|
57 str(img.size()),
|
|
58 )
|
|
59 img_perm = img.permute(0, 2, 3, 1)
|
|
60 mean = torch.Tensor(mean)
|
|
61 std = torch.Tensor(std)
|
|
</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_segment_anything/local_groundingdino/util/utils.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/utils.py</a><br>
|
|
<b>Line number: </b>287<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>
|
|
283 """
|
|
284 Input:
|
|
285 pred, gt: Tensor()
|
|
286 """
|
|
287 assert pred.shape == gt.shape
|
|
288 self.tp += torch.logical_and(pred == 1, gt == 1).sum().item()
|
|
289 self.fp += torch.logical_and(pred == 1, gt == 0).sum().item()
|
|
290 self.tn += torch.logical_and(pred == 0, gt == 0).sum().item()
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-66">
|
|
<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_segment_anything/local_groundingdino/util/utils.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/utils.py</a><br>
|
|
<b>Line number: </b>326<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>
|
|
322 raise NotImplementedError("Unknown type {}".format(type(args)))
|
|
323
|
|
324
|
|
325 def stat_tensors(tensor):
|
|
326 assert tensor.dim() == 1
|
|
327 tensor_sm = tensor.softmax(0)
|
|
328 entropy = (tensor_sm * torch.log(tensor_sm + 1e-9)).sum()
|
|
329
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-67">
|
|
<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_segment_anything/local_groundingdino/util/utils.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/utils.py</a><br>
|
|
<b>Line number: </b>510<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>
|
|
506 self.best_res = init_res
|
|
507 self.best_ep = -1
|
|
508
|
|
509 self.better = better
|
|
510 assert better in ["large", "small"]
|
|
511
|
|
512 def isbetter(self, new_res, old_res):
|
|
513 if self.better == "large":
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-68">
|
|
<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_segment_anything/local_groundingdino/util/utils.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/local_groundingdino/util/utils.py</a><br>
|
|
<b>Line number: </b>602<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>
|
|
598
|
|
599 def get_phrases_from_posmap(
|
|
600 posmap: torch.BoolTensor, tokenized: Dict, tokenizer: AutoTokenizer
|
|
601 ):
|
|
602 assert isinstance(posmap, torch.Tensor), "posmap must be torch.Tensor"
|
|
603 if posmap.dim() == 1:
|
|
604 non_zero_idx = posmap.nonzero(as_tuple=True)[0].tolist()
|
|
605 token_ids = [tokenized["input_ids"][i] for i in non_zero_idx]
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-69">
|
|
<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_segment_anything/sam_hq/automatic.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/sam_hq/automatic.py</a><br>
|
|
<b>Line number: </b>79<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>
|
|
75 For large resolutions, 'binary_mask' may consume large amounts of
|
|
76 memory.
|
|
77 """
|
|
78
|
|
79 assert (points_per_side is None) != (
|
|
80 point_grids is None
|
|
81 ), "Exactly one of points_per_side or point_grid must be provided."
|
|
82 if points_per_side is not None:
|
|
83 self.point_grids = build_all_layer_point_grids(
|
|
84 points_per_side,
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-70">
|
|
<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_segment_anything/sam_hq/automatic.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/sam_hq/automatic.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 self.point_grids = point_grids
|
|
90 else:
|
|
91 raise ValueError("Can't have both points_per_side and point_grid be None.")
|
|
92
|
|
93 assert output_mode in [
|
|
94 "binary_mask",
|
|
95 "uncompressed_rle",
|
|
96 "coco_rle",
|
|
97 ], f"Unknown output_mode {output_mode}."
|
|
98 if output_mode == "coco_rle":
|
|
99 from pycocotools import mask as mask_utils # type: ignore # noqa: F401
|
|
100
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-71">
|
|
<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_segment_anything/sam_hq/modeling/tiny_vit.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/sam_hq/modeling/tiny_vit.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 resolution=(14, 14),
|
|
216 ):
|
|
217 super().__init__()
|
|
218 # (h, w)
|
|
219 assert isinstance(resolution, tuple) and len(resolution) == 2
|
|
220 self.num_heads = num_heads
|
|
221 self.scale = key_dim ** -0.5
|
|
222 self.key_dim = key_dim
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-72">
|
|
<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_segment_anything/sam_hq/modeling/tiny_vit.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/sam_hq/modeling/tiny_vit.py</a><br>
|
|
<b>Line number: </b>310<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>
|
|
306 super().__init__()
|
|
307 self.dim = dim
|
|
308 self.input_resolution = input_resolution
|
|
309 self.num_heads = num_heads
|
|
310 assert window_size > 0, 'window_size must be greater than 0'
|
|
311 self.window_size = window_size
|
|
312 self.mlp_ratio = mlp_ratio
|
|
313
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-73">
|
|
<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_segment_anything/sam_hq/modeling/tiny_vit.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/sam_hq/modeling/tiny_vit.py</a><br>
|
|
<b>Line number: </b>317<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>
|
|
313
|
|
314 self.drop_path = DropPath(
|
|
315 drop_path) if drop_path > 0. else nn.Identity()
|
|
316
|
|
317 assert dim % num_heads == 0, 'dim must be divisible by num_heads'
|
|
318 head_dim = dim // num_heads
|
|
319
|
|
320 window_resolution = (window_size, window_size)
|
|
</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_segment_anything/sam_hq/modeling/tiny_vit.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/sam_hq/modeling/tiny_vit.py</a><br>
|
|
<b>Line number: </b>336<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>
|
|
332
|
|
333 def forward(self, x):
|
|
334 H, W = self.input_resolution
|
|
335 B, L, C = x.shape
|
|
336 assert L == H * W, "input feature has wrong size"
|
|
337 res_x = x
|
|
338 if H == self.window_size and W == self.window_size:
|
|
339 x = self.attn(x)
|
|
</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_segment_anything/sam_hq/modeling/tiny_vit.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/sam_hq/modeling/tiny_vit.py</a><br>
|
|
<b>Line number: </b>572<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>
|
|
568 i += 1
|
|
569 if layer.downsample is not None:
|
|
570 layer.downsample.apply(
|
|
571 lambda x: _set_lr_scale(x, lr_scales[i - 1]))
|
|
572 assert i == depth
|
|
573 for m in [self.norm_head, self.head]:
|
|
574 m.apply(lambda x: _set_lr_scale(x, lr_scales[-1]))
|
|
575
|
|
</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_segment_anything/sam_hq/modeling/tiny_vit.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/sam_hq/modeling/tiny_vit.py</a><br>
|
|
<b>Line number: </b>581<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>
|
|
577 p.param_name = k
|
|
578
|
|
579 def _check_lr_scale(m):
|
|
580 for p in m.parameters():
|
|
581 assert hasattr(p, 'lr_scale'), p.param_name
|
|
582
|
|
583 self.apply(_check_lr_scale)
|
|
584
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-77">
|
|
<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_segment_anything/sam_hq/predictor.py" target="_blank">/custom_nodes/hanzo_studio_segment_anything/sam_hq/predictor.py</a><br>
|
|
<b>Line number: </b>43<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>
|
|
39 1x3xHxW, which has been transformed with ResizeLongestSide.
|
|
40 original_image_size (tuple(int, int)): The size of the image
|
|
41 before transformation, in (H, W) format.
|
|
42 """
|
|
43 assert (
|
|
44 len(transformed_image.shape) == 4
|
|
45 and transformed_image.shape[1] == 3
|
|
46 and max(*transformed_image.shape[2:]) == self.model.image_encoder.img_size
|
|
47 ), f"set_torch_image input must be BCHW with long side {self.model.image_encoder.img_size}."
|
|
48 self.reset_image()
|
|
49
|
|
50 self.original_size = original_image_size
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|