File size: 923 Bytes
8780c33 0d2c713 8780c33 0d2c713 8780c33 0d2c713 8780c33 0d2c713 8780c33 0d2c713 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import gradio as gr
tokenizer = AutoTokenizer.from_pretrained("merve/chatgpt-prompt-generator-v12")
model = AutoModelForSeq2SeqLM.from_pretrained("merve/chatgpt-prompt-generator-v12", from_tf=True)
def generate(prompt):
batch = tokenizer(prompt, return_tensors="pt")
generated_ids = model.generate(batch["input_ids"], max_new_tokens=150)
output = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
return output[0]
input_component = gr.Textbox(label = "Input your Creative Thinking", value = "Creative Thinking")
output_component = gr.Textbox(label = "Prompt")
examples = [["Creative Thinking"], ["Inspiration"]]
description = ""
gr.Interface(generate, inputs = input_component, outputs=output_component, examples=examples, title = "π¨π»βπ€ Power For your Inspirations π¨π»βπ€", description=description).launch() |