test-ncnn
Laughing-q 4 weeks ago
parent cab9470cc8
commit b48c5a81ab
  1. 1
      .github/workflows/ci.yaml
  2. 5
      tests/test_ncnn.py
  3. 6
      tests/test_onnx.py
  4. 10
      ultralytics/engine/exporter.py

@ -195,6 +195,7 @@ jobs:
slow="--slow"
fi
pytest $slow --cov=ultralytics/ --cov-report xml tests/test_ncnn.py
pytest $slow --cov=ultralytics/ --cov-report xml tests/test_onnx.py
- name: Upload Coverage Reports to CodeCov
if: github.repository == 'ultralytics/ultralytics' # && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v4

@ -17,8 +17,3 @@ def test_ncnn():
# verbose=False,
# )
# then export onnx
def test_onnx():
model = YOLO("yolo11n.pt")
model.export(imgsz=160, format="onnx", half=False, int8=False, device="cpu", verbose=False)

@ -0,0 +1,6 @@
from ultralytics import YOLO
def test_onnx():
model = YOLO("yolo11n.pt")
model.export(imgsz=160, format="onnx", half=False, int8=False, device="cpu", verbose=False)

@ -572,8 +572,8 @@ class Exporter:
unzip_dir = safe_download(f"https://github.com/pnnx/pnnx/releases/download/{release}/{asset}", delete=True)
if check_is_path_safe(Path.cwd(), unzip_dir): # avoid path traversal security vulnerability
shutil.move(src=unzip_dir / name, dst=pnnx) # move binary to ROOT
# pnnx.chmod(0o777) # set read, write, and execute permissions for everyone
# shutil.rmtree(unzip_dir) # delete unzip dir
pnnx.chmod(0o777) # set read, write, and execute permissions for everyone
shutil.rmtree(unzip_dir) # delete unzip dir
ncnn_args = [
f'ncnnparam={f / "model.ncnn.param"}',
@ -602,9 +602,9 @@ class Exporter:
subprocess.run(cmd, check=True)
# Remove debug files
# pnnx_files = [x.split("=")[-1] for x in pnnx_args]
# for f_debug in ("debug.bin", "debug.param", "debug2.bin", "debug2.param", *pnnx_files):
# Path(f_debug).unlink(missing_ok=True)
pnnx_files = [x.split("=")[-1] for x in pnnx_args]
for f_debug in ("debug.bin", "debug.param", "debug2.bin", "debug2.param", *pnnx_files):
Path(f_debug).unlink(missing_ok=True)
yaml_save(f / "metadata.yaml", self.metadata) # add metadata.yaml
return str(f), None

Loading…
Cancel
Save