Skip to content
Merged
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
31 changes: 20 additions & 11 deletions benchmarks/instant_id.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Requirements: diffusers==0.25.1.
# Reference: https://github.com/InstantID/InstantID/blob/main/gradio_demo/requirements.txt
REPO = None
FACE_ANALYSIS_ROOT = None
MODEL = "wangqixun/YamerMIX_v8"
VARIANT = None
CUSTOM_PIPELINE = None
CUSTOM_PIPELINE = "pipeline_stable_diffusion_xl_instantid"
SCHEDULER = "EulerAncestralDiscreteScheduler"
LORA = None
CONTROLNET = "InstantX/InstantID"
Expand Down Expand Up @@ -148,9 +150,6 @@ def callback_on_step_end(self, pipe, i, t, callback_kwargs={}):
def main():
args = parse_args()

assert (
args.repo is not None
), "Please set `--repo` to the local path of the cloned repo of https://github.com/InstantID/InstantID"
assert (
args.controlnet is not None
), "Please set `--controlnet` to the name or path of the controlnet"
Expand Down Expand Up @@ -179,12 +178,19 @@ def main():
with open(attention_processor_path, "w") as f:
f.write(content)

sys.path.insert(0, args.repo)
custom_pipeline = None
draw_kps = None
if args.repo is None:
custom_pipeline = args.custom_pipeline
from diffusers import DiffusionPipeline
pipeline_cls = DiffusionPipeline
else:
sys.path.insert(0, args.repo)

from pipeline_stable_diffusion_xl_instantid import (
StableDiffusionXLInstantIDPipeline,
draw_kps,
)
from pipeline_stable_diffusion_xl_instantid import (
StableDiffusionXLInstantIDPipeline as pipeline_cls,
draw_kps,
)

if os.path.exists(args.controlnet):
controlnet = args.controlnet
Expand All @@ -202,15 +208,18 @@ def main():
controlnet_path = os.path.join(controlnet, "ControlNetModel")

pipe = load_pipe(
StableDiffusionXLInstantIDPipeline,
pipeline_cls,
args.model,
variant=args.variant,
custom_pipeline=args.custom_pipeline,
custom_pipeline=custom_pipeline,
scheduler=args.scheduler,
lora=args.lora,
controlnet=controlnet_path,
)

if draw_kps is None:
draw_kps = sys.modules[pipe.__module__].draw_kps

pipe.load_ip_adapter_instantid(face_adapter)

height = args.height or pipe.unet.config.sample_size * pipe.vae_scale_factor
Expand Down