DmitrMakeev commited on
Commit
4aa5967
1 Parent(s): 836c20e

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +74 -0
utils.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+
3
+ import numpy as np
4
+
5
+ MAX_SEED = np.iinfo(np.int32).max
6
+
7
+
8
+ style_list = [
9
+ {
10
+ "name": "(No style)",
11
+ "prompt": "{prompt}",
12
+ "negative_prompt": "",
13
+ },
14
+ {
15
+ "name": "Cinematic",
16
+ "prompt": "cinematic still {prompt} . emotional, harmonious, vignette, highly detailed, high budget, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy",
17
+ "negative_prompt": "anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured",
18
+ },
19
+ {
20
+ "name": "3D Model",
21
+ "prompt": "professional 3d model {prompt} . octane render, highly detailed, volumetric, dramatic lighting",
22
+ "negative_prompt": "ugly, deformed, noisy, low poly, blurry, painting",
23
+ },
24
+ {
25
+ "name": "Anime",
26
+ "prompt": "anime artwork {prompt} . anime style, key visual, vibrant, studio anime, highly detailed",
27
+ "negative_prompt": "photo, deformed, black and white, realism, disfigured, low contrast",
28
+ },
29
+ {
30
+ "name": "Digital Art",
31
+ "prompt": "concept art {prompt} . digital artwork, illustrative, painterly, matte painting, highly detailed",
32
+ "negative_prompt": "photo, photorealistic, realism, ugly",
33
+ },
34
+ {
35
+ "name": "Photographic",
36
+ "prompt": "cinematic photo {prompt} . 35mm photograph, film, bokeh, professional, 4k, highly detailed",
37
+ "negative_prompt": "drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly",
38
+ },
39
+ {
40
+ "name": "Pixel art",
41
+ "prompt": "pixel-art {prompt} . low-res, blocky, pixel art style, 8-bit graphics",
42
+ "negative_prompt": "sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic",
43
+ },
44
+ {
45
+ "name": "Fantasy art",
46
+ "prompt": "ethereal fantasy concept art of {prompt} . magnificent, celestial, ethereal, painterly, epic, majestic, magical, fantasy art, cover art, dreamy",
47
+ "negative_prompt": "photographic, realistic, realism, 35mm film, dslr, cropped, frame, text, deformed, glitch, noise, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, sloppy, duplicate, mutated, black and white",
48
+ },
49
+ {
50
+ "name": "Neonpunk",
51
+ "prompt": "neonpunk style {prompt} . cyberpunk, vaporwave, neon, vibes, vibrant, stunningly beautiful, crisp, detailed, sleek, ultramodern, magenta highlights, dark purple shadows, high contrast, cinematic, ultra detailed, intricate, professional",
52
+ "negative_prompt": "painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured",
53
+ },
54
+ {
55
+ "name": "Manga",
56
+ "prompt": "manga style {prompt} . vibrant, high-energy, detailed, iconic, Japanese comic style",
57
+ "negative_prompt": "ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, Western comic style",
58
+ },
59
+ ]
60
+
61
+ styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
62
+ STYLE_NAMES = list(styles.keys())
63
+ DEFAULT_STYLE_NAME = "Photographic"
64
+
65
+
66
+ def apply_style(style_name: str, positive: str, negative: str = "") -> tuple[str, str]:
67
+ p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
68
+ return p.replace("{prompt}", positive), n + negative
69
+
70
+
71
+ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
72
+ if randomize_seed:
73
+ seed = random.randint(0, MAX_SEED)
74
+ return seed