New Features #20
GitHub Actions / Test Results
failed
Jan 15, 2025 in 0s
1 fail, 1 pass in 1m 52s
Annotations
Check warning on line 0 in tests.test_conversion
github-actions / Test Results
All 6 runs failed: test_automatic_version_detection (tests.test_conversion)
artifacts/Test Results [macOS-latest] (Python 3.10)/pytest.xml [took 0s]
artifacts/Test Results [macOS-latest] (Python 3.11)/pytest.xml [took 0s]
artifacts/Test Results [ubuntu-latest] (Python 3.10)/pytest.xml [took 0s]
artifacts/Test Results [ubuntu-latest] (Python 3.11)/pytest.xml [took 0s]
artifacts/Test Results [windows-latest] (Python 3.10)/pytest.xml [took 0s]
artifacts/Test Results [windows-latest] (Python 3.11)/pytest.xml [took 0s]
Raw output
RuntimeError
path = 'yolov8n.pt', debug = False
def detect_version(path: str, debug: bool = False) -> str:
"""Detect the version of the model weights.
Args:
path (str): Path to the model weights
Returns:
str: The detected version
"""
try:
# Remove and recreate the extracted_model directory
if exists("extracted_model"):
shutil.rmtree("extracted_model")
subprocess.check_output("mkdir extracted_model", shell=True)
# Extract the tar file into the extracted_model directory
if platform.system() == "Windows":
subprocess.check_output(f"tar -xf {path} -C extracted_model", shell=True)
else:
> subprocess.check_output(f"unzip {path} -d extracted_model", shell=True)
tools/utils/version_detection.py:41:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py:466: in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = False, timeout = None, check = True
popenargs = ('unzip yolov8n.pt -d extracted_model',)
kwargs = {'shell': True, 'stdout': -1}
process = <Popen: returncode: 9 args: 'unzip yolov8n.pt -d extracted_model'>
stdout = b'', stderr = None, retcode = 9
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them,
or pass capture_output=True to capture both.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command 'unzip yolov8n.pt -d extracted_model' returned non-zero exit status 9.
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py:571: CalledProcessError
The above exception was the direct cause of the following exception:
def test_automatic_version_detection():
"""Test the autodetection of the model version."""
> assert detect_version("yolov8n.pt") == "yolov8"
tests/test_conversion.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
path = 'yolov8n.pt', debug = False
def detect_version(path: str, debug: bool = False) -> str:
"""Detect the version of the model weights.
Args:
path (str): Path to the model weights
Returns:
str: The detected version
"""
try:
# Remove and recreate the extracted_model directory
if exists("extracted_model"):
shutil.rmtree("extracted_model")
subprocess.check_output("mkdir extracted_model", shell=True)
# Extract the tar file into the extracted_model directory
if platform.system() == "Windows":
subprocess.check_output(f"tar -xf {path} -C extracted_model", shell=True)
else:
subprocess.check_output(f"unzip {path} -d extracted_model", shell=True)
folder = [
f for f in listdir("extracted_model") if isdir(join("extracted_model", f))
][0]
if "yolov8" in folder.lower():
return YOLOV8_CONVERSION
# open a file, where you stored the pickled data
with open(f"extracted_model/{folder}/data.pkl", "rb") as file:
data = file.read()
if debug:
print(data.decode(errors="replace"))
content = data.decode("latin1")
if "yolo11" in content:
return YOLOV11_CONVERSION
elif "yolov10" in content or "v10DetectLoss" in content:
return YOLOV10_CONVERSION
elif "yolov9" in content or (
"v9-model" in content and "ultralytics" in content
):
return YOLOV9_CONVERSION
elif (
"YOLOv5u" in content
or "YOLOv8" in content
or "yolov8" in content
or ("v8DetectionLoss" in content and "ultralytics" in content)
):
return YOLOV8_CONVERSION
elif "yolov6" in content:
if "yolov6.models.yolo\nDetect" in content:
return YOLOV6R1_CONVERSION
elif "CSPSPPFModule" in content or "ConvBNReLU" in content:
return YOLOV6R4_CONVERSION
elif "gold_yolo" in content:
return GOLD_YOLO_CONVERSION
return YOLOV6R3_CONVERSION
elif "yolov7" in content:
return YOLOV7_CONVERSION
elif (
"SPPF" in content
or "yolov5" in content
or (
"models.yolo.Detectr1" in content
and "models.common.SPPr" in content
)
):
return YOLOV5_CONVERSION
except subprocess.CalledProcessError as e:
> raise RuntimeError() from e
E RuntimeError
tools/utils/version_detection.py:93: RuntimeError
Loading