Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Upload app.py with huggingface_hub
Browse files
    	
        app.py
    CHANGED
    
    | @@ -8,64 +8,55 @@ import torch | |
| 8 | 
             
            from my_run import run as run_model
         | 
| 9 |  | 
| 10 |  | 
| 11 | 
            -
            DESCRIPTION =  | 
| 12 | 
            -
             | 
|  | |
| 13 |  | 
| 14 | 
             
            @spaces.GPU
         | 
| 15 | 
             
            def main_pipeline(
         | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 |  | 
| 27 | 
            -
             | 
| 28 |  | 
| 29 |  | 
| 30 | 
            -
            with gr.Blocks(css= | 
| 31 | 
             
                gr.Markdown(DESCRIPTION)
         | 
| 32 |  | 
| 33 | 
             
                gr.HTML(
         | 
| 34 | 
            -
                     | 
| 35 | 
            -
                    <img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate the Space to run privately without waiting in queue | 
|  | |
| 36 |  | 
| 37 | 
             
                with gr.Row():
         | 
| 38 | 
             
                    with gr.Column():
         | 
| 39 | 
             
                        input_image = gr.Image(
         | 
| 40 | 
            -
                            label="Input image",
         | 
| 41 | 
            -
                            type="filepath",
         | 
| 42 | 
            -
                            height=512,
         | 
| 43 | 
            -
                            width=512
         | 
| 44 | 
             
                        )
         | 
| 45 | 
             
                        src_prompt = gr.Text(
         | 
| 46 | 
            -
                            label= | 
| 47 | 
             
                            max_lines=1,
         | 
| 48 | 
            -
                            placeholder= | 
| 49 | 
             
                        )
         | 
| 50 | 
             
                        tgt_prompt = gr.Text(
         | 
| 51 | 
            -
                            label= | 
| 52 | 
             
                            max_lines=1,
         | 
| 53 | 
            -
                            placeholder= | 
| 54 | 
             
                        )
         | 
| 55 | 
             
                        with gr.Accordion("Advanced Options", open=False):
         | 
| 56 | 
             
                            seed = gr.Slider(
         | 
| 57 | 
            -
                                label= | 
| 58 | 
            -
                                minimum=0,
         | 
| 59 | 
            -
                                maximum=16*1024,
         | 
| 60 | 
            -
                                value=7865,
         | 
| 61 | 
            -
                                step=1
         | 
| 62 | 
             
                            )
         | 
| 63 | 
             
                            w1 = gr.Slider(
         | 
| 64 | 
            -
                                label= | 
| 65 | 
            -
                                minimum=1.0,
         | 
| 66 | 
            -
                                maximum=3.0,
         | 
| 67 | 
            -
                                value=1.5,
         | 
| 68 | 
            -
                                step=0.05
         | 
| 69 | 
             
                            )
         | 
| 70 | 
             
                            # w2 = gr.Slider(
         | 
| 71 | 
             
                            #     label='w2',
         | 
| @@ -75,50 +66,44 @@ with gr.Blocks(css='app/style.css') as demo: | |
| 75 | 
             
                            #     step=0.05
         | 
| 76 | 
             
                            # )
         | 
| 77 |  | 
| 78 | 
            -
                        run_button = gr.Button( | 
| 79 | 
             
                    with gr.Column():
         | 
| 80 | 
             
                        # result = gr.Gallery(label='Result')
         | 
| 81 | 
            -
                        result = gr.Image(
         | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
                         | 
| 87 | 
            -
             | 
| 88 | 
            -
                         | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
                         | 
| 106 | 
            -
             | 
| 107 | 
            -
                         | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
                                    outputs=[
         | 
| 117 | 
            -
                                        result
         | 
| 118 | 
            -
                                    ],
         | 
| 119 | 
            -
                                    fn=main_pipeline,
         | 
| 120 | 
            -
                                    cache_examples=True)
         | 
| 121 | 
            -
             | 
| 122 |  | 
| 123 | 
             
                inputs = [
         | 
| 124 | 
             
                    input_image,
         | 
| @@ -128,9 +113,7 @@ with gr.Blocks(css='app/style.css') as demo: | |
| 128 | 
             
                    w1,
         | 
| 129 | 
             
                    # w2,
         | 
| 130 | 
             
                ]
         | 
| 131 | 
            -
                outputs = [
         | 
| 132 | 
            -
                    result
         | 
| 133 | 
            -
                ]
         | 
| 134 | 
             
                run_button.click(fn=main_pipeline, inputs=inputs, outputs=outputs)
         | 
| 135 |  | 
| 136 | 
            -
            demo.queue(max_size=50).launch(share=True, max_threads=100)
         | 
|  | |
| 8 | 
             
            from my_run import run as run_model
         | 
| 9 |  | 
| 10 |  | 
| 11 | 
            +
            DESCRIPTION = """# Turbo Edit
         | 
| 12 | 
            +
            """
         | 
| 13 | 
            +
             | 
| 14 |  | 
| 15 | 
             
            @spaces.GPU
         | 
| 16 | 
             
            def main_pipeline(
         | 
| 17 | 
            +
                input_image: str,
         | 
| 18 | 
            +
                src_prompt: str,
         | 
| 19 | 
            +
                tgt_prompt: str,
         | 
| 20 | 
            +
                seed: int,
         | 
| 21 | 
            +
                w1: float,
         | 
| 22 | 
            +
                # w2: float,
         | 
| 23 | 
            +
            ):
         | 
| 24 |  | 
| 25 | 
            +
                w2 = 1.0
         | 
| 26 | 
            +
                res_image = run_model(input_image, src_prompt, tgt_prompt, seed, w1, w2)
         | 
| 27 |  | 
| 28 | 
            +
                return res_image
         | 
| 29 |  | 
| 30 |  | 
| 31 | 
            +
            with gr.Blocks(css="app/style.css") as demo:
         | 
| 32 | 
             
                gr.Markdown(DESCRIPTION)
         | 
| 33 |  | 
| 34 | 
             
                gr.HTML(
         | 
| 35 | 
            +
                    """<a href="https://huggingface.co/spaces/turboedit/turbo_edit?duplicate=true">
         | 
| 36 | 
            +
                    <img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate the Space to run privately without waiting in queue"""
         | 
| 37 | 
            +
                )
         | 
| 38 |  | 
| 39 | 
             
                with gr.Row():
         | 
| 40 | 
             
                    with gr.Column():
         | 
| 41 | 
             
                        input_image = gr.Image(
         | 
| 42 | 
            +
                            label="Input image", type="filepath", height=512, width=512
         | 
|  | |
|  | |
|  | |
| 43 | 
             
                        )
         | 
| 44 | 
             
                        src_prompt = gr.Text(
         | 
| 45 | 
            +
                            label="Source Prompt",
         | 
| 46 | 
             
                            max_lines=1,
         | 
| 47 | 
            +
                            placeholder="Source Prompt",
         | 
| 48 | 
             
                        )
         | 
| 49 | 
             
                        tgt_prompt = gr.Text(
         | 
| 50 | 
            +
                            label="Target Prompt",
         | 
| 51 | 
             
                            max_lines=1,
         | 
| 52 | 
            +
                            placeholder="Target Prompt",
         | 
| 53 | 
             
                        )
         | 
| 54 | 
             
                        with gr.Accordion("Advanced Options", open=False):
         | 
| 55 | 
             
                            seed = gr.Slider(
         | 
| 56 | 
            +
                                label="seed", minimum=0, maximum=16 * 1024, value=7865, step=1
         | 
|  | |
|  | |
|  | |
|  | |
| 57 | 
             
                            )
         | 
| 58 | 
             
                            w1 = gr.Slider(
         | 
| 59 | 
            +
                                label="w", minimum=1.0, maximum=3.0, value=1.5, step=0.05
         | 
|  | |
|  | |
|  | |
|  | |
| 60 | 
             
                            )
         | 
| 61 | 
             
                            # w2 = gr.Slider(
         | 
| 62 | 
             
                            #     label='w2',
         | 
|  | |
| 66 | 
             
                            #     step=0.05
         | 
| 67 | 
             
                            # )
         | 
| 68 |  | 
| 69 | 
            +
                        run_button = gr.Button("Edit")
         | 
| 70 | 
             
                    with gr.Column():
         | 
| 71 | 
             
                        # result = gr.Gallery(label='Result')
         | 
| 72 | 
            +
                        result = gr.Image(label="Result", type="pil", height=512, width=512)
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                        # examples = [
         | 
| 75 | 
            +
                        #     [
         | 
| 76 | 
            +
                        #         "demo_im/WhatsApp Image 2024-05-17 at 17.32.53.jpeg", #input_image
         | 
| 77 | 
            +
                        #         "a painting of a white cat sleeping on a lotus flower", #src_prompt
         | 
| 78 | 
            +
                        #         "a painting of a white cat sleeping on a lotus flower", #tgt_prompt
         | 
| 79 | 
            +
                        #         4759, #seed
         | 
| 80 | 
            +
                        #         1.0, #w1
         | 
| 81 | 
            +
                        #         # 1.1, #w2
         | 
| 82 | 
            +
                        #     ],
         | 
| 83 | 
            +
                        #     [
         | 
| 84 | 
            +
                        #         "demo_im/pexels-pixabay-458976.less.png", #input_image
         | 
| 85 | 
            +
                        #         "a squirrel standing in the grass", #src_prompt
         | 
| 86 | 
            +
                        #         "a squirrel standing in the grass", #tgt_prompt
         | 
| 87 | 
            +
                        #         6128, #seed
         | 
| 88 | 
            +
                        #         1.25, #w1
         | 
| 89 | 
            +
                        #         # 1.1, #w2
         | 
| 90 | 
            +
                        #     ],
         | 
| 91 | 
            +
                        # ]
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                        # gr.Examples(examples=examples,
         | 
| 94 | 
            +
                        #             inputs=[
         | 
| 95 | 
            +
                        #                 input_image,
         | 
| 96 | 
            +
                        #                 src_prompt,
         | 
| 97 | 
            +
                        #                 tgt_prompt,
         | 
| 98 | 
            +
                        #                 seed,
         | 
| 99 | 
            +
                        #                 w1,
         | 
| 100 | 
            +
                        #                 # w2,
         | 
| 101 | 
            +
                        #             ],
         | 
| 102 | 
            +
                        #             outputs=[
         | 
| 103 | 
            +
                        #                 result
         | 
| 104 | 
            +
                        #             ],
         | 
| 105 | 
            +
                        #             fn=main_pipeline,
         | 
| 106 | 
            +
                        #             cache_examples=True)
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 107 |  | 
| 108 | 
             
                inputs = [
         | 
| 109 | 
             
                    input_image,
         | 
|  | |
| 113 | 
             
                    w1,
         | 
| 114 | 
             
                    # w2,
         | 
| 115 | 
             
                ]
         | 
| 116 | 
            +
                outputs = [result]
         | 
|  | |
|  | |
| 117 | 
             
                run_button.click(fn=main_pipeline, inputs=inputs, outputs=outputs)
         | 
| 118 |  | 
| 119 | 
            +
            demo.queue(max_size=50).launch(share=True, max_threads=100)
         |