Update app.py
Browse files
app.py
CHANGED
|
@@ -2,17 +2,19 @@ import gradio as gr
|
|
| 2 |
from PIL import Image
|
| 3 |
import os
|
| 4 |
import random
|
|
|
|
| 5 |
|
| 6 |
def generate_image(text, input_image):
|
| 7 |
return input_image
|
| 8 |
|
| 9 |
description = """
|
| 10 |
-
|
| 11 |
"""
|
| 12 |
|
| 13 |
article = """
|
| 14 |
"""
|
| 15 |
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Gradio
|
| 18 |
with gr.Blocks(theme=gr.themes.Default(primary_hue=gr.themes.colors.orange, secondary_hue=gr.themes.colors.orange)) as demo:
|
|
@@ -25,29 +27,41 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue=gr.themes.colors.orange, seco
|
|
| 25 |
image_input_1 = gr.Image(label="Картинка", type="filepath")
|
| 26 |
|
| 27 |
# text prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
prompt_input = gr.Textbox(
|
| 29 |
label="Введите что-то", placeholder="Напишите сюда что-нибудь"
|
| 30 |
)
|
|
|
|
|
|
|
| 31 |
# generate
|
| 32 |
-
generate_button = gr.Button("Найти")
|
| 33 |
-
|
| 34 |
|
|
|
|
|
|
|
| 35 |
with gr.Column():
|
| 36 |
# output image
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
# click
|
| 40 |
generate_button.click(
|
| 41 |
-
|
| 42 |
inputs=[
|
| 43 |
prompt_input,
|
| 44 |
image_input_1,
|
|
|
|
| 45 |
],
|
| 46 |
-
outputs=
|
| 47 |
)
|
| 48 |
|
| 49 |
-
|
| 50 |
gr.Markdown(article)
|
| 51 |
|
|
|
|
| 52 |
# launch
|
| 53 |
demo.launch()
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
import os
|
| 4 |
import random
|
| 5 |
+
import glob
|
| 6 |
|
| 7 |
def generate_image(text, input_image):
|
| 8 |
return input_image
|
| 9 |
|
| 10 |
description = """
|
|
|
|
| 11 |
"""
|
| 12 |
|
| 13 |
article = """
|
| 14 |
"""
|
| 15 |
|
| 16 |
+
def images(text, input_image, pictures):
|
| 17 |
+
return [input_image] * pictures
|
| 18 |
|
| 19 |
# Gradio
|
| 20 |
with gr.Blocks(theme=gr.themes.Default(primary_hue=gr.themes.colors.orange, secondary_hue=gr.themes.colors.orange)) as demo:
|
|
|
|
| 27 |
image_input_1 = gr.Image(label="Картинка", type="filepath")
|
| 28 |
|
| 29 |
# text prompt
|
| 30 |
+
pictures_slider = gr.Slider(
|
| 31 |
+
label="Количество картинок", minimum=1.0, maximum=20.0, value=10, step=1
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
prompt_input = gr.Textbox(
|
| 35 |
label="Введите что-то", placeholder="Напишите сюда что-нибудь"
|
| 36 |
)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
# generate
|
| 40 |
+
generate_button = gr.Button("Найти", variant='primary')
|
| 41 |
+
|
| 42 |
|
| 43 |
+
|
| 44 |
+
|
| 45 |
with gr.Column():
|
| 46 |
# output image
|
| 47 |
+
# add gallery of 20 pictures here
|
| 48 |
+
#output_image = gr.Image(label="Output Image", sources='upload')
|
| 49 |
+
gallery = gr.Gallery(label='галерея', columns=4, rows=5, scale=2)
|
| 50 |
|
| 51 |
# click
|
| 52 |
generate_button.click(
|
| 53 |
+
images,
|
| 54 |
inputs=[
|
| 55 |
prompt_input,
|
| 56 |
image_input_1,
|
| 57 |
+
pictures_slider,
|
| 58 |
],
|
| 59 |
+
outputs=gallery,
|
| 60 |
)
|
| 61 |
|
| 62 |
+
# md article
|
| 63 |
gr.Markdown(article)
|
| 64 |
|
| 65 |
+
|
| 66 |
# launch
|
| 67 |
demo.launch()
|