-
Notifications
You must be signed in to change notification settings - Fork 0
/
render
1 lines (1 loc) · 3.19 KB
/
render
1
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"render","provenance":[],"collapsed_sections":["1MvAxqiFLBVy","MVxWg6WD-pHJ","SaDOcwdsDIEb"],"authorship_tag":"ABX9TyNrp6xR/FwwJB9l6njbof2B"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"},"accelerator":"GPU"},"cells":[{"cell_type":"markdown","source":["# Always run before doing anything "],"metadata":{"id":"1MvAxqiFLBVy"}},{"cell_type":"code","source":["# Always run before doing anything \n","\n","mount_path = '/content/drive/' #@param {type: \"string\"}\n","output = f'{mount_path}Blender/Images' \n","project_dir = f'{mount_path}MyDrive/Blender/Blend/'\n","blender_dir = f'{mount_path}MyDrive/Blender/'\n","blender_path = f'{mount_path}MyDrive/Blender/blender-3.0.0-linux-x64/blender'\n","blender_url = 'https://download.blender.org/release/Blender3.0/blender-3.0.0-linux-x64.tar.xz'\n","engine = \"CYCLES\" #@param [\"CYCLES\", \"BLENDER_RENDER\"]\n","from google.colab import drive\n","drive.mount(mount_path, force_remount=True)\n"],"metadata":{"id":"MsUXSuHMLchO"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["# Setup"],"metadata":{"id":"MVxWg6WD-pHJ"}},{"cell_type":"code","source":["# run for the first time.\n","# make folders .\n","\n","\n","while True:\n"," if os.path.isdir(f'{mount_path}MyDrive/Blender'):\n"," if os.path.isdir(f'{mount_path}MyDrive/Blender/Images'):\n"," if os.path.isdir(f'{mount_path}MyDrive/Blender/Blend'):\n"," break\n"," else:\n"," os.mkdir(f'{mount_path}MyDrive/Blender/Blend')\n"," else:\n"," os.mkdir(f'{mount_path}MyDrive/Blender/Images')\n"," else:\n"," os.mkdir(f'{mount_path}MyDrive/Blender')\n"],"metadata":{"id":"OD07GNcs-tOU"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["!echo \"Downloading Blender\"\n","!wget $blender_url\n","!echo \"Downloaded\"\n","!echo \"Extracting zip file\"\n","!tar xf blender-3.0.0-linux-x64.tar.xz\n","!mv blender-3.0.0-linux-x64 $blender_dir\n","!rm -rf blender-3.0.0-linux-x64.tar.xz\n","\n"],"metadata":{"id":"8K6TaEO9Aq0E"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["# Start Render\n"],"metadata":{"id":"SaDOcwdsDIEb"}},{"cell_type":"code","source":["#input project file name\n","import os\n","\n","while True:\n"," name = input(\"name of the file with '.blend' - \")\n"," file_name = project_dir+name\n"," if os.path.isfile(file_name):\n"," break\n"," else:\n"," print(\"The file was not found\")\n"," print(\"List of available files :\")\n"," !ls $project_dir\n","output_name = name.strip(\".blend\")"],"metadata":{"id":"o-A-Nr2eDSBy"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# just important\n","os.environ[\"LD_PRELOAD\"] = \"\"\n","!apt remove libtcmalloc-minimal4\n","!apt install libtcmalloc-minimal4\n","os.environ[\"LD_PRELOAD\"] = \"/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4.3.0\""],"metadata":{"id":"9A2vBcNPD-an"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["!chmod 744 $blender_path\n","!$blender_path -b $file_name -noaudio -E 'CYCLES' -o $output_name -f 1 -F 'PNG' -- --cycles-device CUDA"],"metadata":{"id":"dU2hhX3jEF0A"},"execution_count":null,"outputs":[]}]}