jennysun commited on
Commit
c190b7c
Β·
1 Parent(s): dda908e

Removing mirror

Browse files
Files changed (1) hide show
  1. app.py +3 -51
app.py CHANGED
@@ -22,6 +22,7 @@ import openai
22
  from gradio.components import Textbox, Text
23
 
24
  sys.tracebacklimit = 0
 
25
  def load_from_hf(repo_id, filename='diffusion_pytorch_model.bin', subfolder=None):
26
  cache_file = hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder)
27
  return torch.load(cache_file, map_location='cpu')
@@ -494,42 +495,10 @@ function(x) {
494
  }
495
  """
496
 
497
- mirror_js = """
498
- function () {
499
- const root = document.querySelector('gradio-app').shadowRoot || document.querySelector('gradio-app');
500
- const mirrors_div = root.querySelector('#mirrors');
501
- const current_url = window.location.href;
502
- const mirrors = [
503
- 'https://dev.hliu.cc/gligen_mirror1/',
504
- 'https://dev.hliu.cc/gligen_mirror2/',
505
- ];
506
-
507
- let mirror_html = '';
508
- mirror_html += '[<a href="https://gligen.github.io" target="_blank" style="">Project Page</a>]';
509
- mirror_html += '[<a href="https://arxiv.org/abs/2301.07093" target="_blank" style="">Paper</a>]';
510
- mirror_html += '[<a href="https://github.com/gligen/GLIGEN" target="_blank" style="">GitHub Repo</a>]';
511
- mirror_html += '&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
512
- mirror_html += 'Mirrors: ';
513
-
514
- mirrors.forEach((e, index) => {
515
- let cur_index = index + 1;
516
- if (current_url.includes(e)) {
517
- mirror_html += `[Mirror ${cur_index}] `;
518
- } else {
519
- mirror_html += `[<a onclick="window.location.href = '${e}'">Mirror ${cur_index}</a>] `;
520
- }
521
- });
522
-
523
- mirror_html = `<div class="output-markdown gr-prose" style="max-width: 100%;"><h3 style="text-align: center" id="paper-info">${mirror_html}</h3></div>`;
524
-
525
- mirrors_div.innerHTML = mirror_html;
526
- }
527
- """
528
-
529
  # Set up OpenAI API key
530
  openai.api_key = os.environ['OPENAI_API_KEY']
531
 
532
- prompt_base = 'Separate the subjects in this sentence by semicolons. For example, the sentence "a tiger and a horse running in a greenland" should output "tiger; horse". If there are numbers, make each subject unique. For example, "2 dogs and 1 duck" would be "dog; dog; duck." Do the same for the following sentence: \n'
533
 
534
  original_input = ""
535
  separated_subjects = ""
@@ -558,23 +527,6 @@ def separate_subjects(input_text):
558
  output_text = response.choices[0].text.strip()
559
  return output_text
560
 
561
- # def update_original_input():
562
- # print("start update_original_input")
563
- # global original_input
564
- # original_input = language_instruction.value
565
- # print("original_input in update:", original_input)
566
-
567
- # def update_grounding_instruction():
568
- # print("start update_grounding_instruction")
569
- # # global original_input # declare you want to use the outer variable
570
- # global separated_subjects
571
- # update_original_input()
572
- # separated_subjects = separate_subjects(language_instruction.value)
573
- # # separated_subjects = separate_subjects(original_input)
574
- # grounding_instruction.value = separated_subjects
575
- # print("original_input:", original_input)
576
- # print("separated_subjects", separated_subjects)
577
-
578
  with Blocks(
579
  css=css,
580
  analytics_enabled=False,
@@ -652,7 +604,7 @@ with Blocks(
652
  out_imagebox = gr.Image(type="pil", label="Parsed Sketch Pad")
653
  with gr.Row():
654
  clear_btn = gr.Button(value='Clear')
655
- gen_btn = gr.Button(value='Generate', elem_id="generate-btn")
656
  with gr.Accordion("Advanced Options", open=False):
657
  with gr.Column():
658
  alpha_sample = gr.Slider(minimum=0, maximum=1.0, step=0.1, value=0.3, label="Scheduled Sampling (Ο„)", visible=False)
 
22
  from gradio.components import Textbox, Text
23
 
24
  sys.tracebacklimit = 0
25
+
26
  def load_from_hf(repo_id, filename='diffusion_pytorch_model.bin', subfolder=None):
27
  cache_file = hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder)
28
  return torch.load(cache_file, map_location='cpu')
 
495
  }
496
  """
497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  # Set up OpenAI API key
499
  openai.api_key = os.environ['OPENAI_API_KEY']
500
 
501
+ prompt_base = 'Separate the subjects in this sentence by semicolons. For example, the sentence "a tiger and a horse running" should output "tiger; horse". If there are numbers, make each subject unique. For example, "2 dogs and 1 duck" would be "dog; dog; duck." Do the same for the following sentence: \n'
502
 
503
  original_input = ""
504
  separated_subjects = ""
 
527
  output_text = response.choices[0].text.strip()
528
  return output_text
529
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
  with Blocks(
531
  css=css,
532
  analytics_enabled=False,
 
604
  out_imagebox = gr.Image(type="pil", label="Parsed Sketch Pad")
605
  with gr.Row():
606
  clear_btn = gr.Button(value='Clear')
607
+ gen_btn = gr.Button(value='Generate')
608
  with gr.Accordion("Advanced Options", open=False):
609
  with gr.Column():
610
  alpha_sample = gr.Slider(minimum=0, maximum=1.0, step=0.1, value=0.3, label="Scheduled Sampling (Ο„)", visible=False)