Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -124,6 +124,7 @@ def apply_style(style_name: str, positive: str, negative: str = "") -> tuple[str | |
| 124 | 
             
                p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
         | 
| 125 | 
             
                return p.replace("{prompt}", positive), n + negative
         | 
| 126 |  | 
|  | |
| 127 | 
             
            device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
         | 
| 128 |  | 
| 129 | 
             
            eulera_scheduler = EulerAncestralDiscreteScheduler.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", subfolder="scheduler")
         | 
| @@ -237,7 +238,7 @@ def run( | |
| 237 | 
             
                    pipe = pipe_cyber
         | 
| 238 | 
             
                else:  # "Stallion Dreams Pony Realistic v1"
         | 
| 239 | 
             
                    pipe = pipe_stallion
         | 
| 240 | 
            -
             | 
| 241 | 
             
                if use_canny:
         | 
| 242 | 
             
                    out = pipe(
         | 
| 243 | 
             
                        prompt=prompt,
         | 
| @@ -278,6 +279,7 @@ with gr.Blocks(css="style.css", js=js_func) as demo: | |
| 278 | 
             
                        with gr.Group():
         | 
| 279 | 
             
                            image = gr.ImageEditor(type="pil", label="Sketch your image or upload one", width=512, height=512)
         | 
| 280 | 
             
                            prompt = gr.Textbox(label="Prompt")
         | 
|  | |
| 281 | 
             
                            model_choice = gr.Dropdown(
         | 
| 282 | 
             
                                ["Pony Realism v21", "Cyber Realistic Pony v61", "Stallion Dreams Pony Realistic v1"],
         | 
| 283 | 
             
                                label="Model Choice",
         | 
| @@ -330,8 +332,8 @@ with gr.Blocks(css="style.css", js=js_func) as demo: | |
| 330 | 
             
                    image,
         | 
| 331 | 
             
                    prompt,
         | 
| 332 | 
             
                    negative_prompt,
         | 
| 333 | 
            -
                    model_choice,
         | 
| 334 | 
            -
                    style, | 
| 335 | 
             
                    num_steps,
         | 
| 336 | 
             
                    guidance_scale,
         | 
| 337 | 
             
                    controlnet_conditioning_scale,
         | 
| @@ -339,7 +341,6 @@ with gr.Blocks(css="style.css", js=js_func) as demo: | |
| 339 | 
             
                    use_hed,
         | 
| 340 | 
             
                    use_canny
         | 
| 341 | 
             
                ]
         | 
| 342 | 
            -
             | 
| 343 | 
             
                outputs = [image_slider]
         | 
| 344 | 
             
                run_button.click(
         | 
| 345 | 
             
                    fn=randomize_seed_fn,
         | 
|  | |
| 124 | 
             
                p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
         | 
| 125 | 
             
                return p.replace("{prompt}", positive), n + negative
         | 
| 126 |  | 
| 127 | 
            +
             | 
| 128 | 
             
            device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
         | 
| 129 |  | 
| 130 | 
             
            eulera_scheduler = EulerAncestralDiscreteScheduler.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", subfolder="scheduler")
         | 
|  | |
| 238 | 
             
                    pipe = pipe_cyber
         | 
| 239 | 
             
                else:  # "Stallion Dreams Pony Realistic v1"
         | 
| 240 | 
             
                    pipe = pipe_stallion
         | 
| 241 | 
            +
                
         | 
| 242 | 
             
                if use_canny:
         | 
| 243 | 
             
                    out = pipe(
         | 
| 244 | 
             
                        prompt=prompt,
         | 
|  | |
| 279 | 
             
                        with gr.Group():
         | 
| 280 | 
             
                            image = gr.ImageEditor(type="pil", label="Sketch your image or upload one", width=512, height=512)
         | 
| 281 | 
             
                            prompt = gr.Textbox(label="Prompt")
         | 
| 282 | 
            +
                            style = gr.Dropdown(label="Style", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
         | 
| 283 | 
             
                            model_choice = gr.Dropdown(
         | 
| 284 | 
             
                                ["Pony Realism v21", "Cyber Realistic Pony v61", "Stallion Dreams Pony Realistic v1"],
         | 
| 285 | 
             
                                label="Model Choice",
         | 
|  | |
| 332 | 
             
                    image,
         | 
| 333 | 
             
                    prompt,
         | 
| 334 | 
             
                    negative_prompt,
         | 
| 335 | 
            +
                    model_choice,  # Add this new input
         | 
| 336 | 
            +
                    style,
         | 
| 337 | 
             
                    num_steps,
         | 
| 338 | 
             
                    guidance_scale,
         | 
| 339 | 
             
                    controlnet_conditioning_scale,
         | 
|  | |
| 341 | 
             
                    use_hed,
         | 
| 342 | 
             
                    use_canny
         | 
| 343 | 
             
                ]
         | 
|  | |
| 344 | 
             
                outputs = [image_slider]
         | 
| 345 | 
             
                run_button.click(
         | 
| 346 | 
             
                    fn=randomize_seed_fn,
         | 
