zenafey commited on
Commit
355874e
1 Parent(s): 616e3a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  from prodiapy import Prodia
3
  import gradio as gr
4
  from style_template import styles
@@ -7,9 +8,10 @@ import base64
7
  prodia = Prodia()
8
  STYLE_NAMES = list(styles.keys())
9
  DEFAULT_STYLE_NAME = "Photographic (Default)"
 
10
 
11
 
12
- def generate_image(upload_images, prompt, negative_prompt, style_name, steps, progress=gr.Progress(track_tqdm=True)):
13
  error_if_no_img(prompt)
14
  p, n = apply_style(style_name, prompt, negative_prompt)
15
 
@@ -17,7 +19,9 @@ def generate_image(upload_images, prompt, negative_prompt, style_name, steps, pr
17
  imageData=[file_to_base64(img) for img in upload_images],
18
  prompt=p,
19
  negative_prompt=n,
20
- steps=steps
 
 
21
  )
22
  result = prodia.wait(job)
23
 
@@ -117,6 +121,20 @@ with gr.Blocks(css=css) as demo:
117
  step=1,
118
  value=40,
119
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  with gr.Column():
121
  result_image = gr.Image(label="Generated Image")
122
 
@@ -125,7 +143,7 @@ with gr.Blocks(css=css) as demo:
125
 
126
  submit.click(
127
  fn=generate_image,
128
- inputs=[files, prompt, negative_prompt, style, steps],
129
  outputs=[result_image]
130
  )
131
 
 
1
  import os
2
+ import numpy as np
3
  from prodiapy import Prodia
4
  import gradio as gr
5
  from style_template import styles
 
8
  prodia = Prodia()
9
  STYLE_NAMES = list(styles.keys())
10
  DEFAULT_STYLE_NAME = "Photographic (Default)"
11
+ MAX_SEED = np.iinfo(np.int32).max
12
 
13
 
14
+ def generate_image(upload_images, prompt, negative_prompt, style_name, steps, strength, seed, progress=gr.Progress(track_tqdm=True)):
15
  error_if_no_img(prompt)
16
  p, n = apply_style(style_name, prompt, negative_prompt)
17
 
 
19
  imageData=[file_to_base64(img) for img in upload_images],
20
  prompt=p,
21
  negative_prompt=n,
22
+ steps=steps,
23
+ strength=strength,
24
+ seed=seed
25
  )
26
  result = prodia.wait(job)
27
 
 
121
  step=1,
122
  value=40,
123
  )
124
+ strength_ratio = gr.Slider(
125
+ label="Strength (%)",
126
+ minimum=15,
127
+ maximum=50,
128
+ step=1,
129
+ value=20,
130
+ )
131
+ seed = gr.Slider(
132
+ label="Seed",
133
+ minimum=0,
134
+ maximum=MAX_SEED,
135
+ step=1,
136
+ value=0,
137
+ )
138
  with gr.Column():
139
  result_image = gr.Image(label="Generated Image")
140
 
 
143
 
144
  submit.click(
145
  fn=generate_image,
146
+ inputs=[files, prompt, negative_prompt, style, steps, strength_ratio, seed],
147
  outputs=[result_image]
148
  )
149