diff --git a/.devcontainer/cpu/devcontainer.json b/.devcontainer/cpu/devcontainer.json new file mode 100644 index 0000000..583beea --- /dev/null +++ b/.devcontainer/cpu/devcontainer.json @@ -0,0 +1,66 @@ +{ + "name": "Focoos CPU", + "build": { + "context": "../..", + "dockerfile": "../../Dockerfile", + "target": "focoos-cpu" + }, + "shutdownAction": "none", + "remoteUser": "root", + "workspaceFolder": "${localWorkspaceFolder}", + "workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind", + "postCreateCommand": "uv pip install -e .[dev]", + "remoteEnv": { + "UV_SYSTEM_PYTHON": "true" + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "true", + "configureZshAsDefaultShell": "true", + "username": "vscode", + "userUid": "1000", + "userGid": "1000", + "upgradePackages": "true" + }, + // git + "ghcr.io/devcontainers/features/git:1": { + "version": "os-provided", + "ppa": "false" + }, + // "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, + "ghcr.io/iterative/features/nvtop:1": {}, + }, + "customizations": { + "devpod": { + "podManifestTemplate": ".devcontainer/pod_manifest.yaml" + }, + "vscode": { + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "python.terminal.activateEnvInCurrentTerminal": true, + }, + "extensions": [ + "ms-python.python", + "ms-azuretools.vscode-docker", + "ms-toolsai.jupyter", + "ms-python.python", + "vscode.git", + "ms-azuretools.vscode-docker", + "vscode.ipynb", + "waderyan.gitblame", + "michelemelluso.gitignore", + "amazonwebservices.aws-toolkit-vscode", + "naumovs.color-highlight", + "mindaro-dev.file-downloader", + "donjayamanne.githistory", + "github.vscode-github-actions", + "seatonjiang.gitmoji-vscode", + "ms-vscode.remote-repositories", + "donjayamanne.python-environment-manager", + "ninoseki.vscode-pylens", + "ninoseki.vscode-mogami", + "charliermarsh.ruff" + ] + } + } +} diff --git a/.devcontainer/gpu-base/devcontainer.json b/.devcontainer/gpu-base/devcontainer.json new file mode 100644 index 0000000..bf9ac7a --- /dev/null +++ b/.devcontainer/gpu-base/devcontainer.json @@ -0,0 +1,79 @@ +{ + "name": "Focoos GPU (OnnxRuntime)", + "build": { + "target": "focoos-onnx", + "context": "../..", + "dockerfile": "../../Dockerfile", + }, + "shutdownAction": "none", + "remoteUser": "root", + "hostRequirements": { + "gpu": "optional" + }, + "workspaceFolder": "${localWorkspaceFolder}", + "workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind", + "postCreateCommand": "uv pip install -e .[onnx,dev]", + "remoteEnv": { + "UV_SYSTEM_PYTHON": "true" + }, + "runArgs": [ + "--gpus=all", + "--ipc=host", + "--runtime=nvidia", + "--ulimit=memlock=-1", + "--ulimit=stack=67108864", + "--privileged" + ], + "postStartCommand": [ + "nvidia-smi" + ], + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "true", + "configureZshAsDefaultShell": "true", + "username": "vscode", + "userUid": "1000", + "userGid": "1000", + "upgradePackages": "true" + }, + // git + "ghcr.io/devcontainers/features/git:1": { + "version": "os-provided", + "ppa": "false" + }, + "ghcr.io/iterative/features/nvtop:1": {}, + }, + "customizations": { + "devpod": { + "podManifestTemplate": ".devcontainer/pod_manifest.yaml" + }, + "vscode": { + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "python.terminal.activateEnvInCurrentTerminal": true, + }, + "extensions": [ + "ms-python.python", + "ms-azuretools.vscode-docker", + "ms-toolsai.jupyter", + "ms-python.python", + "vscode.git", + "ms-azuretools.vscode-docker", + "vscode.ipynb", + "waderyan.gitblame", + "michelemelluso.gitignore", + "amazonwebservices.aws-toolkit-vscode", + "naumovs.color-highlight", + "mindaro-dev.file-downloader", + "donjayamanne.githistory", + "github.vscode-github-actions", + "seatonjiang.gitmoji-vscode", + "ms-vscode.remote-repositories", + "donjayamanne.python-environment-manager", + "ninoseki.vscode-pylens", + "ninoseki.vscode-mogami", + "charliermarsh.ruff" + ] + } + } +} diff --git a/.devcontainer/gpu-tenosrrt/devcontainer.json b/.devcontainer/gpu-tenosrrt/devcontainer.json new file mode 100644 index 0000000..d2cd701 --- /dev/null +++ b/.devcontainer/gpu-tenosrrt/devcontainer.json @@ -0,0 +1,81 @@ +{ + "name": "Focoos GPU (OnnxRuntime, Torch, TensorRT)", + + "build": { + "context": "../..", + "dockerfile": "../../Dockerfile", + "target": "focoos-tensorrt" + }, + "shutdownAction": "none", + "remoteUser": "root", + "hostRequirements": { + "gpu": "optional" + }, + "workspaceFolder": "${localWorkspaceFolder}", + "workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind", + "postCreateCommand": "uv pip install -e .[tensorrt,dev]", + "remoteEnv": { + "UV_SYSTEM_PYTHON": "true" + }, + "runArgs": [ + "--gpus=all", + "--ipc=host", + "--runtime=nvidia", + "--ulimit=memlock=-1", + "--ulimit=stack=67108864", + "--privileged" + ], + "postStartCommand": [ + "nvidia-smi" + ], + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "true", + "configureZshAsDefaultShell": "true", + "username": "vscode", + "userUid": "1000", + "userGid": "1000", + "upgradePackages": "true" + }, + // git + "ghcr.io/devcontainers/features/git:1": { + "version": "os-provided", + "ppa": "false" + }, + // "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, + "ghcr.io/iterative/features/nvtop:1": {}, + }, + "customizations": { + "devpod": { + "podManifestTemplate": ".devcontainer/pod_manifest.yaml" + }, + "vscode": { + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "python.terminal.activateEnvInCurrentTerminal": true, + }, + "extensions": [ + "ms-python.python", + "ms-azuretools.vscode-docker", + "ms-toolsai.jupyter", + "ms-python.python", + "vscode.git", + "ms-azuretools.vscode-docker", + "vscode.ipynb", + "waderyan.gitblame", + "michelemelluso.gitignore", + "amazonwebservices.aws-toolkit-vscode", + "naumovs.color-highlight", + "mindaro-dev.file-downloader", + "donjayamanne.githistory", + "github.vscode-github-actions", + "seatonjiang.gitmoji-vscode", + "ms-vscode.remote-repositories", + "donjayamanne.python-environment-manager", + "ninoseki.vscode-pylens", + "ninoseki.vscode-mogami", + "charliermarsh.ruff" + ] + } + } +} diff --git a/.devcontainer/gpu-torch/devcontainer.json b/.devcontainer/gpu-torch/devcontainer.json new file mode 100644 index 0000000..2e99f34 --- /dev/null +++ b/.devcontainer/gpu-torch/devcontainer.json @@ -0,0 +1,80 @@ +{ + "name": "Focoos GPU (OnnxRuntime,Torch)", + "build": { + "context": "../..", + "dockerfile": "../../Dockerfile", + "target": "focoos-torch" + }, + "shutdownAction": "none", + "remoteUser": "root", + "hostRequirements": { + "gpu": "optional" + }, + "workspaceFolder": "${localWorkspaceFolder}", + "workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind", + "postCreateCommand": "uv pip install -e .[torch,dev]", + "remoteEnv": { + "UV_SYSTEM_PYTHON": "true" + }, + "runArgs": [ + "--gpus=all", + "--ipc=host", + "--runtime=nvidia", + "--ulimit=memlock=-1", + "--ulimit=stack=67108864", + "--privileged" + ], + "postStartCommand": [ + "nvidia-smi" + ], + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "true", + "configureZshAsDefaultShell": "true", + "username": "vscode", + "userUid": "1000", + "userGid": "1000", + "upgradePackages": "true" + }, + // git + "ghcr.io/devcontainers/features/git:1": { + "version": "os-provided", + "ppa": "false" + }, + // "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, + "ghcr.io/iterative/features/nvtop:1": {}, + }, + "customizations": { + "devpod": { + "podManifestTemplate": ".devcontainer/pod_manifest.yaml" + }, + "vscode": { + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "python.terminal.activateEnvInCurrentTerminal": true, + }, + "extensions": [ + "ms-python.python", + "ms-azuretools.vscode-docker", + "ms-toolsai.jupyter", + "ms-python.python", + "vscode.git", + "ms-azuretools.vscode-docker", + "vscode.ipynb", + "waderyan.gitblame", + "michelemelluso.gitignore", + "amazonwebservices.aws-toolkit-vscode", + "naumovs.color-highlight", + "mindaro-dev.file-downloader", + "donjayamanne.githistory", + "github.vscode-github-actions", + "seatonjiang.gitmoji-vscode", + "ms-vscode.remote-repositories", + "donjayamanne.python-environment-manager", + "ninoseki.vscode-pylens", + "ninoseki.vscode-mogami", + "charliermarsh.ruff" + ] + } + } +} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99d7575..e4762f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,8 +29,8 @@ jobs: uses: astral-sh/setup-uv@v4 with: python-version: ${{ matrix.python-version }} - - name: ๐Ÿ“ฆ Install dependencies - run: uv pip install .[cpu,dev] + - name: ๐Ÿ“ฆ Install dev dependencies + run: uv pip install .[dev] - name: ๐Ÿงช Run test run: make test - name: ๐Ÿ“Š Generate test coverage report diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bcd8417 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM python:3.12-slim-bullseye AS focoos-cpu +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ +LABEL authors="focoos.ai" +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential git ffmpeg libsm6 libxext6 gcc libmagic1 wget make cmake +WORKDIR /app +COPY focoos ./focoos +COPY pyproject.toml ./pyproject.toml +RUN uv pip install --system -e . + + +FROM ghcr.io/focoosai/deeplearning:base-cu12-cudnn9-py312-uv AS focoos-onnx +LABEL authors="focoos.ai" + +WORKDIR /app + +COPY focoos ./focoos +COPY pyproject.toml ./pyproject.toml +RUN uv pip install --system -e .[onnx] + + +FROM focoos-onnx AS focoos-torch +RUN uv pip install --system -e .[torch] + +FROM focoos-torch AS focoos-tensorrt +RUN apt-get update && apt-get install -y \ + wget lsb-release && \ + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \ + dpkg -i cuda-keyring_1.1-1_all.deb && \ + apt-get update && apt-get install -y \ + tensorrt \ + python3-libnvinfer-dev \ + uff-converter-tf && \ + apt-get clean && rm -rf /var/lib/apt/lists/* +RUN uv pip install --system -e .[tensorrt] diff --git a/README.md b/README.md index f3d7b34..6e1ec18 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![Tests](https://github.com/FocoosAI/focoos/actions/workflows/test.yml/badge.svg??event=push&branch=main) + # Focoos pre-trained models | Model Name | Task | Metrics | Domain | @@ -21,13 +23,12 @@ Focoos supports both cloud and local inference, and enables training on the clou ### Key Features - **Pre-trained Models**: A wide range of pre-trained models for different tasks and domains. -- **Multiple Inference Runtimes**: Support for various inference runtimes including CPU, GPU, Torchscript CUDA, OnnxRuntime CUDA, and OnnxRuntime TensorRT. - **Cloud Inference**: API to Focoos cloud inference. -- **Local Inference**: local inference, making it easy to deploy models on the local machine. -- **Cloud Training**: Train user models on the focoos cloud. +- **Cloud Training**: Train custom models with the Focoos cloud. +- **Multiple Local Inference Runtimes**: Support for various inference runtimes including CPU, GPU, Torchscript CUDA, OnnxRuntime CUDA, and OnnxRuntime TensorRT. - **Model Monitoring**: Monitor model performance and metrics. -![Tests](https://github.com/FocoosAI/focoos/actions/workflows/test.yml/badge.svg??event=push&branch=main) + # ๐Ÿ Setup We recommend using [UV](https://docs.astral.sh/uv/) as a package manager and environment manager for a streamlined dependency management experience. @@ -111,3 +112,13 @@ model = focoos.get_local_model("focoos_object365") detections = model.infer("./image.jpg", threshold=0.4) ``` + + +## Docker and devcontainers +For container support, Focoos offers four different Docker images: +- `focoos-cpu`: only CPU +- `focoos-onnx`: Includes ONNX support +- `focoos-torch`: Includes ONNX and Torchscript support +- `focoos-tensorrt`: Includes ONNX, Torchscript, and TensorRT support + +This repository also includes a devcontainer configuration for each of the above images. You can launch these devcontainers in Visual Studio Code for a seamless development experience.