diff --git a/README.md b/README.md index f44afc9..c70b5ba 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,20 @@ Model downloading is automatic. Note that the "gradio_demo.py" has an official [huggingFace Space here](https://huggingface.co/spaces/lllyasviel/IC-Light). +## Use Google Colab + +Below script will run the text-conditioned relighting model: + + !git clone https://github.com/lllyasviel/IC-Light.git + %cd IC-Light + !pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121 + !pip install -r requirements.txt + !python gradio_demo.py --share + +Or, to use background-conditioned demo: + + !python gradio_demo_bg.py --share + # Screenshot ### Text-Conditioned Model diff --git a/gradio_demo.py b/gradio_demo.py index eab8eac..b8e1281 100644 --- a/gradio_demo.py +++ b/gradio_demo.py @@ -5,6 +5,7 @@ import torch import safetensors.torch as sf import db_examples +import argparse from PIL import Image from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline @@ -25,6 +26,11 @@ unet = UNet2DConditionModel.from_pretrained(sd15_name, subfolder="unet") rmbg = BriaRMBG.from_pretrained("briaai/RMBG-1.4") +# command line arguments +parser = argparse.ArgumentParser(description='IC-Light Relighting with Foreground Condition') +parser.add_argument('--share', action='store_true', help='Share the app on Gradio') +args = parser.parse_args() + # Change UNet with torch.no_grad(): @@ -430,4 +436,4 @@ class BGSource(Enum): example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False) -block.launch(server_name='0.0.0.0') +block.launch(server_name='0.0.0.0', share=args.share) diff --git a/gradio_demo_bg.py b/gradio_demo_bg.py index 50fd642..c81e4b8 100644 --- a/gradio_demo_bg.py +++ b/gradio_demo_bg.py @@ -5,6 +5,7 @@ import torch import safetensors.torch as sf import db_examples +import argparse from PIL import Image from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline @@ -25,6 +26,11 @@ unet = UNet2DConditionModel.from_pretrained(sd15_name, subfolder="unet") rmbg = BriaRMBG.from_pretrained("briaai/RMBG-1.4") +# command line arguments +parser = argparse.ArgumentParser(description='IC-Light Relighting with Background Condition') +parser.add_argument('--share', action='store_true', help='Share the app on Gradio') +args = parser.parse_args() + # Change UNet with torch.no_grad(): @@ -462,4 +468,4 @@ def bg_gallery_selected(gal, evt: gr.SelectData): bg_gallery.select(bg_gallery_selected, inputs=bg_gallery, outputs=input_bg) -block.launch(server_name='0.0.0.0') +block.launch(server_name='0.0.0.0', share=args.share)