okaris commited on
Commit
224d97a
1 Parent(s): 515c311

Gradio Space

Browse files
Files changed (1) hide show
  1. space.py +117 -0
space.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from omni_zero import OmniZeroSingle
3
+
4
+ def generate(
5
+ seed=42,
6
+ prompt="A person",
7
+ negative_prompt="blurry, out of focus",
8
+ guidance_scale=3.0,
9
+ number_of_images=1,
10
+ number_of_steps=10,
11
+ base_image="https://github.com/okaris/omni-zero/assets/1448702/2ca63443-c7f3-4ba6-95c1-2a341414865f",
12
+ base_image_strength=0.15,
13
+ composition_image="https://github.com/okaris/omni-zero/assets/1448702/2ca63443-c7f3-4ba6-95c1-2a341414865f",
14
+ composition_image_strength=1.0,
15
+ style_image="https://github.com/okaris/omni-zero/assets/1448702/64dc150b-f683-41b1-be23-b6a52c771584",
16
+ style_image_strength=1.0,
17
+ identity_image="https://github.com/okaris/omni-zero/assets/1448702/ba193a3a-f90e-4461-848a-560454531c58",
18
+ identity_image_strength=1.0,
19
+ depth_image=None,
20
+ depth_image_strength=0.5,
21
+ ):
22
+
23
+ omni_zero = OmniZeroSingle(
24
+ base_model="frankjoshua/albedobaseXL_v13",
25
+ )
26
+
27
+ images = omni_zero.generate(
28
+ seed=seed,
29
+ prompt=prompt,
30
+ negative_prompt=negative_prompt,
31
+ guidance_scale=guidance_scale,
32
+ number_of_images=number_of_images,
33
+ number_of_steps=number_of_steps,
34
+ base_image=base_image,
35
+ base_image_strength=base_image_strength,
36
+ composition_image=composition_image,
37
+ composition_image_strength=composition_image_strength,
38
+ style_image=style_image,
39
+ style_image_strength=style_image_strength,
40
+ identity_image=identity_image,
41
+ identity_image_strength=identity_image_strength,
42
+ depth_image=depth_image,
43
+ depth_image_strength=depth_image_strength,
44
+ )
45
+
46
+ # for i, image in enumerate(images):
47
+ # image.save(f"oz_output_{i}.jpg")
48
+ return images
49
+
50
+ with gr.Blocks() as demo:
51
+ with gr.Row():
52
+ with gr.Column():
53
+ with gr.Row():
54
+ prompt = gr.Textbox(label="Prompt", value="A person")
55
+ with gr.Row():
56
+ negative_prompt = gr.Textbox(label="Negative Prompt", value="blurry, out of focus")
57
+ with gr.Row():
58
+ seed = gr.Slider(label="Seed",step=1, minimum=0, maximum=10000000, value=42)
59
+ number_of_images = gr.Slider(label="Number of Outputs",step=1, minimum=1, maximum=4, value=1)
60
+ with gr.Row():
61
+ guidance_scale = gr.Slider(label="Guidance Scale",step=0.1, minimum=0.0, maximum=14.0, value=3.0)
62
+ number_of_steps = gr.Slider(label="Number of Steps",step=1, minimum=1, maximum=50, value=10)
63
+ with gr.Row():
64
+ with gr.Column():
65
+ with gr.Row():
66
+ base_image = gr.Image(label="Base Image", value="https://github.com/okaris/omni-zero/assets/1448702/2ca63443-c7f3-4ba6-95c1-2a341414865f")
67
+ with gr.Row():
68
+ base_image_strength = gr.Slider(label="Base Image Strength",step=0.01, minimum=0.0, maximum=1.0, value=0.15)
69
+ with gr.Column():
70
+ with gr.Row():
71
+ composition_image = gr.Image(label="Composition", value="https://github.com/okaris/omni-zero/assets/1448702/2ca63443-c7f3-4ba6-95c1-2a341414865f")
72
+ with gr.Row():
73
+ composition_image_strength = gr.Slider(label="Composition Image Strength",step=0.01, minimum=0.0, maximum=1.0, value=1.0)
74
+ # with gr.Row():
75
+ with gr.Column():
76
+ with gr.Row():
77
+ style_image = gr.Image(label="Style Image", value="https://github.com/okaris/omni-zero/assets/1448702/64dc150b-f683-41b1-be23-b6a52c771584")
78
+ with gr.Row():
79
+ style_image_strength = gr.Slider(label="Style Image Strength",step=0.01, minimum=0.0, maximum=1.0, value=1.0)
80
+ with gr.Column():
81
+ with gr.Row():
82
+ identity_image = gr.Image(label="Identity Image", value="https://github.com/okaris/omni-zero/assets/1448702/ba193a3a-f90e-4461-848a-560454531c58")
83
+ with gr.Row():
84
+ identity_image_strength = gr.Slider(label="Identitiy Image Strenght",step=0.01, minimum=0.0, maximum=1.0, value=1.0)
85
+ # with gr.Column():
86
+ # with gr.Row():
87
+ # depth_image = gr.Image(label="depth_image", value=None)
88
+ # with gr.Row():
89
+ # depth_image_strength = gr.Slider(label="depth_image_strength",step=0.01, minimum=0.0, maximum=1.0, value=0.5)
90
+ with gr.Column():
91
+ with gr.Row():
92
+ out = gr.Image(label="Output(s)", value=None)
93
+ with gr.Row():
94
+ # clear = gr.Button("Clear")
95
+ submit = gr.Button("Generate")
96
+
97
+ submit.click(generate, inputs=[
98
+ seed,
99
+ prompt,
100
+ negative_prompt,
101
+ guidance_scale,
102
+ number_of_images,
103
+ number_of_steps,
104
+ base_image,
105
+ base_image_strength,
106
+ composition_image,
107
+ composition_image_strength,
108
+ style_image,
109
+ style_image_strength,
110
+ identity_image,
111
+ identity_image_strength,
112
+ ],
113
+ outputs=[out]
114
+ )
115
+ # clear.click(lambda: None, None, chatbot, queue=False)
116
+
117
+ demo.launch()