dreamdrop-art commited on
Commit
fc63532
1 Parent(s): c95bc41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -13,6 +13,8 @@ import PIL
13
  from PIL import Image
14
  import re
15
 
 
 
16
 
17
  def query(payload, model):
18
  HF_TOKEN = os.getenv("HF_TOKEN")
@@ -381,7 +383,7 @@ with gr.Blocks(css=css) as demo:
381
  with gr.Row():
382
  with gr.Column():
383
  image_input = gr.Image(type="filepath", interactive=True)
384
- png_button = gr.Button("Get Info")
385
  with gr.Row():
386
  with gr.Column():
387
  exif_output = gr.HTML(label="EXIF Data")
@@ -439,7 +441,7 @@ with gr.Blocks(css=css) as demo:
439
  gpt2_pipe = pipeline('text-generation', model='Gustavosta/MagicPrompt-Stable-Diffusion', tokenizer='gpt2')
440
  with open("ideas.txt", "r") as f:
441
  line = f.readlines()
442
- def generate(starting_text):
443
  seed = random.randint(100, 1000000)
444
  set_seed(seed)
445
  if starting_text == "":
@@ -454,9 +456,18 @@ with gr.Blocks(css=css) as demo:
454
  response_end = "\n".join(response_list)
455
  response_end = re.sub('[^ ]+\.[^ ]+','', response_end)
456
  response_end = response_end.replace("<", "").replace(">", "")
457
-
458
- if response_end != "":
459
- return response_end
 
 
 
 
 
 
 
 
 
460
 
461
  with gr.Tab("BLIP"):
462
  with gr.Tab("Base"):
 
13
  from PIL import Image
14
  import re
15
 
16
+ send_prompt(prompt):
17
+ return prompt
18
 
19
  def query(payload, model):
20
  HF_TOKEN = os.getenv("HF_TOKEN")
 
383
  with gr.Row():
384
  with gr.Column():
385
  image_input = gr.Image(type="filepath", interactive=True)
386
+ png_button = gr.Button("Get Info", variant="primary")
387
  with gr.Row():
388
  with gr.Column():
389
  exif_output = gr.HTML(label="EXIF Data")
 
441
  gpt2_pipe = pipeline('text-generation', model='Gustavosta/MagicPrompt-Stable-Diffusion', tokenizer='gpt2')
442
  with open("ideas.txt", "r") as f:
443
  line = f.readlines()
444
+ def prompt_gen(starting_text):
445
  seed = random.randint(100, 1000000)
446
  set_seed(seed)
447
  if starting_text == "":
 
456
  response_end = "\n".join(response_list)
457
  response_end = re.sub('[^ ]+\.[^ ]+','', response_end)
458
  response_end = response_end.replace("<", "").replace(">", "")
459
+ if response_end != "":
460
+ return response_end
461
+ idea = gr.Textbox(show_label=False, placeholder="Enter your idea", max_lines=3, lines=1, interactive=True)
462
+ prompt_button = gr.Button(value="Generate Prompt", variant="primary")
463
+ prompt_full = gr.Textbox(label="Full Prompt", max_lines=8, lines=3, interactive=False, show_copy_button=True)
464
+ send_to_txt2img_prompt = gr.Button(value="Send FULL PROMPT to txt2img")
465
+ send_to_img2img_prompt = gr.Button(value="Send FULL PROMPT to img2img")
466
+
467
+ send_to_txt2img_prompt.click(send_prompt, inputs=prompt_full, outputs=prompt)
468
+ send_to_img2img_prompt.click(send_prompt, inputs=prompt_full, outputs=i2i_prompt)
469
+ idea.submit(prompt_gen, inputs=idea, outputs=prompt_full)
470
+ prompt_button.click(prompt_gen, inputs=idea, outputs=prompt_full)
471
 
472
  with gr.Tab("BLIP"):
473
  with gr.Tab("Base"):