Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,16 +16,8 @@ model = T5ForConditionalGeneration.from_pretrained("roborovski/superprompt-v1",
|
|
| 16 |
model.to(device)
|
| 17 |
|
| 18 |
|
| 19 |
-
def generate(
|
| 20 |
-
prompt
|
| 21 |
-
max_new_tokens,
|
| 22 |
-
repetition_penalty,
|
| 23 |
-
temperature,
|
| 24 |
-
top_p,
|
| 25 |
-
top_k,
|
| 26 |
-
seed
|
| 27 |
-
):
|
| 28 |
-
input_text = f"Expand the following prompt to add more detail: {prompt}"
|
| 29 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
|
| 30 |
|
| 31 |
if seed == 0:
|
|
@@ -49,7 +41,7 @@ def generate(
|
|
| 49 |
return better_prompt
|
| 50 |
|
| 51 |
|
| 52 |
-
|
| 53 |
|
| 54 |
max_new_tokens = gr.Slider(value=512, minimum=250, maximum=512, step=1, interactive=True, label="Max New Tokens", info="The maximum numbers of new tokens, controls how long is the output")
|
| 55 |
|
|
@@ -77,7 +69,7 @@ examples = [
|
|
| 77 |
|
| 78 |
gr.Interface(
|
| 79 |
fn=generate,
|
| 80 |
-
inputs=[
|
| 81 |
outputs=gr.Textbox(label="Better Prompt"),
|
| 82 |
title="SuperPrompt-v1",
|
| 83 |
description='Make your prompts more detailed! <br> <a href="https://huggingface.co/roborovski/superprompt-v1">Model used</a> <br> <a href="https://brianfitzgerald.xyz/prompt-augmentation/">Model Blog</a> <br> Task Prefix: "Expand the following prompt to add more detail:" is already setted! <br> Hugging Face Space made by [Nick088](https://linktr.ee/Nick088)',
|
|
|
|
| 16 |
model.to(device)
|
| 17 |
|
| 18 |
|
| 19 |
+
def generate(your_prompt, max_new_tokens, repetition_penalty, temperature, top_p, top_k, seed):
|
| 20 |
+
input_text = f"Expand the following prompt to add more detail: {your_prompt}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
|
| 22 |
|
| 23 |
if seed == 0:
|
|
|
|
| 41 |
return better_prompt
|
| 42 |
|
| 43 |
|
| 44 |
+
your_prompt = gr.Textbox(label="Your Prompt", interactive=True)
|
| 45 |
|
| 46 |
max_new_tokens = gr.Slider(value=512, minimum=250, maximum=512, step=1, interactive=True, label="Max New Tokens", info="The maximum numbers of new tokens, controls how long is the output")
|
| 47 |
|
|
|
|
| 69 |
|
| 70 |
gr.Interface(
|
| 71 |
fn=generate,
|
| 72 |
+
inputs=[your_prompt, max_new_tokens, repetition_penalty, temperature, top_p, top_k, seed],
|
| 73 |
outputs=gr.Textbox(label="Better Prompt"),
|
| 74 |
title="SuperPrompt-v1",
|
| 75 |
description='Make your prompts more detailed! <br> <a href="https://huggingface.co/roborovski/superprompt-v1">Model used</a> <br> <a href="https://brianfitzgerald.xyz/prompt-augmentation/">Model Blog</a> <br> Task Prefix: "Expand the following prompt to add more detail:" is already setted! <br> Hugging Face Space made by [Nick088](https://linktr.ee/Nick088)',
|