Rooni commited on
Commit
c25d024
1 Parent(s): 6fd936a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -11,7 +11,7 @@ API_URL = "https://api-inference.huggingface.co/models/openskyml/dalle-3-xl"
11
  API_TOKEN = os.getenv("HF_READ_TOKEN") # it is free
12
  headers = {"Authorization": f"Bearer {API_TOKEN}"}
13
 
14
- def query(prompt, model, is_negative=False, steps=20, cfg_scale=7, seed=-1):
15
  language = detect(prompt)
16
 
17
  if language == 'ru':
@@ -26,7 +26,7 @@ def query(prompt, model, is_negative=False, steps=20, cfg_scale=7, seed=-1):
26
  "is_negative": is_negative,
27
  "steps": steps,
28
  "cfg_scale": cfg_scale,
29
- "seed": seed
30
  }
31
 
32
  image_bytes = requests.post(API_URL, headers=headers, json=payload).content
@@ -48,15 +48,12 @@ with gr.Blocks(css=css) as dalle:
48
 
49
  with gr.Tab("Расширенные настройки"):
50
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Чего не должно быть на изображении", value="text, blurry, fuzziness", lines=1, elem_id="negative-prompt-text-input")
51
- steps = gr.Slider(label="Sampling Steps", value=20, minimum=1, maximum=30, step=1)
52
- cfg = gr.Slider(label="CFG Scale", value=7, minimum=1, maximum=20, step=1)
53
- seed = gr.Slider(label="Сид", value=-1, minimum=-1, maximum=2147483647, step=1)
54
 
55
  with gr.Row():
56
  text_button = gr.Button("Генерация", variant='primary', elem_id="gen-button")
57
  with gr.Row():
58
  image_output = gr.Image(type="pil", label="Изображение", elem_id="gallery")
59
 
60
- text_button.click(query, inputs=[text_prompt, model, negative_prompt, steps, cfg, seed], outputs=image_output)
61
 
62
  dalle.launch(show_api=False)
 
11
  API_TOKEN = os.getenv("HF_READ_TOKEN") # it is free
12
  headers = {"Authorization": f"Bearer {API_TOKEN}"}
13
 
14
+ def query(prompt, model, is_negative=False, steps=20, cfg_scale=7, seed=None):
15
  language = detect(prompt)
16
 
17
  if language == 'ru':
 
26
  "is_negative": is_negative,
27
  "steps": steps,
28
  "cfg_scale": cfg_scale,
29
+ "seed": seed if seed is not None else random.randint(-1, 2147483647)
30
  }
31
 
32
  image_bytes = requests.post(API_URL, headers=headers, json=payload).content
 
48
 
49
  with gr.Tab("Расширенные настройки"):
50
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Чего не должно быть на изображении", value="text, blurry, fuzziness", lines=1, elem_id="negative-prompt-text-input")
 
 
 
51
 
52
  with gr.Row():
53
  text_button = gr.Button("Генерация", variant='primary', elem_id="gen-button")
54
  with gr.Row():
55
  image_output = gr.Image(type="pil", label="Изображение", elem_id="gallery")
56
 
57
+ text_button.click(query, inputs=[text_prompt, model, negative_prompt], outputs=image_output)
58
 
59
  dalle.launch(show_api=False)