Spaces:
Paused
Paused
Update app.py
Browse files20 unmodified lines212223242425262730 unmodified lines585960616162636421 unmodified lines868788898990919293949593949596979828 unmodified lines12712812913013013113213313413513513613713891 unmodified lines23023123223323323423523623623723823954 unmodified lines29429529629729729829930082 unmodified lines383384385386386387388389136 unmodified lines52652752852952953053153253353453553653753853253353453553653753853954054177 unmodified lines61962062162262262362462520 unmodified linesfrom style_template import stylesfrom pipeline_stable_diffusion_xl_instantid_full import StableDiffusionXLInstantIDPipeline, draw_kps
from controlnet_aux import OpenposeDetector# from controlnet_aux import OpenposeDetector
import gradio as gr
30 unmodified lines)app.prepare(ctx_id=0, det_size=(640, 640))
openpose = OpenposeDetector.from_pretrained("lllyasviel/ControlNet")# openpose = OpenposeDetector.from_pretrained("lllyasviel/ControlNet")
depth_anything = DepthAnything.from_pretrained('LiheYoung/depth_anything_vitl14').to(device).eval()
21 unmodified lines)
# controlnet-pose/canny/depthcontrolnet_pose_model = "thibaud/controlnet-openpose-sdxl-1.0"# controlnet_pose_model = "thibaud/controlnet-openpose-sdxl-1.0"controlnet_canny_model = "diffusers/controlnet-canny-sdxl-1.0"controlnet_depth_model = "diffusers/controlnet-depth-sdxl-1.0-small"
controlnet_pose = ControlNetModel.from_pretrained( controlnet_pose_model, torch_dtype=dtype).to(device)# controlnet_pose = ControlNetModel.from_pretrained(# controlnet_pose_model, torch_dtype=dtype# ).to(device)controlnet_canny = ControlNetModel.from_pretrained( controlnet_canny_model, torch_dtype=dtype).to(device)28 unmodified lines return Image.fromarray(edges, "L")
controlnet_map = { "pose": controlnet_pose, # "pose": controlnet_pose, "canny": controlnet_canny, "depth": controlnet_depth,}controlnet_map_fn = { "pose": openpose, # "pose": openpose, "canny": get_canny_image, "depth": get_depth_map,}91 unmodified lines 20, # num_steps 0.8, # identitynet_strength_ratio 0.8, # adapter_strength_ratio 0.4, # pose_strength # 0.4, # pose_strength 0.3, # canny_strength 0.5, # depth_strength ["pose", "canny"], # controlnet_selection ["depth", "canny"], # controlnet_selection 5.0, # guidance_scale 42, # seed "EulerDiscreteScheduler", # scheduler54 unmodified lines num_steps, identitynet_strength_ratio, adapter_strength_ratio, pose_strength, # pose_strength, canny_strength, depth_strength, controlnet_selection,82 unmodified lines
if len(controlnet_selection) > 0: controlnet_scales = { "pose": pose_strength, # "pose": pose_strength, "canny": canny_strength, "depth": depth_strength, }136 unmodified lines ) with gr.Accordion("Controlnet"): controlnet_selection = gr.CheckboxGroup( ["pose", "canny", "depth"], label="Controlnet", value=["pose"], ["canny", "depth"], label="Controlnet", value=["canny"], info="Use pose for skeleton inference, canny for edge detection, and depth for depth map estimation. You can try all three to control the generation process" ) pose_strength = gr.Slider( label="Pose strength", minimum=0, maximum=1.5, step=0.05, value=0.40, ) # pose_strength = gr.Slider( # label="Pose strength", # minimum=0, # maximum=1.5, # step=0.05, # value=0.40, # ) canny_strength = gr.Slider( label="Canny strength", minimum=0,77 unmodified lines num_steps, identitynet_strength_ratio, adapter_strength_ratio, pose_strength, # pose_strength, canny_strength, depth_strength, controlnet_selection,app.py+21-21