Ritesh Khanna commited on
Commit
e99a5e3
1 Parent(s): cbc1cc3

another log

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -4,7 +4,7 @@ import transformers
4
  import os
5
  import re
6
  import json
7
-
8
 
9
  device = "cpu"
10
 
@@ -71,6 +71,7 @@ def generate_text(prompt, extra=False, top_k=100, top_p=0.95, temperature=0.85,
71
  for i in range(1):
72
  print(f"Generating sample {i+1}")
73
  outputs = model.generate(**inputs, max_length=256, do_sample=True, top_k=top_k, top_p=top_p, temperature=temperature, num_return_sequences=4, pad_token_id=tokenizer.eos_token_id)
 
74
  for output in outputs:
75
  sample = tokenizer.decode(output, skip_special_tokens=True)
76
  sample = format_prompt(sample, enhancers, inpspiration, negative_prompt)
@@ -120,7 +121,7 @@ if __name__ == "__main__":
120
  examples = json.load(f)
121
 
122
  for i, example in enumerate(examples):
123
- with gr.Tab(f"Example {i+1}"):
124
  with gr.Row():
125
  with gr.Column():
126
  gr.Markdown(f"### Base Prompt")
@@ -135,6 +136,10 @@ if __name__ == "__main__":
135
  gr.Markdown(f"Coming Soon!")
136
 
137
 
 
 
 
 
138
  init_model()
139
  fungineer.launch(enable_queue=True)
140
 
 
4
  import os
5
  import re
6
  import json
7
+ import random
8
 
9
  device = "cpu"
10
 
 
71
  for i in range(1):
72
  print(f"Generating sample {i+1}")
73
  outputs = model.generate(**inputs, max_length=256, do_sample=True, top_k=top_k, top_p=top_p, temperature=temperature, num_return_sequences=4, pad_token_id=tokenizer.eos_token_id)
74
+ print(f"Generated {len(outputs)} samples.")
75
  for output in outputs:
76
  sample = tokenizer.decode(output, skip_special_tokens=True)
77
  sample = format_prompt(sample, enhancers, inpspiration, negative_prompt)
 
121
  examples = json.load(f)
122
 
123
  for i, example in enumerate(examples):
124
+ with gr.Tab(f"Example {i+1}", id=i):
125
  with gr.Row():
126
  with gr.Column():
127
  gr.Markdown(f"### Base Prompt")
 
136
  gr.Markdown(f"Coming Soon!")
137
 
138
 
139
+ random_id = random.randint(0, len(examples)-1)
140
+ gr.Tabs.update(selected=random_id)
141
+
142
+
143
  init_model()
144
  fungineer.launch(enable_queue=True)
145