Run IC-Light on Google Colab Free Tier

0𝕏koji
2 min readMay 11, 2024

--

What is IC-Light?

IC-Light is a project to manipulate the illumination of images.
The name “IC-Light” stands for “Imposing Consistent Light” (we will briefly describe this at the end of this page).

How to Run IC-Light on Google Colab?

The steps we need are very straightforward and not difficult.

Step1. Change Runtime on Google Colab

Go to https://colab.research.google.com/ and click Runtime -> Change Runtime -> T4 GPU

Step2. Clone the repo

!git clone https://github.com/lllyasviel/IC-Light.git

Step3. Install dependencies

cd IC-Light
!pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
!pip install -r requirements.txt

This step will take some time.

Step4. Modify gradio_demo_bg.py

We just need to change only 1 line.

# before
block.launch(server_name='0.0.0.0')

# after
block.launch(server_name='127.0.0.1', share=True)

Step5. Run gradio_demo_bg.py

!python gradio_demo_bg.py

You will see something like this. This step also would take some time since need to download models.

/usr/local/lib/python3.10/dist-packages/transformers/utils/generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
_torch_pytree._register_pytree_node(
The cache for model files in Transformers v4.22.0 has been updated. Migrating your old cache. This is a one-time only operation. You can interrupt this and resume the migration later on by calling `transformers.utils.move_cache()`.
0it [00:00, ?it/s]
2024-05-11 01:08:16.363718: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-05-11 01:08:16.363780: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-05-11 01:08:16.493211: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-05-11 01:08:18.972938: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
/usr/local/lib/python3.10/dist-packages/transformers/utils/generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
_torch_pytree._register_pytree_node(
/usr/local/lib/python3.10/dist-packages/transformers/utils/generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
_torch_pytree._register_pytree_node(
tokenizer/tokenizer_config.json: 100% 704/704 [00:00<00:00, 2.61MB/s]
tokenizer/vocab.json: 100% 1.06M/1.06M [00:00<00:00, 3.22MB/s]
tokenizer/merges.txt: 100% 525k/525k [00:00<00:00, 2.15MB/s]
tokenizer/special_tokens_map.json: 100% 586/586 [00:00<00:00, 2.40MB/s]
text_encoder/config.json: 100% 560/560 [00:00<00:00, 2.23MB/s]
model.safetensors: 100% 246M/246M [00:01<00:00, 144MB/s]
vae/config.json: 100% 606/606 [00:00<00:00, 2.37MB/s]
diffusion_pytorch_model.safetensors: 100% 167M/167M [00:01<00:00, 163MB/s]
unet/config.json: 100% 1.78k/1.78k [00:00<00:00, 7.60MB/s]
diffusion_pytorch_model.safetensors: 100% 1.72G/1.72G [00:20<00:00, 83.9MB/s]
config.json: 100% 548/548 [00:00<00:00, 2.31MB/s]
pytorch_model.bin: 100% 177M/177M [00:02<00:00, 66.7MB/s]
100% 1.60G/1.60G [00:13<00:00, 126MB/s]
Running on local URL: http://127.0.0.1:7860
IMPORTANT: You are using gradio version 3.41.2, however version 4.29.0 is available, please upgrade.
--------
Running on public URL: https://65a7c6684da105a45e.gradio.live

Then you need to access Running on public URL

When you access the public url, you will see something like below.

Enjoy IC-Light!

--

--

0𝕏koji

software engineer works for a Biotechnology Research startup in Brooklyn. #CreativeCoding #Art #IoT #MachineLearning #python #typescript #javascript #reactjs