Run IC-Light on Google Colab Free Tier

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).

lllyasviel / IC-Light

More relighting!

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).

Currently, we release two types of models: text-conditioned relighting model and background-conditioned model. Both types take foreground images as inputs.

Note that “iclightai dot com” is a scam website. They have no relationship with us. Do not give scam websites money! This GitHub repo is the only official IC-Light.

News

Some news about flux is here. (A fix update is added at Nov 25, more demos will be uploaded soon.)

Get Started

Below script will run the text-conditioned relighting model:

git clone https://github.com/lllyasviel/IC-Light.git
cd IC-Light
conda create -n iclight python=3.10
conda activate iclight
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
python gradio_demo.py
git clone https://github.com/lllyasviel/IC-Light.git
cd IC-Light
conda create -n iclight python=3.10
conda activate iclight
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
python gradio_demo.py
git clone https://github.com/lllyasviel/IC-Light.git cd IC-Light conda create -n iclight python=3.10 conda activate iclight pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121 pip install -r requirements.txt python gradio_demo.py

Or, to use background-conditioned demo:

python gradio_demo_bg.py
python gradio_demo_bg.py
python gradio_demo_bg.py

Model downloading is automatic.

Note that the…

View on GitHub

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

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

Enter fullscreen mode Exit fullscreen mode

Step3. Install dependencies

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

Enter fullscreen mode Exit fullscreen mode

This step will take some time.

Step4. Modify gradio_demo_bg.py

We just need to change only 1 line.

before

<span>block</span><span>.</span><span>launch</span><span>(</span><span>server_name</span><span>=</span><span>'</span><span>0.0.0.0</span><span>'</span><span>)</span>
<span>block</span><span>.</span><span>launch</span><span>(</span><span>server_name</span><span>=</span><span>'</span><span>0.0.0.0</span><span>'</span><span>)</span>
block.launch(server_name='0.0.0.0')

Enter fullscreen mode Exit fullscreen mode

after

<span>block</span><span>.</span><span>launch</span><span>(</span><span>server_name</span><span>=</span><span>'</span><span>127.0.0.1</span><span>'</span><span>,</span> <span>share</span><span>=</span><span>True</span><span>)</span>
<span>block</span><span>.</span><span>launch</span><span>(</span><span>server_name</span><span>=</span><span>'</span><span>127.0.0.1</span><span>'</span><span>,</span> <span>share</span><span>=</span><span>True</span><span>)</span>
block.launch(server_name='127.0.0.1', share=True)

Enter fullscreen mode Exit fullscreen mode

Step5. Run gradio_demo_bg.py

<span>!</span>python gradio_demo_bg.py
<span>!</span>python gradio_demo_bg.py
!python gradio_demo_bg.py

Enter fullscreen mode Exit fullscreen mode

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<span>(</span>
The cache <span>for </span>model files <span>in </span>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 <span>`</span>transformers.utils.move_cache<span>()</span><span>`</span><span>.</span>
0it <span>[</span>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 <span>for </span>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 <span>for </span>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 <span>for </span>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<span>(</span>
/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<span>(</span>
tokenizer/tokenizer_config.json: 100% 704/704 <span>[</span>00:00<00:00, 2.61MB/s]
tokenizer/vocab.json: 100% 1.06M/1.06M <span>[</span>00:00<00:00, 3.22MB/s]
tokenizer/merges.txt: 100% 525k/525k <span>[</span>00:00<00:00, 2.15MB/s]
tokenizer/special_tokens_map.json: 100% 586/586 <span>[</span>00:00<00:00, 2.40MB/s]
text_encoder/config.json: 100% 560/560 <span>[</span>00:00<00:00, 2.23MB/s]
model.safetensors: 100% 246M/246M <span>[</span>00:01<00:00, 144MB/s]
vae/config.json: 100% 606/606 <span>[</span>00:00<00:00, 2.37MB/s]
diffusion_pytorch_model.safetensors: 100% 167M/167M <span>[</span>00:01<00:00, 163MB/s]
unet/config.json: 100% 1.78k/1.78k <span>[</span>00:00<00:00, 7.60MB/s]
diffusion_pytorch_model.safetensors: 100% 1.72G/1.72G <span>[</span>00:20<00:00, 83.9MB/s]
config.json: 100% 548/548 <span>[</span>00:00<00:00, 2.31MB/s]
pytorch_model.bin: 100% 177M/177M <span>[</span>00:02<00:00, 66.7MB/s]
100% 1.60G/1.60G <span>[</span>00:13<00:00, 126MB/s]
Running on <span>local </span>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.
<span>--------</span>
Running on public URL: https://65a7c6684da105a45e.gradio.live
/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<span>(</span>
The cache <span>for </span>model files <span>in </span>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 <span>`</span>transformers.utils.move_cache<span>()</span><span>`</span><span>.</span>
0it <span>[</span>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 <span>for </span>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 <span>for </span>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 <span>for </span>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<span>(</span>
/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<span>(</span>
tokenizer/tokenizer_config.json: 100% 704/704 <span>[</span>00:00<00:00, 2.61MB/s]
tokenizer/vocab.json: 100% 1.06M/1.06M <span>[</span>00:00<00:00, 3.22MB/s]
tokenizer/merges.txt: 100% 525k/525k <span>[</span>00:00<00:00, 2.15MB/s]
tokenizer/special_tokens_map.json: 100% 586/586 <span>[</span>00:00<00:00, 2.40MB/s]
text_encoder/config.json: 100% 560/560 <span>[</span>00:00<00:00, 2.23MB/s]
model.safetensors: 100% 246M/246M <span>[</span>00:01<00:00, 144MB/s]
vae/config.json: 100% 606/606 <span>[</span>00:00<00:00, 2.37MB/s]
diffusion_pytorch_model.safetensors: 100% 167M/167M <span>[</span>00:01<00:00, 163MB/s]
unet/config.json: 100% 1.78k/1.78k <span>[</span>00:00<00:00, 7.60MB/s]
diffusion_pytorch_model.safetensors: 100% 1.72G/1.72G <span>[</span>00:20<00:00, 83.9MB/s]
config.json: 100% 548/548 <span>[</span>00:00<00:00, 2.31MB/s]
pytorch_model.bin: 100% 177M/177M <span>[</span>00:02<00:00, 66.7MB/s]
100% 1.60G/1.60G <span>[</span>00:13<00:00, 126MB/s]
Running on <span>local </span>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.
<span>--------</span>
Running on public URL: https://65a7c6684da105a45e.gradio.live
/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

Enter fullscreen mode Exit fullscreen mode

Then you need to access Running on public URL.
When you access the public URL, you will see something like

Enjoy IC-Light!

原文链接:Run IC-Light on Google Colab Free Tier

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
We are the tender love in the world.
我们都在被这个世界温柔的爱着
评论 抢沙发

请登录后发表评论

    暂无评论内容