Skip to content

Instantly share code, notes, and snippets.

@Mihirsahu2307
Last active April 22, 2024 12:41
Show Gist options
  • Save Mihirsahu2307/897f51187420eceb1b014f7a468a1a3a to your computer and use it in GitHub Desktop.
Save Mihirsahu2307/897f51187420eceb1b014f7a468a1a3a to your computer and use it in GitHub Desktop.
Updated Clevr image generation on Colab (works as of 22/04/24)
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
"source": [
"!git clone https://github.com/facebookresearch/clevr-dataset-gen.git"
],
"metadata": {
"id": "haP0mNWRFtL6",
"collapsed": true
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "NT-LW2iBQ2sJ",
"collapsed": true
},
"source": [
"!apt install blender\n",
"!apt install libboost-all-dev\n",
"!apt install libgl1-mesa-dev"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "ojIwubdnROwZ"
},
"source": [
"blender_version = 'blender2.79' #@param [\"blender2.79\", \"blender2.80\", \"blender2.81\", \"blender2.82\", \"blender2.83\", \"blender2.90.1\", \"blender2.91.2\"] {allow-input: false}\n",
"gpu_enabled = True #@param {type:\"boolean\"}\n",
"cpu_enabled = False #@param {type:\"boolean\"}"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "BxAsAPz9SBUa"
},
"source": [
"if blender_version == \"blender2.79\":\n",
" download_path=\"https://download.blender.org/release/Blender2.79/blender-2.79-linux-glibc219-x86_64.tar.bz2\"\n",
"else:\n",
" raise NotImplementedError"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "AAX05CUVYyM9",
"collapsed": true
},
"source": [
"!mkdir $blender_version\n",
"if blender_version == \"blender2.79\":\n",
" !wget -O '{blender_version}.tar.xz' -nc $download_path\n",
" !tar xf '{blender_version}.tar.xz' -C ./$blender_version --strip-components=1\n",
"else:\n",
" raise NotImplementedError"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "Bw4p_etoY5LE",
"collapsed": true
},
"source": [
"import os\n",
"\n",
"os.environ[\"LD_PRELOAD\"] = \"\"\n",
"\n",
"!apt update\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.5.9\"\n",
"\n",
"!echo $LD_PRELOAD"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "mo2mXUKbZPTN",
"collapsed": true
},
"source": [
"!apt install libboost-all-dev\n",
"!apt install libgl1-mesa-dev\n",
"!apt install libglu1-mesa libsm-dev"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!echo /content/clevr-dataset-gen/image_generation >> blender2.79/2.79/python/lib/python3.5/site-packages/clevr.pth"
],
"metadata": {
"id": "a6tJiktxpGyz"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!cat /content/blender2.79/2.79/python/lib/python3.5/site-packages/clevr.pth"
],
"metadata": {
"collapsed": true,
"id": "IkxkoVWjtcS8"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"%cd clevr-dataset-gen/image_generation"
],
"metadata": {
"collapsed": true,
"id": "zoxg435jrw6d"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!/content/$blender_version/blender --background -noaudio --python render_images.py -- --num_images=5"
],
"metadata": {
"collapsed": true,
"id": "kQVEN5ZGpomZ"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment