FredZhang7 commited on
Commit
4d00198
•
1 Parent(s): f498686

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +6 -4
README.md CHANGED
@@ -36,7 +36,7 @@ Prefix *1boy*  | [Generated *1boy* prompts](./anime_boy_settings.txt) | 
36
 
37
  ![](./anime_boys.png)
38
 
39
- ## Greedy Search
40
  ```python
41
  import torch
42
  from transformers import GPT2Tokenizer, GPT2LMHeadModel, pipeline
@@ -44,13 +44,13 @@ tokenizer = GPT2Tokenizer.from_pretrained('distilgpt2')
44
  tokenizer.add_special_tokens({'pad_token': '[PAD]'})
45
  model = GPT2LMHeadModel.from_pretrained('FredZhang7/anime-anything-promptgen')
46
 
47
- prompt = r'1girl, master piece,'
48
 
49
  # generate text using fine-tuned model
50
  nlp = pipeline('text-generation', model=model, tokenizer=tokenizer)
51
 
52
  # generate 10 samples using greedy search
53
- outs = nlp(prompt, max_length=76, num_return_sequences=10, do_sample=True, temperature=0.7, top_k=4, early_stopping=True)
54
 
55
  print('\nInput:\n' + 100 * '-')
56
  print('\033[96m' + prompt + '\033[0m')
@@ -63,7 +63,9 @@ print('\033[92m' + '\n\n'.join(outs) + '\033[0m\n')
63
 
64
  Output Example:
65
 
66
- ![](./greedy_search.png)
 
 
67
 
68
 
69
  ## Tips
 
36
 
37
  ![](./anime_boys.png)
38
 
39
+ ## Contrastive Search
40
  ```python
41
  import torch
42
  from transformers import GPT2Tokenizer, GPT2LMHeadModel, pipeline
 
44
  tokenizer.add_special_tokens({'pad_token': '[PAD]'})
45
  model = GPT2LMHeadModel.from_pretrained('FredZhang7/anime-anything-promptgen')
46
 
47
+ prompt = r'1girl, genshin impact'
48
 
49
  # generate text using fine-tuned model
50
  nlp = pipeline('text-generation', model=model, tokenizer=tokenizer)
51
 
52
  # generate 10 samples using greedy search
53
+ outs = nlp(prompt, max_length=76, num_return_sequences=10, do_sample=True, repetition_penalty=1.1, temperature=0.7, top_k=4, early_stopping=True)
54
 
55
  print('\nInput:\n' + 100 * '-')
56
  print('\033[96m' + prompt + '\033[0m')
 
63
 
64
  Output Example:
65
 
66
+ ![](./contrastive_search.png)
67
+
68
+ Please see [Fast GPT PromptGen](https://huggingface.co/FredZhang7/distilgpt2-stable-diffusion-v2) for more info on the pipeline parameters.
69
 
70
 
71
  ## Tips