File size: 2,221 Bytes
b857620
987024c
 
cf72c4b
 
 
 
 
 
 
 
 
 
 
23f3fad
cf72c4b
23f3fad
cf72c4b
 
 
 
23f3fad
cf72c4b
23f3fad
cf72c4b
 
 
987024c
a1db0e9
 
 
 
 
 
987024c
cf72c4b
 
 
 
 
 
 
987024c
cf72c4b
 
 
 
 
 
987024c
cf72c4b
 
 
 
a1db0e9
 
 
 
 
 
 
 
b857620
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import gradio as gr
from dartrs.v2 import AspectRatioTag, LengthTag, RatingTag, IdentityTag

# from https://huggingface.co/spaces/cagliostrolab/animagine-xl-3.1/blob/main/config.py
QUALITY_TAGS = {
    "default": "(masterpiece), best quality, very aesthetic, perfect face",
}
NEGATIVE_PROMPT = {
    "default": "nsfw, (low quality, worst quality:1.2), very displeasing, 3d, watermark, signature, ugly, poorly drawn",
}


IMAGE_SIZE_OPTIONS = {
    "1536x640": "<|aspect_ratio:ultra_wide|>",
    "1344x768": "<|aspect_ratio:wide|>",
    "1024x1024": "<|aspect_ratio:square|>",
    "768x1344": "<|aspect_ratio:tall|>",
    "640x1536": "<|aspect_ratio:ultra_tall|>",
}
IMAGE_SIZES = {
    "1536x640": (1536, 640),
    "1344x768": (1344, 768),
    "1024x1024": (1024, 1024),
    "768x1344": (768, 1344),
    "640x1536": (640, 1536),
}

ASPECT_RATIO_OPTIONS: dict[str, AspectRatioTag] = {
    "ultra_wide": "<|aspect_ratio:ultra_wide|>",
    "wide": "<|aspect_ratio:wide|>",
    "square": "<|aspect_ratio:square|>",
    "tall": "<|aspect_ratio:tall|>",
    "ultra_tall": "<|aspect_ratio:ultra_tall|>",
}
RATING_OPTIONS: dict[str, RatingTag] = {
    "sfw": "<|rating:sfw|>",
    "general": "<|rating:general|>",
    "sensitive": "<|rating:sensitive|>",
    "nsfw": "<|rating:nsfw|>",
    "questionable": "<|rating:questionable|>",
    "explicit": "<|rating:explicit|>",
}
LENGTH_OPTIONS: dict[str, LengthTag] = {
    "very_short": "<|length:very_short|>",
    "short": "<|length:short|>",
    "medium": "<|length:medium|>",
    "long": "<|length:long|>",
    "very_long": "<|length:very_long|>",
}
IDENTITY_OPTIONS: dict[str, IdentityTag] = {
    "none": "<|identity:none|>",
    "lax": "<|identity:lax|>",
    "strict": "<|identity:strict|>",
}


PEOPLE_TAGS = [
    *[f"1{x}" for x in ["girl", "boy", "other"]],
    *[f"{i}girls" for i in range(2, 6)],
    *[f"6+{x}s" for x in ["girl", "boy", "other"]],
    "no humans",
]


# ref: https://qiita.com/tregu148/items/fccccbbc47d966dd2fc2
def gradio_copy_text(_text: None):
    gr.Info("Copied!")


COPY_ACTION_JS = """\
(inputs, _outputs) => {
  // inputs is the string value of the input_text
  if (inputs.trim() !== "") {
    navigator.clipboard.writeText(inputs);
  }
}"""