Very small AI Model that Makes your prompts better for AI
Model Used: https://huggingface.co/roborovski/superprompt-v1
Check the model blog here: https://brianfitzgerald.xyz/prompt-augmentation/
This tool has been also used by a Stable Diffusion 3 Beta Tester and it shows how good it is and will be when everyone has access to SD 3: https://twitter.com/dark_sm1/status/1774054069126009032
Your Prompt (task prefix already setted): A storefront with 'Text to Image' written on it.
Generated Better Prompt: The neon sign above the storefront reads "NeurIPS" in bold, white letters. The storefront is surrounded by a bustling cityscape, with skyscrapers and neon signs lining the walls. The sign is surrounded by a variety of colorful goods, including a variety of fruits, vegetables, and fruits, all arranged in a neat and organized manner. The storefront is surrounded by a bustling crowd of people, all chatting and laughing as they go about their daily routines.
pip install transformers
if its your first time installing the package transformers on Windows, then you may wanna check this https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell#enable-long-paths-in-windows-10-version-1607-and-later.
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-small")
model = T5ForConditionalGeneration.from_pretrained("roborovski/superprompt-v1", device_map="auto")
input_text = "Expand the following prompt to add more detail: A storefront with 'Text to Image' written on it."
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids, max_new_tokens=77)
print(tokenizer.decode(outputs[0]))
# The neon sign above the storefront reads "NeurIPS" in bold, white letters. The storefront is surrounded by a bustling cityscape, with skyscrapers and neon signs lining the walls. The sign is surrounded by a variety of colorful goods, including a variety of fruits, vegetables, and fruits, all arranged in a neat and organized manner. The storefront is surrounded by a bustling crowd of people, all chatting and laughing as they go about their daily routines.
As its a very small model (77M parameters) it can run easily and fast even on old PCs CPU:
Fix https://github.com/Nick088Official/SuperPrompt-v1/issues/5.
Reduced the minimum max new tokens to 50 instead of 250, and fixed a bug where you couldn't put repetition penalty on 2 for the web ui
Correctly use the seed via the tranformers library instead of the torch one, and added a task prefix parameter which is the prompt for how to expand the your prompt to the AI.
Added back the model precision option for every ports and also improved a bit more the local version.
Improved the Local Version and removed the model precision option, so i used auto instead.
Updated the local version to make it use venvs, Credits for it to Poopmaster/Poiqazwsx
100 commits
Jupyter Notebook
63.8%
Python
23.1%
Batchfile
13.2%
Very small AI Model that Makes your prompts better for AI
Model Used: https://huggingface.co/roborovski/superprompt-v1
Check the model blog here: https://brianfitzgerald.xyz/prompt-augmentation/
This tool has been also used by a Stable Diffusion 3 Beta Tester and it shows how good it is and will be when everyone has access to SD 3: https://twitter.com/dark_sm1/status/1774054069126009032
Your Prompt (task prefix already setted): A storefront with 'Text to Image' written on it.
Generated Better Prompt: The neon sign above the storefront reads "NeurIPS" in bold, white letters. The storefront is surrounded by a bustling cityscape, with skyscrapers and neon signs lining the walls. The sign is surrounded by a variety of colorful goods, including a variety of fruits, vegetables, and fruits, all arranged in a neat and organized manner. The storefront is surrounded by a bustling crowd of people, all chatting and laughing as they go about their daily routines.
pip install transformers
if its your first time installing the package transformers on Windows, then you may wanna check this https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell#enable-long-paths-in-windows-10-version-1607-and-later.
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-small")
model = T5ForConditionalGeneration.from_pretrained("roborovski/superprompt-v1", device_map="auto")
input_text = "Expand the following prompt to add more detail: A storefront with 'Text to Image' written on it."
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids, max_new_tokens=77)
print(tokenizer.decode(outputs[0]))
# The neon sign above the storefront reads "NeurIPS" in bold, white letters. The storefront is surrounded by a bustling cityscape, with skyscrapers and neon signs lining the walls. The sign is surrounded by a variety of colorful goods, including a variety of fruits, vegetables, and fruits, all arranged in a neat and organized manner. The storefront is surrounded by a bustling crowd of people, all chatting and laughing as they go about their daily routines.
As its a very small model (77M parameters) it can run easily and fast even on old PCs CPU:
Fix https://github.com/Nick088Official/SuperPrompt-v1/issues/5.
Reduced the minimum max new tokens to 50 instead of 250, and fixed a bug where you couldn't put repetition penalty on 2 for the web ui
Correctly use the seed via the tranformers library instead of the torch one, and added a task prefix parameter which is the prompt for how to expand the your prompt to the AI.
Added back the model precision option for every ports and also improved a bit more the local version.
Improved the Local Version and removed the model precision option, so i used auto instead.
Updated the local version to make it use venvs, Credits for it to Poopmaster/Poiqazwsx
100 commits
Jupyter Notebook
63.8%
Python
23.1%
Batchfile
13.2%