From 42d28b417d4d962addf17e41d54d83e448345a6f Mon Sep 17 00:00:00 2001 From: klemen1999 Date: Thu, 4 Jun 2026 21:52:35 +0200 Subject: [PATCH 1/4] Shared_with_container folder and all subfolders have user permissons instead of root --- modelconverter/__main__.py | 1 + modelconverter/cli/utils.py | 14 +++++++++++++- modelconverter/utils/docker_utils.py | 20 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/modelconverter/__main__.py b/modelconverter/__main__.py index c66e2a5e..dc9f6325 100644 --- a/modelconverter/__main__.py +++ b/modelconverter/__main__.py @@ -623,6 +623,7 @@ def launcher( if in_docker(): return command(*bound.args, **bound.kwargs) + init_dirs() tag = "dev" if dev else "latest" target = bound.arguments["target"] diff --git a/modelconverter/cli/utils.py b/modelconverter/cli/utils.py index ff05a094..349911a2 100644 --- a/modelconverter/cli/utils.py +++ b/modelconverter/cli/utils.py @@ -24,6 +24,7 @@ MISC_DIR, MODELS_DIR, OUTPUTS_DIR, + SHARED_DIR, ) from modelconverter.utils.hub_requests import Request from modelconverter.utils.types import DataType, Encoding, Target @@ -66,7 +67,18 @@ def get_output_dir_name( def init_dirs() -> None: - for p in [CONFIGS_DIR, MODELS_DIR, OUTPUTS_DIR, CALIBRATION_DIR]: + for p in [ + SHARED_DIR, + MISC_DIR, + # Some tools run inside the container as the host UID and still + # expect writable HOME/XDG cache locations. + MISC_DIR / "runtime-home", + MISC_DIR / "runtime-cache", + CONFIGS_DIR, + MODELS_DIR, + OUTPUTS_DIR, + CALIBRATION_DIR, + ]: logger.debug(f"Creating {p}") p.mkdir(parents=True, exist_ok=True) diff --git a/modelconverter/utils/docker_utils.py b/modelconverter/utils/docker_utils.py index 2540e902..8b2a95b4 100644 --- a/modelconverter/utils/docker_utils.py +++ b/modelconverter/utils/docker_utils.py @@ -23,6 +23,9 @@ import docker from modelconverter import __version__ +_CONTAINER_USER_HOME = "/app/shared_with_container/misc/runtime-home" +_CONTAINER_USER_CACHE = "/app/shared_with_container/misc/runtime-cache" + def get_docker_client_from_active_context() -> docker.DockerClient: ctx_name = subprocess.check_output( @@ -73,6 +76,7 @@ def generate_compose_config( memory: str | None = None, cpus: float | None = None, ) -> str: + user_spec = _get_current_user_spec() config = { "services": { "modelconverter": { @@ -104,6 +108,14 @@ def generate_compose_config( } }, } + if user_spec is not None: + config["services"]["modelconverter"]["user"] = user_spec + config["services"]["modelconverter"]["environment"].update( + { + "HOME": _CONTAINER_USER_HOME, + "XDG_CACHE_HOME": _CONTAINER_USER_CACHE, + } + ) limits = {} if memory is not None: limits["memory"] = memory @@ -121,6 +133,14 @@ def generate_compose_config( return yaml.dump(config) +def _get_current_user_spec() -> str | None: + getuid = getattr(os, "getuid", None) + getgid = getattr(os, "getgid", None) + if not callable(getuid) or not callable(getgid): + return None + return f"{getuid()}:{getgid()}" + + def in_docker() -> bool: return "IN_DOCKER" in os.environ From 43bc26b0e3b0773a5e0eac70a5d69a474c58932c Mon Sep 17 00:00:00 2001 From: klemen1999 Date: Thu, 4 Jun 2026 21:59:01 +0200 Subject: [PATCH 2/4] updates to README --- README.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 217a737d..2273e793 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ There are two main ways to execute configure the conversion process: 1. **NN Archive**: Alternatively, you can use an [NN Archive](https://docs.luxonis.com/software-v3/ai-inference/nn-archive/#NN%20Archive) as input. An NN Archive includes a model in one of the supported formats—ONNX (.onnx), OpenVINO IR (.xml and .bin), or TensorFlow Lite (.tflite)—alongside a `config.json` file. The config.json file follows a specific configuration format as described under the `Configuration` section. -1. **YAML Configuration File (Legacy)**: +2. **YAML Configuration File (Legacy)**: An alternative way to configure the conversion is through a YAML configuration file. For reference, you can check [defaults.yaml](shared_with_container/configs/defaults.yaml) and other examples located in the [shared_with_container/configs](shared_with_container/configs) directory. **Modifying Settings with Command-Line Arguments**: @@ -324,6 +324,9 @@ shared_with_container/ │ ├── resnet18.yaml │ └── │ +├── misc/ +│ └── +│ ├── models/ │ ├── resnet18.onnx │ └── @@ -345,7 +348,8 @@ The converter first searches for files exactly at the provided path. If not foun The `output_dir` can be specified using the `--output-dir` CLI argument. If such a directory already exists, the `output_dir_name` will be appended with the current date and time. If not specified, the `output_dir_name` will be autogenerated in the following format: `_to___