Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion modelconverter/packages/base_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pathlib import Path
from typing import Any

import cv2
import numpy as np
from loguru import logger

Expand Down Expand Up @@ -225,7 +226,24 @@ def _prepare_random_calibration_data(self) -> None:
arr = np.clip(arr, calib.min_value, calib.max_value)

arr = arr.astype(calib.data_type.as_numpy_dtype())
np.save(dest / f"{i}.npy", arr)
if len(arr.shape) in {2, 3} or (
len(arr.shape) in {3, 4} and arr.shape[0] == 1
):
Comment thread
kozlov721 marked this conversation as resolved.
layout = inp.layout
if arr.shape[0] == 1 and len(arr.shape) > 2:
arr = arr.squeeze(0)
if layout is not None:
layout = layout[1:]

if layout is not None and "C" in layout:
channel_dim = layout.index("C")
if channel_dim == 0 and len(arr.shape) == 3:
arr = arr.transpose(1, 2, 0)
elif arr.shape[0] in {1, 3}: # type: ignore
arr = arr.transpose(1, 2, 0)
cv2.imwrite(str(dest / f"{i}.png"), arr)
else:
np.save(dest / f"{i}.npy", arr)

self.inputs[name].calibration = ImageCalibrationConfig(path=dest)

Expand Down
1 change: 1 addition & 0 deletions modelconverter/packages/rvc3/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, config: SingleStageConfig, output_dir: Path):
self.mo_args = config.rvc3.mo_args
self.compile_tool_args = config.rvc3.compile_tool_args
self.device = "VPUX.3400"
self.reverse_input_channels = False
self._device_specific_buildinfo = {}

def export(self) -> Path:
Expand Down
Loading