Spaces:
Runtime error
Runtime error
Ming Li commited on
Commit Β·
cce8954
1
Parent(s): 1f3a0a5
update demo
Browse filesFiles changed (16)
- app.py+2-24
- app_canny.py+21-2
- app_depth.py+22-2
- app_lineart.py+40-4
- app_segmentation.py+25-2
- app_softedge.py+21-2
- images/canny_demo.jpg β images/canny/canny_demo.jpgRenamed
- images/depth_demo.png β images/depth/depth_demo.pngRenamed
- images/hed_demo.jpeg β images/hed/hed_demo.jpegRenamed
- images/lineart/Ryan Reynolds_1.pngAdded
- images/lineart/Ryan Reynolds_2.pngAdded
- images/lineart/Ryan Reynolds_3.pngAdded
- images/lineart_demo.jpg β images/lineart/tube.jpgRenamed
- images/seg/33.pngAdded
- images/seg_demo.png β images/seg/seg_demo.pngRenamed
- model.py+6-1
13 unmodified lines1415161718193 unmodified lines23242526272829303132333435363738394041424344454647484950515213 unmodified linesfrom app_softedge import create_demo as create_demo_softedgefrom model import Modelfrom settings import ALLOW_CHANGING_BASE_MODEL, DEFAULT_MODEL_ID, SHOW_DUPLICATE_BUTTONDESCRIPTION = "# [ControlNet++: Improving Conditional Controls with Efficient Consistency Feedback](https://arxiv.org/abs/2404.07987)"3 unmodified linesmodel = Model(base_model_id=DEFAULT_MODEL_ID, task_name="Canny")# examples = [# [# "images/canny_demo.jpg",# "BEAUTIFUL PORTRAIT PAINTINGS BY EMMA UBER",# ],# [# "images/depth_demo.jpg",# "BEAUTIFUL PORTRAIT PAINTINGS BY EMMA UBER",# ],# [# "images/hed_demo.jpg",# "BEAUTIFUL PORTRAIT PAINTINGS BY EMMA UBER",# ],# [# "images/lineart_demo.jpg",# "BEAUTIFUL PORTRAIT PAINTINGS BY EMMA UBER",# ],# [# "images/seg_demo.jpg",# "BEAUTIFUL PORTRAIT PAINTINGS BY EMMA UBER",# ],# ]with gr.Blocks(css="style.css") as demo:gr.Markdown(DESCRIPTION)gr.DuplicateButton(13 unmodified lines14151617181920213 unmodified lines25262728293013 unmodified linesfrom app_softedge import create_demo as create_demo_softedgefrom model import Modelfrom settings import ALLOW_CHANGING_BASE_MODEL, DEFAULT_MODEL_ID, SHOW_DUPLICATE_BUTTONfrom transformers.utils.hub import move_cachemove_cache()DESCRIPTION = "# [ControlNet++: Improving Conditional Controls with Efficient Consistency Feedback](https://arxiv.org/abs/2404.07987)"3 unmodified linesmodel = Model(base_model_id=DEFAULT_MODEL_ID, task_name="Canny")with gr.Blocks(css="style.css") as demo:gr.Markdown(DESCRIPTION)gr.DuplicateButton(
10 unmodified lines1112131415161718192021222323 unmodified lines47484950515210 unmodified lines)from utils import randomize_seed_fndef create_demo(process):with gr.Blocks() as demo:with gr.Row():with gr.Column():image = gr.Image(value='images/canny_demo.jpg')prompt = gr.Textbox(label="Prompt", value='BEAUTIFUL PORTRAIT PAINTINGS BY EMMA UBER')run_button = gr.Button("Run")with gr.Accordion("Advanced options", open=False):num_samples = gr.Slider(23 unmodified lines)with gr.Column():result = gr.Gallery(label="Output", show_label=False, columns=2, object_fit="scale-down")inputs = [image,prompt,10 unmodified lines1112131415161718192021222324252627282923 unmodified lines5354555657585960616263646566676869707110 unmodified lines)from utils import randomize_seed_fnexamples = [["images/canny/canny_demo.jpg","BEAUTIFUL PORTRAIT PAINTINGS BY EMMA UBER",],]def create_demo(process):with gr.Blocks() as demo:with gr.Row():with gr.Column():image = gr.Image()prompt = gr.Textbox(label="Prompt")run_button = gr.Button("Run")with gr.Accordion("Advanced options", open=False):num_samples = gr.Slider(23 unmodified lines)with gr.Column():result = gr.Gallery(label="Output", show_label=False, columns=2, object_fit="scale-down")gr.Examples(examples=examples,inputs=[image,prompt,guidance_scale,seed,],outputs=result,fn=process,)inputs = [image,prompt,
10 unmodified lines1112131415161718192021222323 unmodified lines47484950515210 unmodified lines)from utils import randomize_seed_fndef create_demo(process):with gr.Blocks() as demo:with gr.Row():with gr.Column():image = gr.Image(value='images/depth_demo.png')prompt = gr.Textbox(label="Prompt", value='heart, mountains, and nature image')run_button = gr.Button("Run")with gr.Accordion("Advanced options", open=False):preprocessor_name = gr.Radio(23 unmodified lines)with gr.Column():result = gr.Gallery(label="Output", show_label=False, columns=2, object_fit="scale-down")inputs = [image,prompt,10 unmodified lines111213141516171819202122232425262728293023 unmodified lines5455565758596061626364656667686970717210 unmodified lines)from utils import randomize_seed_fnexamples = [["images/depth/depth_demo.png","heart, mountains, and nature image",],]def create_demo(process):with gr.Blocks() as demo:with gr.Row():with gr.Column():image = gr.Image()prompt = gr.Textbox(label="Prompt")run_button = gr.Button("Run")with gr.Accordion("Advanced options", open=False):preprocessor_name = gr.Radio(23 unmodified lines)with gr.Column():result = gr.Gallery(label="Output", show_label=False, columns=2, object_fit="scale-down")gr.Examples(examples=examples,inputs=[image,prompt,guidance_scale,seed,],outputs=result,fn=process,)inputs = [image,prompt,
11 unmodified lines12131415161718192021222326 unmodified lines5051525354555657585960616211 unmodified linesfrom utils import randomize_seed_fndef create_demo(process):with gr.Blocks() as demo:with gr.Row():with gr.Column():image = gr.Image(value='images/lineart_demo.jpg')prompt = gr.Textbox(label="Prompt", value='Picture Of Looking Through A View Finder')run_button = gr.Button("Run")with gr.Accordion("Advanced options", open=False):preprocessor_name = gr.Radio(26 unmodified linesguidance_scale = gr.Slider(label="Guidance scale", minimum=0.1, maximum=30.0, value=7.5, step=0.1)seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)randomize_seed = gr.Checkbox(label="Randomize seed", value=True)a_prompt = gr.Textbox(label="Additional prompt", value="high-quality, extremely detailed, 4K")n_prompt = gr.Textbox(label="Negative prompt",value="longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality",)with gr.Column():result = gr.Gallery(label="Output", show_label=False, columns=2, object_fit="scale-down")inputs = [image,prompt,11 unmodified lines12131415161718192021222324252627282930313233343536373839404142434445464726 unmodified lines7475767778798081828384858687888990919293949596979811 unmodified linesfrom utils import randomize_seed_fnexamples = [["images/lineart/Ryan Reynolds_1.png","Ryan Reynolds","None",],["images/lineart/Ryan Reynolds_2.png","Ryan Reynolds","None",],["images/lineart/Ryan Reynolds_3.png","Ryan Reynolds","None",],["images/lineart/tube.jpg","Picture Of Looking Through A View Finder","Lineart",],]def create_demo(process):with gr.Blocks() as demo:with gr.Row():with gr.Column():image = gr.Image()prompt = gr.Textbox(label="Prompt")run_button = gr.Button("Run")with gr.Accordion("Advanced options", open=False):preprocessor_name = gr.Radio(26 unmodified linesguidance_scale = gr.Slider(label="Guidance scale", minimum=0.1, maximum=30.0, value=7.5, step=0.1)seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)randomize_seed = gr.Checkbox(label="Randomize seed", value=True)a_prompt = gr.Textbox(label="Additional prompt")n_prompt = gr.Textbox(label="Negative prompt",)with gr.Column():result = gr.Gallery(label="Output", show_label=False, columns=2, object_fit="scale-down")gr.Examples(examples=examples,inputs=[image,prompt,preprocessor_name],outputs=result,fn=process,)inputs = [image,prompt,
10 unmodified lines1112131415161718192021222323 unmodified lines47484950515210 unmodified lines)from utils import randomize_seed_fndef create_demo(process):with gr.Blocks() as demo:with gr.Row():with gr.Column():image = gr.Image(value='images/seg_demo.png')prompt = gr.Textbox(label="Prompt", value='A large building with a pointed roof and several chimneys')run_button = gr.Button("Run")with gr.Accordion("Advanced options", open=False):preprocessor_name = gr.Radio(23 unmodified lines)with gr.Column():result = gr.Gallery(label="Output", show_label=False, columns=2, object_fit="scale-down")inputs = [image,prompt,10 unmodified lines111213141516171819202122232425262728293031323323 unmodified lines5758596061626364656667686970717273747510 unmodified lines)from utils import randomize_seed_fnexamples = [["images/seg/33.png","A man standing in front of a wall with several framed artworks hanging on it",],["images/seg/seg_demo.png","A large building with a pointed roof and several chimneys",],]def create_demo(process):with gr.Blocks() as demo:with gr.Row():with gr.Column():image = gr.Image()prompt = gr.Textbox(label="Prompt")run_button = gr.Button("Run")with gr.Accordion("Advanced options", open=False):preprocessor_name = gr.Radio(23 unmodified lines)with gr.Column():result = gr.Gallery(label="Output", show_label=False, columns=2, object_fit="scale-down")gr.Examples(examples=examples,inputs=[image,prompt,guidance_scale,seed,],outputs=result,fn=process,)inputs = [image,prompt,
10 unmodified lines1112131415161718192021222332 unmodified lines56575859606110 unmodified lines)from utils import randomize_seed_fndef create_demo(process):with gr.Blocks() as demo:with gr.Row():with gr.Column():image = gr.Image(value='images/hed_demo.jpeg')prompt = gr.Textbox(label="Prompt", value='Language trip to Laon')run_button = gr.Button("Run")with gr.Accordion("Advanced options", open=False):preprocessor_name = gr.Radio(32 unmodified lines)with gr.Column():result = gr.Gallery(label="Output", show_label=False, columns=2, object_fit="scale-down")inputs = [image,prompt,10 unmodified lines1112131415161718192021222324252627282932 unmodified lines6263646566676869707172737475767778798010 unmodified lines)from utils import randomize_seed_fnexamples = [["images/hed/hed_demo.jpeg","Language trip to Laon",],]def create_demo(process):with gr.Blocks() as demo:with gr.Row():with gr.Column():image = gr.Image()prompt = gr.Textbox(label="Prompt")run_button = gr.Button("Run")with gr.Accordion("Advanced options", open=False):preprocessor_name = gr.Radio(32 unmodified lines)with gr.Column():result = gr.Gallery(label="Output", show_label=False, columns=2, object_fit="scale-down")gr.Examples(examples=examples,inputs=[image,prompt,guidance_scale,seed,],outputs=result,fn=process,)inputs = [image,prompt,
584 unmodified lines58558658758858959059126 unmodified lines6186196206216226231 unmodified line625626627628629630584 unmodified linesraise ValueErrorif preprocessor_name in ["None", "None (anime)"]:image = HWC3(image)image = resize_image(image, resolution=image_resolution)control_image = PIL.Image.fromarray(image)elif preprocessor_name in ["Lineart", "Lineart coarse"]:26 unmodified linesguidance_scale=guidance_scale,seed=seed,)conditions_of_generated_imgs = [self.preprocessor(image=x,1 unmodified linedetect_resolution=preprocess_resolution,) for x in results]return [control_image] * num_images + results + conditions_of_generated_imgs@torch.inference_mode()584 unmodified lines58558658758858959059126 unmodified lines6186196206216226236241 unmodified line626627628629630631632633634635584 unmodified linesraise ValueErrorif preprocessor_name in ["None", "None (anime)"]:image = 255 - HWC3(image)image = resize_image(image, resolution=image_resolution)control_image = PIL.Image.fromarray(image)elif preprocessor_name in ["Lineart", "Lineart coarse"]:26 unmodified linesguidance_scale=guidance_scale,seed=seed,)self.preprocessor.load("Lineart")conditions_of_generated_imgs = [self.preprocessor(image=x,1 unmodified linedetect_resolution=preprocess_resolution,) for x in results]control_image = PIL.Image.fromarray((255 - np.array(control_image)).astype(np.uint8))conditions_of_generated_imgs = [PIL.Image.fromarray((255 - np.array(x)).astype(np.uint8)) for x in conditions_of_generated_imgs]return [control_image] * num_images + results + conditions_of_generated_imgs@torch.inference_mode()
app.py+2-24
app_canny.py+21-2
app_depth.py+22-2
app_lineart.py+40-4
app_segmentation.py+25-2
app_softedge.py+21-2
images/canny_demo.jpg β images/canny/canny_demo.jpgRenamed


images/depth_demo.png β images/depth/depth_demo.pngRenamed


images/hed_demo.jpeg β images/hed/hed_demo.jpegRenamed


images/lineart/Ryan Reynolds_1.pngAdded

images/lineart/Ryan Reynolds_2.pngAdded

images/lineart/Ryan Reynolds_3.pngAdded

images/lineart_demo.jpg β images/lineart/tube.jpgRenamed


images/seg/33.pngAdded

images/seg_demo.png β images/seg/seg_demo.pngRenamed


model.py+6-1