ngoctuanai commited on
Commit
eef06b6
·
1 Parent(s): 8d5132b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -15
app.py CHANGED
@@ -77,6 +77,8 @@ def generate_txt2img(current_model, prompt, is_negative=False, image_style="None
77
  image = Image.open(io.BytesIO(image_bytes))
78
  return image
79
 
 
 
80
  css = """
81
  /* General Container Styles */
82
  .gradio-container {
@@ -122,21 +124,29 @@ def generate_txt2img(current_model, text_prompt, negative_prompt, image_style):
122
  # Your generation code here
123
  pass
124
 
125
- current_model = gr.inputs.Dropdown(label="Current Model", choices=list_models, default=list_models[1])
 
 
 
 
126
  text_prompt = gr.inputs.Textbox(label="Prompt", placeholder="Enter a prompt", lines=1)
127
  negative_prompt = gr.inputs.Textbox(label="Negative Prompt", value="text, blurry, fuzziness", lines=1)
128
- image_style = gr.inputs.Dropdown(label="Style", choices=["None style", "Cinematic", "Digital Art", "Portrait"], default="None style")
129
- generate_button = gr.outputs.Button(label="Generate", type="button")
130
 
131
- image_output = gr.outputs.Image(label="Generated Image")
132
-
133
- interface = gr.Interface(
134
- fn=generate_txt2img,
135
- inputs=[current_model, text_prompt, negative_prompt, image_style, generate_button],
136
- outputs=image_output,
137
- layout="vertical",
138
- css=css,
139
- title="AI Diffusion"
140
- )
141
-
142
- interface.launch()
 
 
 
 
 
 
77
  image = Image.open(io.BytesIO(image_bytes))
78
  return image
79
 
80
+ import gradio as gr
81
+
82
  css = """
83
  /* General Container Styles */
84
  .gradio-container {
 
124
  # Your generation code here
125
  pass
126
 
127
+ favicon = '<img src="" width="48px" style="display: inline">'
128
+ title = f"""<h1><center>{favicon} AI Diffusion</center></h1>"""
129
+ markdown_title = gr.Markdown(title)
130
+
131
+ current_model = gr.inputs.Dropdown(label="Current Model", choices=list_models, value=list_models[1])
132
  text_prompt = gr.inputs.Textbox(label="Prompt", placeholder="Enter a prompt", lines=1)
133
  negative_prompt = gr.inputs.Textbox(label="Negative Prompt", value="text, blurry, fuzziness", lines=1)
134
+ image_style = gr.inputs.Dropdown(label="Style", choices=["None style", "Cinematic", "Digital Art", "Portrait"], value="None style")
 
135
 
136
+ generate_button = gr.outputs.Button(label="Generate", type="button")
137
+ image_output = gr.outputs.Image(label="Output Image")
138
+
139
+ with gr.Blocks(css=css) as demo:
140
+ gr.Grid(col_width="auto", col_gap="10px").push(
141
+ markdown_title,
142
+ current_model,
143
+ text_prompt,
144
+ negative_prompt,
145
+ image_style,
146
+ generate_button,
147
+ image_output
148
+ )
149
+
150
+ generate_button.click(generate_txt2img, inputs=[current_model, text_prompt, negative_prompt, image_style], outputs=image_output)
151
+
152
+ demo.launch(show_api=False)