Skip to content

Instantly share code, notes, and snippets.

@erfto1
Created August 26, 2025 18:24
Show Gist options
  • Save erfto1/f4ef7ea8915df41f66c65618b9e45ea7 to your computer and use it in GitHub Desktop.
Save erfto1/f4ef7ea8915df41f66c65618b9e45ea7 to your computer and use it in GitHub Desktop.
MeshroomColab.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/erfto1/f4ef7ea8915df41f66c65618b9e45ea7/meshroomcolab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "TZh8CZsjwfD1"
},
"source": [
"\n",
"**Meshroom for GoogleColab**\n",
"\n",
"This is an example on how to use Meshroom in GoogleColab with uploaded images to generate a textured mesh (OBJ) that can be downloaded.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3wBFjbjIz9ZX"
},
"source": [
"**0. Connect to Google Drive (optional)**\n",
"\n",
"Paste your authorisation code and resume with Enter\n"
]
},
{
"cell_type": "code",
"metadata": {
"id": "NB2T3gnb1GY4"
},
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive')"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "kpxHm8UdUpzc"
},
"source": [
"Create a temp folder in your istance"
]
},
{
"cell_type": "code",
"metadata": {
"id": "HIsZd9i70xVT"
},
"source": [
"%cd /content\n",
"!mkdir temp\n",
"!mkdir meshroom\n",
"!ls # check dir"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "7kShJYbj6GS6"
},
"source": [
"**1. Download Meshroom 2025.1.0**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "oDLXn_M6R-zz"
},
"source": [
"%cd temp\n",
"!wget -N https://zenodo.org/records/16887472/files/Meshroom-2025.1.0-Linux.tar.gz\n",
"!tar -xvf Meshroom-2025.1.0-Linux.tar.gz -C ../meshroom"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "mmSZ5le1wl1r"
},
"source": [
"Create folder for image upload (§ can be skipped when using Google Drive)\n"
]
},
{
"cell_type": "code",
"metadata": {
"id": "BP3p_lGEq69X"
},
"source": [
"%cd /content\n",
"!mkdir input\n",
"!ls # check dir"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "zUd42W__QE2p"
},
"source": [
"**2. Upload images** (§ optional)\n",
"\n",
"(It is possible to link to a GoogleDrive folder instead. Just comment the following cell and use the next one.)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "MpXT0L6ywoSa"
},
"source": [
"%cd input\n",
"from google.colab import files\n",
"\n",
"# optional upload for the images\n",
"\n",
"uploaded = files.upload()\n",
"\n",
"for fn in uploaded.keys():\n",
" print('User uploaded file \"{name}\" with length {length} bytes'.format( name=fn, length=len(uploaded[fn])))\n",
"\n",
"!ls # list uploaded images"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "QMspCFLAs_K7"
},
"source": [
"Copy image from your drive to /content/input (§)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "nlqgbqAHZbeM"
},
"source": [
"# !cp -r \"/content/drive/My Drive/path/to/your/images\" /content/input"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "4E_kAx-2wq3O"
},
"source": [
"\n",
"**3. Run Meshroom**\n",
"\n",
"The node temp files are stored in the **/tmp/MeshroomCache** folder, the **/content/out** is only for the final result.\n",
"\n",
"(It is possible to use a Meshroom graph file (.mg) with costumized parameters and nodes instead of the following default pipeline. Might be added to this notepad in the future)\n",
"\n",
"When using Google Drive, provide the path to your image folder: --input YOUR/IMAGEs/FOLDER/PATH (the easiest solution is to create a input folder in ./yourprojectfolder/meshroom/Meshroom-2025.1.0/meshroom_batch with all your images)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "3GimHqrGwsmu"
},
"source": [
"!mkdir out\n",
"!/content/meshroom/Meshroom-2025.1.0/meshroom_batch --input /content/input --output out"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "49aKN-I0Oddu"
},
"source": [
"**4. Preview Mesh using Trimesh (optional)**\n",
"\n",
"This is experimental and not optimized"
]
},
{
"cell_type": "code",
"metadata": {
"id": "uY7p1hKj81Uq"
},
"source": [
"!pip install trimesh"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "exhdh1bu_8VY"
},
"source": [
"!ls"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "9SwOo0WCRtmw"
},
"source": [
"%cd out"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "kTYgiJauVF26"
},
"source": [
"Start preview"
]
},
{
"cell_type": "code",
"metadata": {
"id": "fWi3nrpn8_ZT"
},
"source": [
"import numpy as np\n",
"import trimesh\n",
"mesh = trimesh.load_mesh('texturedMesh.obj')\n",
"mesh.show()"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "dV3uF6ZmCX-x"
},
"source": [
"Read https://trimesh.org/index.html#quick-start for details\n",
"\n",
"**Before downloading, change back to the contents folder:**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "-6dc2xQ8SJYT"
},
"source": [
"%cd ../"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "_EZJtblswuZy"
},
"source": [
"\n",
"**5. Download**\n",
"\n",
"Use the prefered download format (tar.gz or zip)\n"
]
},
{
"cell_type": "code",
"metadata": {
"id": "IirusdKJwz-6"
},
"source": [
"!tar -czvf out.tar.gz ./out\n",
"from google.colab import files\n",
"\n",
"files.download('out.tar.gz')"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "VQ8F_rxPw4dK"
},
"source": [
"!zip -r out.zip ./out\n",
"from google.colab import files\n",
"\n",
"files.download('out.zip')"
],
"execution_count": null,
"outputs": []
}
],
"metadata": {
"colab": {
"provenance": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"accelerator": "GPU"
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment