From f6aff8b8a28949fb04072ee11cb0fb17b90ccb26 Mon Sep 17 00:00:00 2001 From: shinshin86 Date: Sat, 11 May 2024 10:16:10 +0900 Subject: [PATCH 1/2] Added --share option so that it can also be used with Google Colab --- README.md | 10 ++++++++++ gradio_demo.py | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f44afc9..363fdab 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,16 @@ 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 + # 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) From f915c6a83361fdb42ea91c5c30639cdc450df4ba Mon Sep 17 00:00:00 2001 From: shinshin86 Date: Sat, 11 May 2024 10:43:36 +0900 Subject: [PATCH 2/2] fix gradio_demo_bg.py --- README.md | 4 ++++ gradio_demo_bg.py | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 363fdab..c70b5ba 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,10 @@ Below script will run the text-conditioned relighting model: !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_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)