llamameta commited on
Commit
529c805
·
verified ·
1 Parent(s): 738915f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -22
app.py CHANGED
@@ -177,15 +177,16 @@ def gen(prompt: str, system_prompt: str, token: str, accountId: str):
177
 
178
  return text, images
179
 
180
- # Modify Gradio interface
181
- with gr.Blocks(theme="ocean") as demo:
 
 
182
  gr.HTML("<h1><center>ImagenX</center></h1>")
183
  prompt = gr.Textbox(label='Enter Your Prompt', placeholder="Enter prompt...")
184
  with gr.Row():
185
  sendBtn = gr.Button(variant='primary')
186
  clearBtn = gr.ClearButton([prompt])
187
  gen_text = gr.Textbox(label="Optimization")
188
- # Ganti Image dengan Gallery
189
  gen_img = gr.Gallery(
190
  label="Generated Images",
191
  show_label=True,
@@ -196,31 +197,31 @@ with gr.Blocks(theme="ocean") as demo:
196
  )
197
  with gr.Accordion("Advanced Options", open=True):
198
  system_prompt = gr.Textbox(
199
- value = PRESET_PROMPT,
200
- label = "System prompt",
201
- lines = 10,
202
  )
203
  token = gr.Textbox(
204
- label = "API Token",
205
- type = "password"
206
  )
207
  accountId = gr.Textbox(
208
- label = "Account ID",
209
- type = "password"
210
  )
211
  gr.HTML("<p>Powered By Cloudflare Workers AI</p>")
212
 
213
- gr.on(
214
- triggers=[
215
- prompt.submit,
216
- sendBtn.click,
217
- ],
218
  fn=gen,
219
- inputs=[
220
- prompt,
221
- system_prompt,
222
- token,
223
- accountId
224
- ],
225
  outputs=[gen_text, gen_img]
226
- )
 
 
 
 
 
 
 
 
 
 
177
 
178
  return text, images
179
 
180
+ # Gradio Interface
181
+ demo = gr.Blocks(theme="ocean")
182
+
183
+ with demo:
184
  gr.HTML("<h1><center>ImagenX</center></h1>")
185
  prompt = gr.Textbox(label='Enter Your Prompt', placeholder="Enter prompt...")
186
  with gr.Row():
187
  sendBtn = gr.Button(variant='primary')
188
  clearBtn = gr.ClearButton([prompt])
189
  gen_text = gr.Textbox(label="Optimization")
 
190
  gen_img = gr.Gallery(
191
  label="Generated Images",
192
  show_label=True,
 
197
  )
198
  with gr.Accordion("Advanced Options", open=True):
199
  system_prompt = gr.Textbox(
200
+ value=PRESET_PROMPT,
201
+ label="System prompt",
202
+ lines=10,
203
  )
204
  token = gr.Textbox(
205
+ label="API Token",
206
+ type="password"
207
  )
208
  accountId = gr.Textbox(
209
+ label="Account ID",
210
+ type="password"
211
  )
212
  gr.HTML("<p>Powered By Cloudflare Workers AI</p>")
213
 
214
+ sendBtn.click(
 
 
 
 
215
  fn=gen,
216
+ inputs=[prompt, system_prompt, token, accountId],
 
 
 
 
 
217
  outputs=[gen_text, gen_img]
218
+ )
219
+
220
+ prompt.submit(
221
+ fn=gen,
222
+ inputs=[prompt, system_prompt, token, accountId],
223
+ outputs=[gen_text, gen_img]
224
+ )
225
+
226
+ if __name__ == "__main__":
227
+ demo.queue(api_open=False).launch(show_api=False, share=False)