Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --share option so that it can also be used with Google Colab #30

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion gradio_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down Expand Up @@ -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)
8 changes: 7 additions & 1 deletion gradio_demo_bg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down Expand Up @@ -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)