ai621_new/res.py

85 lines
4.1 KiB
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from random import randint
from telethon.tl.custom import Button
params = {
'seed': {
'description': 'The seed is a number between 0 and 1000000. The seed defines the "shape" of the noise which will used to create the image(s).',
'default': (lambda: randint(0, 1000000)),
'transform': lambda x: int(x),
'checks': {
(lambda x: x < 1000000): 'The number must be less than 1000000',
(lambda x: x > 0): 'The number must be more than 0',
}
},
'image': {
'description': 'Upload an image, give me an e621 link or just delete the current one.',
'default': None,
'buttons': [Button.inline(f"🚫 No image", f"msg_but:no_image")]
},
'prompt': {
'description': 'Give me a list of e621 tags, a phrase or an e621 link to use as a prompt for your image. You can check which tags you can use over at https://ai621.foxo.me/test.html',
'default': None,
'transform': lambda x: x.strip(),
'checks': {
(lambda x: len(x) < 200): 'The prompt cannot be longer than 200 characters.',
(lambda x: len(x) > 32): 'The prompt cannot be shorter than 32 characters.',
(lambda x: ('🖼' in x) or ('👀' in x) or ('🌀' in x)): 'If you copy and paste other prompts, try to clean them from extra emojis and formatting.',
}
},
'negative_prompt': {
'description': 'This is the negative prompt. Use this to define what you <strong>don\'t</strong> want to see. ',
'default': None,
'transform': lambda x: x.strip(),
'checks': {
(lambda x: len(x) < 200): 'The neg prompt cannot be longer than 200 characters.',
(lambda x: len(x) > 16): 'The neg prompt cannot be shorter than 16 characters.',
(lambda x: ('🖼' in x) or ('👀' in x) or ('🌀' in x)): 'If you copy and paste other prompts, try to clean them from extra emojis and formatting.',
}
},
'number': {
'description': 'How many images would you like to receive?',
'default': 3,
'transform': lambda x: int(3),
'checks': {
(lambda x: x in [1,2,3,4]): 'You can only generate between 1 and 4 images.',
},
'buttons': [Button.inline(f"1", f"msg_but:1"), Button.inline(f"2", f"msg_but:2"), Button.inline(f"3", f"msg_but:3"), Button.inline(f"4", f"msg_but:4")],
},
'detail': {
'description': 'Detail (guidance scale) how heavily should the bot draw tags? This value should be between 2 and 20. (and a multiple of 0.1)',
'default': 6.9,
'transform': lambda x: round(float(x), 1),
'checks': {
(lambda x: len(x) < 20): 'The maximum for this value is 20.',
(lambda x: len(x) > 2): 'The minimum for this value is 2.',
},
'buttons': [Button.inline(f"S (3.0)", f"msg_but:3"), Button.inline(f"M (6.5)", f"msg_but:6.5"), Button.inline(f"L (9.0)", f"msg_but:9")],
},
'inference_steps': {
'description': 'Cycles (inference steps) how many times should we try to redraw the image before giving the result? Higher values = higher quality, but only when prompts are good.',
'default': 40,
'transform': lambda x: int(x),
'checks': {
(lambda x: len(x) < 200): 'The maximum for this value is 200.',
(lambda x: len(x) > 20): 'The minimum for this value is 20.',
},
'buttons': [Button.inline(f"S (20)", f"msg_but:20"), Button.inline(f"M (40)", f"msg_but:40"), Button.inline(f"L (60)", f"msg_but:60")],
},
'resolution': {
'description': 'Decide the aspect ratio and resolution of the final image.',
'default': '512x512',
'checks': {
(lambda x: x in ['512x512', '512x768', '768x512', '1024x512', '512x1024']): 'This resolution is invalid.'
},
'buttons': [[Button.inline(f"Potrait (512x768)", f"msg_but:512x768"), Button.inline(f"Landscape (768x512)", f"msg_but:768x512")],[Button.inline(f"Square (512x512)", f"msg_but:512x512")],[Button.inline(f"Ultrawide (1024x512)", f"msg_but:1024x512"), Button.inline(f"Ultratall (512x1024)", f"msg_but:512x1024")]]
},
'resolution': 'The width and height of the final image.',
'crop': 'Do you want to crop the base image so that it matches the generated image resolution?',
'hires': 'Do you want to receive a high res image at the end of the generation? (it will take more time)',
}
# 'blend': [Button.inline(f"S (0.3)", f"msg_but:0.3"), Button.inline(f"M (0.6)", f"msg_but:0.6"), Button.inline(f"L (0.8)", f"msg_but:0.8")],