matteomarjanovic commited on
Commit
36abcb2
·
1 Parent(s): 7c203d2

add input image column

Browse files
Files changed (1) hide show
  1. app.py +79 -75
app.py CHANGED
@@ -46,7 +46,7 @@ def infer(
46
  negative_prompt=negative_prompt,
47
  guidance_scale=0.,
48
  num_inference_steps=4,
49
- width=1920,
50
  height=1080,
51
  max_sequence_length=256,
52
  ).images[0]
@@ -68,90 +68,94 @@ css = """
68
  """
69
 
70
  with gr.Blocks(css=css) as demo:
71
- with gr.Column(elem_id="col-container"):
72
- gr.Markdown(" # Text-to-Image Gradio Template")
73
-
74
- with gr.Row():
75
- prompt = gr.Text(
76
- label="Prompt",
77
- show_label=False,
78
- max_lines=1,
79
- placeholder="Enter your prompt",
80
- container=False,
81
- )
82
-
83
- run_button = gr.Button("Run", scale=0, variant="primary")
84
-
85
- result = gr.Image(label="Result", show_label=False)
86
-
87
- with gr.Accordion("Advanced Settings", open=False):
88
- negative_prompt = gr.Text(
89
- label="Negative prompt",
90
- max_lines=1,
91
- placeholder="Enter a negative prompt",
92
- visible=False,
93
- )
94
-
95
- seed = gr.Slider(
96
- label="Seed",
97
- minimum=0,
98
- maximum=MAX_SEED,
99
- step=1,
100
- value=0,
101
- )
102
-
103
- randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
104
 
105
  with gr.Row():
106
- width = gr.Slider(
107
- label="Width",
108
- minimum=256,
109
- maximum=MAX_IMAGE_SIZE,
110
- step=32,
111
- value=1024, # Replace with defaults that work for your model
112
  )
113
 
114
- height = gr.Slider(
115
- label="Height",
116
- minimum=256,
117
- maximum=MAX_IMAGE_SIZE,
118
- step=32,
119
- value=1024, # Replace with defaults that work for your model
120
- )
121
 
122
- with gr.Row():
123
- guidance_scale = gr.Slider(
124
- label="Guidance scale",
125
- minimum=0.0,
126
- maximum=10.0,
127
- step=0.1,
128
- value=0.0, # Replace with defaults that work for your model
 
129
  )
130
 
131
- num_inference_steps = gr.Slider(
132
- label="Number of inference steps",
133
- minimum=1,
134
- maximum=50,
135
  step=1,
136
- value=2, # Replace with defaults that work for your model
137
  )
138
 
139
- gr.Examples(examples=examples, inputs=[prompt])
140
- gr.on(
141
- triggers=[run_button.click, prompt.submit],
142
- fn=infer,
143
- inputs=[
144
- prompt,
145
- negative_prompt,
146
- seed,
147
- randomize_seed,
148
- width,
149
- height,
150
- guidance_scale,
151
- num_inference_steps,
152
- ],
153
- outputs=[result, seed],
154
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
 
156
  if __name__ == "__main__":
157
  demo.launch()
 
46
  negative_prompt=negative_prompt,
47
  guidance_scale=0.,
48
  num_inference_steps=4,
49
+ width=1420,
50
  height=1080,
51
  max_sequence_length=256,
52
  ).images[0]
 
68
  """
69
 
70
  with gr.Blocks(css=css) as demo:
71
+ with gr.Row():
72
+ with gr.Column(elem_id="col-input-image"):
73
+ gr.Markdown(" # Drop your image here")
74
+ gr.Image()
75
+ with gr.Column(elem_id="col-container"):
76
+ gr.Markdown(" # Text-to-Image Gradio Template")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  with gr.Row():
79
+ prompt = gr.Text(
80
+ label="Prompt",
81
+ show_label=False,
82
+ max_lines=1,
83
+ placeholder="Enter your prompt",
84
+ container=False,
85
  )
86
 
87
+ run_button = gr.Button("Run", scale=0, variant="primary")
 
 
 
 
 
 
88
 
89
+ result = gr.Image(label="Result", show_label=False)
90
+
91
+ with gr.Accordion("Advanced Settings", open=False):
92
+ negative_prompt = gr.Text(
93
+ label="Negative prompt",
94
+ max_lines=1,
95
+ placeholder="Enter a negative prompt",
96
+ visible=False,
97
  )
98
 
99
+ seed = gr.Slider(
100
+ label="Seed",
101
+ minimum=0,
102
+ maximum=MAX_SEED,
103
  step=1,
104
+ value=0,
105
  )
106
 
107
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
108
+
109
+ with gr.Row():
110
+ width = gr.Slider(
111
+ label="Width",
112
+ minimum=256,
113
+ maximum=MAX_IMAGE_SIZE,
114
+ step=32,
115
+ value=1024, # Replace with defaults that work for your model
116
+ )
117
+
118
+ height = gr.Slider(
119
+ label="Height",
120
+ minimum=256,
121
+ maximum=MAX_IMAGE_SIZE,
122
+ step=32,
123
+ value=1024, # Replace with defaults that work for your model
124
+ )
125
+
126
+ with gr.Row():
127
+ guidance_scale = gr.Slider(
128
+ label="Guidance scale",
129
+ minimum=0.0,
130
+ maximum=10.0,
131
+ step=0.1,
132
+ value=0.0, # Replace with defaults that work for your model
133
+ )
134
+
135
+ num_inference_steps = gr.Slider(
136
+ label="Number of inference steps",
137
+ minimum=1,
138
+ maximum=50,
139
+ step=1,
140
+ value=2, # Replace with defaults that work for your model
141
+ )
142
+
143
+ gr.Examples(examples=examples, inputs=[prompt])
144
+ gr.on(
145
+ triggers=[run_button.click, prompt.submit],
146
+ fn=infer,
147
+ inputs=[
148
+ prompt,
149
+ negative_prompt,
150
+ seed,
151
+ randomize_seed,
152
+ width,
153
+ height,
154
+ guidance_scale,
155
+ num_inference_steps,
156
+ ],
157
+ outputs=[result, seed],
158
+ )
159
 
160
  if __name__ == "__main__":
161
  demo.launch()