baiango commited on
Commit
5bde2c8
1 Parent(s): a5ad31b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -9
README.md CHANGED
@@ -8,7 +8,7 @@ tags:
8
  - art
9
  ---
10
  # REM sleep priming anime
11
- A Python script that will generates the prompt unconditionally to increase the variation without any LLM bias; by Python's built-in Mersenne Twister (mt19937) PRNG in the random module. Iterated and tested with [cagliostrolab/animagine-xl-3.1](https://huggingface.co/spaces/cagliostrolab/animagine-xl-3.1) spaces. Not all the generated detail in the prompt works, this is due to the model lacking the dataset to understand it. And, not the script is not working. To use it, run the script and copy the printed output.
12
  Examples:
13
  ```
14
  1girl, early, creative, lifting, red-purple bangs haircut, green wolf eyes, earrings, navy blue and tan outfit, crewneck, flare jeans, high-angle shot, colonies on other planets, crepuscular rays
@@ -16,8 +16,27 @@ Examples:
16
 
17
  ### Code
18
  ```py
19
- import random
20
  import functools
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  class REMSleepPrmAnime:
23
  def __init__(self):
@@ -66,12 +85,14 @@ class REMSleepPrmAnime:
66
  self.lightings = {"both": {"rim lighting", "flat lighting", "cinematic lighting", "crepuscular rays"}}
67
 
68
  def main(self):
 
 
69
  def get_random_x(x, gender=["both"]):
70
  concat = sum([list(x.get(ge, [])) for ge in gender], [])
71
- return concat[random.randint(0, len(concat) - 1)] if len(concat) else ""
72
 
73
- rand50 = lambda: random.randint(1, 100) <= 50
74
- rand85 = lambda: random.randint(1, 100) <= 85
75
 
76
  gender = "1girl" if rand50() else "1boy"
77
  gender_selection = ["both"] + ["female" if gender == "1girl" else "male"]
@@ -95,7 +116,7 @@ class REMSleepPrmAnime:
95
  *(((self.one_pieces,),) if rand50() else ((self.tops,), (self.bottoms,))),
96
 
97
  (self.camera_angels, "shot",),
98
- ((self.places,) if rand85() else (self.eras,)),
99
 
100
  # ("masterpiece",), ("best quality",), ("very aesthetic",), ("absurdres",), # Already prepended
101
  (self.resolutions if rand50() else None,),
@@ -114,8 +135,16 @@ if __name__ == "__main__":
114
  prompt_generator = REMSleepPrmAnime()
115
  [print(prompt_generator.main()) for _ in range(1)]
116
  ```
117
-
118
-
 
 
 
 
 
 
 
 
119
  ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6557be93e0a6202d3613b651/sP7PGb0S75jRvP5HAki2G.png)
120
  ```json
121
  {
@@ -168,4 +197,4 @@ if __name__ == "__main__":
168
  "use_upscaler": null,
169
  "model": "Animagine XL 3.1"
170
  }
171
- ```
 
8
  - art
9
  ---
10
  # REM sleep priming anime
11
+ A Python script that will generates the prompt unconditionally to increase the variation without any LLM bias; by my custom-made PCG64 PRNG. Iterated and tested with [cagliostrolab/animagine-xl-3.1](https://huggingface.co/spaces/cagliostrolab/animagine-xl-3.1) spaces. Not all the generated detail in the prompt works, this is due to the model lacking the dataset to understand it. And, not the script is not working. To use it, run the script and copy the printed output.
12
  Examples:
13
  ```
14
  1girl, early, creative, lifting, red-purple bangs haircut, green wolf eyes, earrings, navy blue and tan outfit, crewneck, flare jeans, high-angle shot, colonies on other planets, crepuscular rays
 
16
 
17
  ### Code
18
  ```py
 
19
  import functools
20
+ import time
21
+
22
+
23
+ class PCG64:
24
+ # https://www.pcg-random.org/download.html#id1
25
+ # Less biased than MT19937 or `random.randint`!
26
+ def __init__(self, seed=time.time_ns()):
27
+ self._state = seed
28
+
29
+ def random(self):
30
+ old_state = self._state
31
+ self._state = (self._state * 6364136223846793005) & 0xffffffffffffffff
32
+ xorshifted = (((old_state >> 18) ^ old_state) >> 27) & 0xffffffffffffffff
33
+ rot = old_state >> 59
34
+ result = (xorshifted >> rot) | (xorshifted << (-rot & 31))
35
+ return result & 0xffffffffffffffff
36
+
37
+ def randint(self, begin, end):
38
+ return self.random() % (1 + end - begin) + begin
39
+
40
 
41
  class REMSleepPrmAnime:
42
  def __init__(self):
 
85
  self.lightings = {"both": {"rim lighting", "flat lighting", "cinematic lighting", "crepuscular rays"}}
86
 
87
  def main(self):
88
+ rng = PCG64()
89
+
90
  def get_random_x(x, gender=["both"]):
91
  concat = sum([list(x.get(ge, [])) for ge in gender], [])
92
+ return concat[rng.randint(0, len(concat) - 1)] if len(concat) else ""
93
 
94
+ rand50 = lambda: rng.randint(1, 100) <= 50
95
+ rand75 = lambda: rng.randint(1, 100) <= 75
96
 
97
  gender = "1girl" if rand50() else "1boy"
98
  gender_selection = ["both"] + ["female" if gender == "1girl" else "male"]
 
116
  *(((self.one_pieces,),) if rand50() else ((self.tops,), (self.bottoms,))),
117
 
118
  (self.camera_angels, "shot",),
119
+ ((self.places,) if rand75() else (self.eras,)),
120
 
121
  # ("masterpiece",), ("best quality",), ("very aesthetic",), ("absurdres",), # Already prepended
122
  (self.resolutions if rand50() else None,),
 
135
  prompt_generator = REMSleepPrmAnime()
136
  [print(prompt_generator.main()) for _ in range(1)]
137
  ```
138
+ ### Contributing
139
+ I prefer every new strings/keywords are stored per line, or stored in CSV or JSON; don't send me binary files.
140
+ A file (fruits.csv) per variable CSV example:
141
+ ```
142
+ color,fruit
143
+ orange,orange,mandarins,papaya
144
+ red,apple,strawberries,tomatoes
145
+ purple,grape,plums,blackberries
146
+ ```
147
+ ### Examples
148
  ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6557be93e0a6202d3613b651/sP7PGb0S75jRvP5HAki2G.png)
149
  ```json
150
  {
 
197
  "use_upscaler": null,
198
  "model": "Animagine XL 3.1"
199
  }
200
+ ```