Spaces:
Paused
Paused
Update app.py
Browse files20 unmodified lines2122232425262730 unmodified lines5859606162636421 unmodified lines8687888990919293949596979828 unmodified lines12712812913013113213313413513613713891 unmodified lines23023123223323423523623723823954 unmodified lines29429529629729829930082 unmodified lines383384385386387388389136 unmodified lines52652752852953053153253353453553653753853954054177 unmodified lines61962062162262362462520 unmodified linesfrom style_template import stylesfrom pipeline_stable_diffusion_xl_instantid_full import StableDiffusionXLInstantIDPipeline, draw_kpsfrom controlnet_aux import OpenposeDetectorimport gradio as gr30 unmodified lines)app.prepare(ctx_id=0, det_size=(640, 640))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_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_canny = ControlNetModel.from_pretrained(controlnet_canny_model, torch_dtype=dtype).to(device)28 unmodified linesreturn Image.fromarray(edges, "L")controlnet_map = {"pose": controlnet_pose,"canny": controlnet_canny,"depth": controlnet_depth,}controlnet_map_fn = {"pose": openpose,"canny": get_canny_image,"depth": get_depth_map,}91 unmodified lines20, # num_steps0.8, # identitynet_strength_ratio0.8, # adapter_strength_ratio0.4, # pose_strength0.3, # canny_strength0.5, # depth_strength["pose", "canny"], # controlnet_selection5.0, # guidance_scale42, # seed"EulerDiscreteScheduler", # scheduler54 unmodified linesnum_steps,identitynet_strength_ratio,adapter_strength_ratio,pose_strength,canny_strength,depth_strength,controlnet_selection,82 unmodified linesif len(controlnet_selection) > 0:controlnet_scales = {"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"],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,)canny_strength = gr.Slider(label="Canny strength",minimum=0,77 unmodified linesnum_steps,identitynet_strength_ratio,adapter_strength_ratio,pose_strength,canny_strength,depth_strength,controlnet_selection,20 unmodified lines2122232425262730 unmodified lines5859606162636421 unmodified lines8687888990919293949596979828 unmodified lines12712812913013113213313413513613713891 unmodified lines23023123223323423523623723823954 unmodified lines29429529629729829930082 unmodified lines383384385386387388389136 unmodified lines52652752852953053153253353453553653753853954054177 unmodified lines61962062162262362462520 unmodified linesfrom style_template import stylesfrom pipeline_stable_diffusion_xl_instantid_full import StableDiffusionXLInstantIDPipeline, draw_kps# from controlnet_aux import OpenposeDetectorimport gradio as gr30 unmodified lines)app.prepare(ctx_id=0, det_size=(640, 640))# openpose = OpenposeDetector.from_pretrained("lllyasviel/ControlNet")depth_anything = DepthAnything.from_pretrained('LiheYoung/depth_anything_vitl14').to(device).eval()21 unmodified lines)# controlnet-pose/canny/depth# 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_canny = ControlNetModel.from_pretrained(controlnet_canny_model, torch_dtype=dtype).to(device)28 unmodified linesreturn Image.fromarray(edges, "L")controlnet_map = {# "pose": controlnet_pose,"canny": controlnet_canny,"depth": controlnet_depth,}controlnet_map_fn = {# "pose": openpose,"canny": get_canny_image,"depth": get_depth_map,}91 unmodified lines20, # num_steps0.8, # identitynet_strength_ratio0.8, # adapter_strength_ratio# 0.4, # pose_strength0.3, # canny_strength0.5, # depth_strength["depth", "canny"], # controlnet_selection5.0, # guidance_scale42, # seed"EulerDiscreteScheduler", # scheduler54 unmodified linesnum_steps,identitynet_strength_ratio,adapter_strength_ratio,# pose_strength,canny_strength,depth_strength,controlnet_selection,82 unmodified linesif len(controlnet_selection) > 0:controlnet_scales = {# "pose": pose_strength,"canny": canny_strength,"depth": depth_strength,}136 unmodified lines)with gr.Accordion("Controlnet"):controlnet_selection = gr.CheckboxGroup(["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,# )canny_strength = gr.Slider(label="Canny strength",minimum=0,77 unmodified linesnum_steps,identitynet_strength_ratio,adapter_strength_ratio,# pose_strength,canny_strength,depth_strength,controlnet_selection,
app.py+21-21