Ultralytics Code Refactor https://ultralytics.com/actions (#13152)
Refactor code for speed and clarity
This commit is contained in:
1 parent
05e59bdec1
commit
b9019671f4
13 files changed
+29
-5
No files matched your search
+3
-3
@@ -343,7 +343,7 @@ def check_online():
|
||||
import socket
|
||||
|
||||
def run_once():
|
||||
# Check once
|
||||
"""Checks internet connectivity by attempting to create a connection to "1.1.1.1" on port 443."""
|
||||
try:
|
||||
socket.create_connection(("1.1.1.1", 443), 5) # check host accessibility
|
||||
return True
|
||||
@@ -587,7 +587,7 @@ def check_amp(model):
|
||||
from models.common import AutoShape, DetectMultiBackend
|
||||
|
||||
def amp_allclose(model, im):
|
||||
# All close FP32 vs AMP results
|
||||
"""Compares FP32 and AMP model inference outputs, ensuring they are close within a 10% absolute tolerance."""
|
||||
m = AutoShape(model, verbose=False) # model
|
||||
a = m(im).xywhn[0] # FP32 inference
|
||||
m.amp = True
|
||||
@@ -652,7 +652,7 @@ def download(url, dir=".", unzip=True, delete=True, curl=False, threads=1, retry
|
||||
"""Downloads and optionally unzips files concurrently, supporting retries and curl fallback."""
|
||||
|
||||
def download_one(url, dir):
|
||||
# Download 1 file
|
||||
"""Downloads a single file from `url` to `dir`, with retry support and optional curl fallback."""
|
||||
success = True
|
||||
if os.path.isfile(url):
|
||||
f = Path(url) # filename
|
||||
|
||||
Reference in new issue
Block a user