upload
Browse files
README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Stable Diffusion Prompts Generation Model
|
| 3 |
+
|
| 4 |
+
This Hugging Face model, named "Falah/stable_diffusion_prompts_gen", is designed for generating illustration art style prompts using the Stable Diffusion tool for text-to-image generation. It utilizes the custom dataset "Falah/stable_diffusion_prompts_dataset" to generate creative and coherent text prompts.
|
| 5 |
+
|
| 6 |
+
## Examples
|
| 7 |
+
|
| 8 |
+
To load the model and generate inferences using the model, you can use the following code snippet:
|
| 9 |
+
|
| 10 |
+
```python
|
| 11 |
+
import torch
|
| 12 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 13 |
+
|
| 14 |
+
model_name = "Falah/stable_diffusion_prompts_gen"
|
| 15 |
+
dataset_name = "Falah/stable_diffusion_prompts_dataset"
|
| 16 |
+
prompt = r'a beautiful female' # the beginning of the prompt
|
| 17 |
+
temperature = 0.9 # a higher temperature will produce more diverse results, but with a higher risk of less coherent text
|
| 18 |
+
top_k = 8 # the number of tokens to sample from at each step
|
| 19 |
+
max_length = 100 # the maximum number of tokens for the output of the model
|
| 20 |
+
repetition_penalty = 1.2 # the penalty value for each repetition of a token
|
| 21 |
+
num_return_sequences = 5 # the number of results to generate
|
| 22 |
+
|
| 23 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 24 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 25 |
+
|
| 26 |
+
input_ids = tokenizer(prompt, return_tensors='pt').input_ids
|
| 27 |
+
output = model.generate(
|
| 28 |
+
input_ids,
|
| 29 |
+
do_sample=True,
|
| 30 |
+
temperature=temperature,
|
| 31 |
+
top_k=top_k,
|
| 32 |
+
max_length=max_length,
|
| 33 |
+
num_return_sequences=num_return_sequences,
|
| 34 |
+
repetition_penalty=repetition_penalty,
|
| 35 |
+
early_stopping=True
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
print('\033[96m' + prompt + '\033[0m')
|
| 39 |
+
for i in range(len(output)):
|
| 40 |
+
print(tokenizer.decode(output[i], skip_special_tokens=True) + '\n')
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
Feel free to modify the parameters like `prompt`, `temperature`, `top_k`, etc., to experiment with different outputs.
|
| 44 |
+
|
| 45 |
+
## Citation
|
| 46 |
+
|
| 47 |
+
If you use this model or the associated dataset in your research or projects, please cite it as follows:
|
| 48 |
+
|
| 49 |
+
```
|
| 50 |
+
@article{your-article-citation,
|
| 51 |
+
title = {Title of Your Article},
|
| 52 |
+
author = {Your Name},
|
| 53 |
+
journal = {Journal Name},
|
| 54 |
+
year = {2023},
|
| 55 |
+
doi = {10.xxxx/your-doi}
|
| 56 |
+
}
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## License
|
| 60 |
+
|
| 61 |
+
This project is licensed under the Apache License, Version 2.0. Please see the [LICENSE](link-to-license-file) file for more details.
|
| 62 |
+
|