Update for Inspirations
Browse files
app.py
CHANGED
@@ -3,38 +3,16 @@ import gradio as gr
|
|
3 |
|
4 |
tokenizer = AutoTokenizer.from_pretrained("merve/chatgpt-prompt-generator-v12")
|
5 |
model = AutoModelForSeq2SeqLM.from_pretrained("merve/chatgpt-prompt-generator-v12", from_tf=True)
|
6 |
-
#
|
7 |
-
tokenizer2 = AutoTokenizer.from_pretrained("Kaludi/chatgpt-gpt4-prompts-bart-large-cnn-samsum")
|
8 |
-
model2 = AutoModelForSeq2SeqLM.from_pretrained("Kaludi/chatgpt-gpt4-prompts-bart-large-cnn-samsum", from_tf=True)
|
9 |
|
10 |
-
def generate(prompt
|
|
|
11 |
batch = tokenizer(prompt, return_tensors="pt")
|
12 |
-
generated_ids = model.generate(batch["input_ids"], max_new_tokens=
|
13 |
output = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
|
14 |
return output[0]
|
15 |
-
|
16 |
-
|
17 |
-
batch = tokenizer2(prompt, return_tensors="pt")
|
18 |
-
generated_ids = model2.generate(batch["input_ids"], max_new_tokens=int(max_new_tokens))
|
19 |
-
output = tokenizer2.batch_decode(generated_ids, skip_special_tokens=True)
|
20 |
-
return output[0]
|
21 |
-
|
22 |
-
def generate2_test(prompt):
|
23 |
-
batch = tokenizer2(prompt, return_tensors="pt")
|
24 |
-
generated_ids = model2.generate(batch["input_ids"], max_new_tokens=150)
|
25 |
-
output = tokenizer2.batch_decode(generated_ids, skip_special_tokens=True)
|
26 |
-
return output[0]
|
27 |
-
|
28 |
-
def generate_prompt(aitype, prompt, max_new_tokens):
|
29 |
-
if aitype=='1':
|
30 |
-
return generate(prompt, max_new_tokens)
|
31 |
-
elif aitype=='2':
|
32 |
-
return generate2(prompt, max_new_tokens)
|
33 |
-
#
|
34 |
-
input_aitype = gr.Textbox(label = "Input a persona, e.g. photographer", value = "2")
|
35 |
-
input_prompt = gr.Textbox(label = "Input a persona, e.g. photographer", value = "photographer")
|
36 |
-
input_maxtokens = gr.Textbox(label = "max tokens", value = "150")
|
37 |
output_component = gr.Textbox(label = "Prompt")
|
38 |
-
examples = [["
|
39 |
description = ""
|
40 |
-
gr.Interface(
|
|
|
3 |
|
4 |
tokenizer = AutoTokenizer.from_pretrained("merve/chatgpt-prompt-generator-v12")
|
5 |
model = AutoModelForSeq2SeqLM.from_pretrained("merve/chatgpt-prompt-generator-v12", from_tf=True)
|
|
|
|
|
|
|
6 |
|
7 |
+
def generate(prompt):
|
8 |
+
|
9 |
batch = tokenizer(prompt, return_tensors="pt")
|
10 |
+
generated_ids = model.generate(batch["input_ids"], max_new_tokens=150)
|
11 |
output = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
|
12 |
return output[0]
|
13 |
+
|
14 |
+
input_component = gr.Textbox(label = "Input your Creative Thinking", value = "Creative Thinking")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
output_component = gr.Textbox(label = "Prompt")
|
16 |
+
examples = [["Creative Thinking"], ["Inspiration"]]
|
17 |
description = ""
|
18 |
+
gr.Interface(generate, inputs = input_component, outputs=output_component, examples=examples, title = "π¨π»βπ€ Power For your Inspirations π¨π»βπ€", description=description).launch()
|