A Python pipeline designed to transform 2D bas relief images into detailed 3D bas-reliefs using Depth Anything 3 depth estimation.
Note: Currently, the script doesn't convert a normal image to an image of a bas relief, it only converts the latter to a mesh. You will have to do this using a different method, such as a local image pipeline, Gemini, ChatGPT, etc. An example prompt that performs pretty well especially on animals:
recreate this exact image as a pure white matte marble bas relief. orthographic view. no frame border. compress depth of the background, enhance the depth of the subject. clear sharp lines. identify and replicate the subject's particular features. keep the same aspect ratio. very light shadows. high resolution, crisp details, 4k, 8k. use the image as line art control net
Note: The Gemini images perform best for the moment
- Depth Estimation: Uses Depth Anything 3 for highly detailed depth map prediction.
- Automated 3D Relief Generation: Converts depth map directly into a mesh (OBJ).
- Interactive CLI Interface: Simple, prompt-guided execution with command-line arguments.
- GPU Accelerated: Optimized for CUDA-enabled PyTorch execution.
- CNC / 3D-Printing Ready: Designed to generate usable 3D geometries for CAM software, carving, and 3D printing.
You can help further development of Carve Anything by contributing to the work or by financially supporting the creator here: OpenSource CNC Ko-Fi page Any bit of help counts a lot, so thank you all in advance!
Before setting up CarveAnything, ensure you have the following installed on your host system:
- Python: 3.10 or higher recommended (Python 3.9 minimum)
- Git: Installed and configured
- NVIDIA GPU Driver: Version
550.58or higher (for CUDA 12.4 support)
Follow these step-by-step instructions to set up CarveAnything on your local system:
Open your terminal or PowerShell and clone the repository:
git clone https://github.com/opensourcecnc/CarveAnything.git
cd CarveAnythingOn Windows (PowerShell):
python -m venv venv
.\venv\Scripts\Activate.ps1On Linux / macOS:
python3 -m venv venv
source venv/bin/activateUpgrade pip and install all necessary Python dependencies:
python -m pip install --upgrade pip
pip install -r requirements.txtIf the requirements installation fails on depth_anything_3, try:
pip install depth_anything_3 --ignore-requires-pythonedit requirements.txt, remove depth_anything_3, then:
pip install --no-build-isolation -r requirements.txtNote on PyTorch / CUDA:
requirements.txtconfigures CUDA 12.4 PyTorch builds by default. If running on CPU only or requiring a different CUDA release, refer to the PyTorch Get Started guide.
CarveAnything requires model weights from the Hugging Face DA3MONO-LARGE repository to perform depth estimation.
1.The Hugging Face repository: depth-anything/DA3MONO-LARGE
-
Download the following files:
config.jsonmodel.safetensors
-
Place the downloaded files into the
da-models/directory in the root of the repository.
Before launching the program, always ensure your virtual environment is activated:
Windows (PowerShell):
.\venv\Scripts\Activate.ps1Linux / macOS:
source venv/bin/activateCarveAnything features an interactive terminal workflow. You do not need to pass command-line arguments when launching the program.
Simply execute the main script:
python CarveAnything.pyOnce launched, the script will guide you with step-by-step on-screen prompts to input your parameters.
Generated output files (depth maps and 3D mesh files) will be saved automatically in the output/ directory.
See LICENSE for details.