Rooni commited on
Commit
eb75e63
1 Parent(s): 5699de1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -2,20 +2,20 @@ import gradio as gr
2
  import requests
3
  import random
4
 
5
- def generate_image(prompt, model, width, height, seed):
6
  if seed == -1:
7
  seed = random.randint(0, 999999)
8
  url = f"https://image.pollinations.ai/prompt/{prompt}?width={width}&height={height}&seed={seed}&nologo=true&nofeed=true"
9
- if model:
10
- url += f"&model={model}"
11
  response = requests.get(url)
12
- return response.content
 
 
 
13
 
14
- # Основные настройки
15
  with gr.Blocks() as demo:
16
  with gr.Tab("Основные настройки"):
17
  prompt_input = gr.Textbox(label="Промпт", placeholder="Введите промпт на английском языке")
18
- model_dropdown = gr.Dropdown(label="Выбор модели", choices=["Flux", "Flux-Pro", "Flux-Realism", "Private", "Flux-Anime", "Flux-3D", "Flux-CablyAl", "Turbo"], value="Flux")
19
 
20
  with gr.Tab("Дополнительные настройки"):
21
  width_slider = gr.Slider(label="Ширина", minimum=1, maximum=4000, value=1024)
@@ -23,8 +23,8 @@ with gr.Blocks() as demo:
23
  seed_slider = gr.Slider(label="Сид", minimum=-1, maximum=999999, value=-1, step=1)
24
 
25
  create_button = gr.Button("Создать")
26
- output_image = gr.Image(label="Изображение")
27
 
28
- create_button.click(fn=generate_image, inputs=[prompt_input, model_dropdown, width_slider, height_slider, seed_slider], outputs=output_image)
29
 
30
- demo.launch()
 
2
  import requests
3
  import random
4
 
5
+ def generate_image(prompt, width, height, seed):
6
  if seed == -1:
7
  seed = random.randint(0, 999999)
8
  url = f"https://image.pollinations.ai/prompt/{prompt}?width={width}&height={height}&seed={seed}&nologo=true&nofeed=true"
 
 
9
  response = requests.get(url)
10
+ if response.status_code == 200:
11
+ return response.content
12
+ else:
13
+ return None
14
 
15
+ # Создаем интерфейс Gradio
16
  with gr.Blocks() as demo:
17
  with gr.Tab("Основные настройки"):
18
  prompt_input = gr.Textbox(label="Промпт", placeholder="Введите промпт на английском языке")
 
19
 
20
  with gr.Tab("Дополнительные настройки"):
21
  width_slider = gr.Slider(label="Ширина", minimum=1, maximum=4000, value=1024)
 
23
  seed_slider = gr.Slider(label="Сид", minimum=-1, maximum=999999, value=-1, step=1)
24
 
25
  create_button = gr.Button("Создать")
26
+ output_image = gr.Image(label="Изображение", type="pil") # Указываем тип вывода как PIL изображение
27
 
28
+ create_button.click(fn=generate_image, inputs=[prompt_input, width_slider, height_slider, seed_slider], outputs=output_image)
29
 
30
+ demo.launch()