ccchenzc commited on
Commit
446727a
·
verified ·
1 Parent(s): 31d28e5

Update examples.

Browse files
Files changed (1) hide show
  1. webui/tab_texture_synthesis.py +46 -46
webui/tab_texture_synthesis.py CHANGED
@@ -1,46 +1,46 @@
1
- import os
2
- from PIL import Image
3
- import gradio as gr
4
-
5
-
6
- def create_interface_texture_synthesis(runner):
7
- with gr.Blocks():
8
- with gr.Row():
9
- gr.Markdown('1. Upload the texture image as input.\n'
10
- '2. (Optional) Customize the configurations below as needed.\n'
11
- '3. Cilck `Run` to start synthesis.')
12
-
13
- with gr.Row():
14
- with gr.Column():
15
- with gr.Row():
16
- texture_image = gr.Image(label='Input Texture Image', type='pil', interactive=True,
17
- value=Image.open('examples/s1.jpg').convert('RGB') if os.path.exists('examples/s1.jpg') else None)
18
-
19
- run_button = gr.Button(value='Run')
20
-
21
- with gr.Accordion('Options', open=True):
22
- height = gr.Number(label='Height', value=512, precision=0, minimum=2, maximum=4096)
23
- width = gr.Number(label='Width', value=1024, precision=0, minimum=2, maximum=4096)
24
- seed = gr.Number(label='Seed', value=2025, precision=0, minimum=0, maximum=2**31)
25
- num_steps = gr.Slider(label='Number of Steps', minimum=1, maximum=1000, value=200, step=1)
26
- iterations = gr.Slider(label='Iterations', minimum=0, maximum=10, value=2, step=1)
27
- lr = gr.Slider(label='Learning Rate', minimum=0.01, maximum=0.5, value=0.05, step=0.01)
28
- mixed_precision = gr.Radio(choices=['bf16', 'no'], value='bf16', label='Mixed Precision')
29
- num_images_per_prompt = gr.Slider(label='Num Images Per Prompt', minimum=1, maximum=10, value=1, step=1)
30
-
31
- base_model_list = ['stable-diffusion-v1-5/stable-diffusion-v1-5',]
32
- model = gr.Radio(choices=base_model_list, label='Select a Base Model', value='stable-diffusion-v1-5/stable-diffusion-v1-5')
33
- synthesis_way = gr.Radio(['Sampling', 'MultiDiffusion'], label='Synthesis Way', value='MultiDiffusion')
34
-
35
- with gr.Column():
36
- gr.Markdown('#### Output Image:\n')
37
- result_gallery = gr.Gallery(label='Output', elem_id='gallery', columns=2, height='auto', preview=True)
38
-
39
- gr.Examples(
40
- [[Image.open('./webui/images/42.jpg').convert('RGB'), 'MultiDiffusion', 512, 1024]],
41
- [texture_image, synthesis_way, height, width]
42
- )
43
- ips = [texture_image, height, width, seed, num_steps, iterations, lr, mixed_precision, num_images_per_prompt, synthesis_way,model]
44
-
45
- run_button.click(fn=runner.run_texture_synthesis, inputs=ips, outputs=[result_gallery])
46
-
 
1
+ import os
2
+ from PIL import Image
3
+ import gradio as gr
4
+
5
+
6
+ def create_interface_texture_synthesis(runner):
7
+ with gr.Blocks():
8
+ with gr.Row():
9
+ gr.Markdown('1. Upload the texture image as input.\n'
10
+ '2. (Optional) Customize the configurations below as needed.\n'
11
+ '3. Cilck `Run` to start synthesis.')
12
+
13
+ with gr.Row():
14
+ with gr.Column():
15
+ with gr.Row():
16
+ texture_image = gr.Image(label='Input Texture Image', type='pil', interactive=True,
17
+ value=Image.open('examples/s1.jpg').convert('RGB') if os.path.exists('examples/s1.jpg') else None)
18
+
19
+ run_button = gr.Button(value='Run')
20
+
21
+ with gr.Accordion('Options', open=True):
22
+ height = gr.Number(label='Height', value=512, precision=0, minimum=2, maximum=4096)
23
+ width = gr.Number(label='Width', value=1024, precision=0, minimum=2, maximum=4096)
24
+ seed = gr.Number(label='Seed', value=2025, precision=0, minimum=0, maximum=2**31)
25
+ num_steps = gr.Slider(label='Number of Steps', minimum=1, maximum=1000, value=200, step=1)
26
+ iterations = gr.Slider(label='Iterations', minimum=0, maximum=10, value=2, step=1)
27
+ lr = gr.Slider(label='Learning Rate', minimum=0.01, maximum=0.5, value=0.05, step=0.01)
28
+ mixed_precision = gr.Radio(choices=['bf16', 'no'], value='bf16', label='Mixed Precision')
29
+ num_images_per_prompt = gr.Slider(label='Num Images Per Prompt', minimum=1, maximum=10, value=1, step=1)
30
+
31
+ base_model_list = ['stable-diffusion-v1-5/stable-diffusion-v1-5',]
32
+ model = gr.Radio(choices=base_model_list, label='Select a Base Model', value='stable-diffusion-v1-5/stable-diffusion-v1-5')
33
+ synthesis_way = gr.Radio(['Sampling', 'MultiDiffusion'], label='Synthesis Way', value='MultiDiffusion')
34
+
35
+ with gr.Column():
36
+ gr.Markdown('#### Output Image:\n')
37
+ result_gallery = gr.Gallery(label='Output', elem_id='gallery', columns=2, height='auto', preview=True)
38
+
39
+ gr.Examples(
40
+ [[Image.open('./webui/images/42.jpg').convert('RGB'), 'Sampling', 512, 1024, 50]],
41
+ [texture_image, synthesis_way, height, width, num_steps]
42
+ )
43
+ ips = [texture_image, height, width, seed, num_steps, iterations, lr, mixed_precision, num_images_per_prompt, synthesis_way,model]
44
+
45
+ run_button.click(fn=runner.run_texture_synthesis, inputs=ips, outputs=[result_gallery])
46
+