mirror of https://github.com/skygpu/skynet.git
492 lines
14 KiB
Python
Executable File
492 lines
14 KiB
Python
Executable File
from skynet.types import ModelDesc
|
||
|
||
VERSION = '0.1a13'
|
||
|
||
DOCKER_RUNTIME_CUDA = 'skynet:runtime-cuda'
|
||
|
||
MODELS: dict[str, ModelDesc] = {
|
||
'RealESRGAN_x4plus': ModelDesc(
|
||
short='realesrgan',
|
||
mem=4,
|
||
attrs={},
|
||
tags=['upscale']
|
||
),
|
||
'runwayml/stable-diffusion-v1-5': ModelDesc(
|
||
short='stable',
|
||
mem=6,
|
||
attrs={'size': {'w': 512, 'h': 512}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
'stabilityai/stable-diffusion-2-1-base': ModelDesc(
|
||
short='stable2',
|
||
mem=6,
|
||
attrs={'size': {'w': 512, 'h': 512}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
'snowkidy/stable-diffusion-xl-base-0.9': ModelDesc(
|
||
short='stablexl0.9',
|
||
mem=8.3,
|
||
attrs={'size': {'w': 1024, 'h': 1024}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
'Linaqruf/anything-v3.0': ModelDesc(
|
||
short='hdanime',
|
||
mem=6,
|
||
attrs={'size': {'w': 512, 'h': 512}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
'hakurei/waifu-diffusion': ModelDesc(
|
||
short='waifu',
|
||
mem=6,
|
||
attrs={'size': {'w': 512, 'h': 512}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
'nitrosocke/Ghibli-Diffusion': ModelDesc(
|
||
short='ghibli',
|
||
mem=6,
|
||
attrs={'size': {'w': 512, 'h': 512}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
'dallinmackay/Van-Gogh-diffusion': ModelDesc(
|
||
short='van-gogh',
|
||
mem=6,
|
||
attrs={'size': {'w': 512, 'h': 512}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
'lambdalabs/sd-pokemon-diffusers': ModelDesc(
|
||
short='pokemon',
|
||
mem=6,
|
||
attrs={'size': {'w': 512, 'h': 512}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
'Envvi/Inkpunk-Diffusion': ModelDesc(
|
||
short='ink',
|
||
mem=6,
|
||
attrs={'size': {'w': 512, 'h': 512}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
'nousr/robo-diffusion': ModelDesc(
|
||
short='robot',
|
||
mem=6,
|
||
attrs={'size': {'w': 512, 'h': 512}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
'black-forest-labs/FLUX.1-schnell': ModelDesc(
|
||
short='flux',
|
||
mem=24,
|
||
attrs={'size': {'w': 1024, 'h': 1024}, 'step': 4},
|
||
tags=['txt2img']
|
||
),
|
||
'black-forest-labs/FLUX.1-Fill-dev': ModelDesc(
|
||
short='flux-inpaint',
|
||
mem=24,
|
||
attrs={'size': {'w': 1024, 'h': 1024}, 'step': 28},
|
||
tags=['inpaint']
|
||
),
|
||
'diffusers/stable-diffusion-xl-1.0-inpainting-0.1': ModelDesc(
|
||
short='stablexl-inpaint',
|
||
mem=8.3,
|
||
attrs={'size': {'w': 1024, 'h': 1024}, 'step': 28},
|
||
tags=['inpaint']
|
||
),
|
||
'prompthero/openjourney': ModelDesc(
|
||
short='midj',
|
||
mem=6,
|
||
attrs={'size': {'w': 512, 'h': 512}, 'step': 28},
|
||
tags=['txt2img', 'img2img']
|
||
),
|
||
'stabilityai/stable-diffusion-xl-base-1.0': ModelDesc(
|
||
short='stablexl',
|
||
mem=8.3,
|
||
attrs={'size': {'w': 1024, 'h': 1024}, 'step': 28},
|
||
tags=['txt2img']
|
||
),
|
||
}
|
||
|
||
SHORT_NAMES = [
|
||
model_info.short
|
||
for model_info in MODELS.values()
|
||
]
|
||
|
||
def get_model_by_shortname(short: str):
|
||
for model, info in MODELS.items():
|
||
if short == info.short:
|
||
return model
|
||
|
||
N = '\n'
|
||
HELP_TEXT = f'''
|
||
test art bot v{VERSION}
|
||
|
||
commands work on a user per user basis!
|
||
config is individual to each user!
|
||
|
||
/txt2img TEXT - request an image based on a prompt
|
||
/img2img <attach_image> TEXT - request an image base on an image and a prompt
|
||
|
||
/redo - redo last command (only works for txt2img for now!)
|
||
|
||
/help step - get info on step config option
|
||
/help guidance - get info on guidance config option
|
||
|
||
/cool - list of cool words to use
|
||
/stats - user statistics
|
||
/donate - see donation info
|
||
|
||
/config algo NAME - select AI to use one of:
|
||
/config model NAME - select AI to use one of:
|
||
|
||
{N.join(SHORT_NAMES)}
|
||
|
||
/config step NUMBER - set amount of iterations
|
||
/config seed [auto|NUMBER] - set the seed, deterministic results!
|
||
/config width NUMBER - set horizontal size in pixels
|
||
/config height NUMBER - set vertical size in pixels
|
||
/config upscaler [off/x4] - enable/disable x4 size upscaler
|
||
/config guidance NUMBER - prompt text importance
|
||
/config strength NUMBER - importance of the input image for img2img
|
||
'''
|
||
|
||
UNKNOWN_CMD_TEXT = 'Unknown command! Try sending \"/help\"'
|
||
|
||
DONATION_INFO = '0xf95335682DF281FFaB7E104EB87B69625d9622B6\ngoal: 0.0465/1.0000 ETH'
|
||
|
||
COOL_WORDS = [
|
||
'cyberpunk',
|
||
'soviet propaganda poster',
|
||
'rastafari',
|
||
'cannabis',
|
||
'art deco',
|
||
'H R Giger Necronom IV',
|
||
'dimethyltryptamine',
|
||
'lysergic',
|
||
'slut',
|
||
'psilocybin',
|
||
'trippy',
|
||
'lucy in the sky with diamonds',
|
||
'fractal',
|
||
'da vinci',
|
||
'pencil illustration',
|
||
'blueprint',
|
||
'internal diagram',
|
||
'baroque',
|
||
'the last judgment',
|
||
'michelangelo'
|
||
]
|
||
|
||
CLEAN_COOL_WORDS = [
|
||
'cyberpunk',
|
||
'soviet propaganda poster',
|
||
'rastafari',
|
||
'cannabis',
|
||
'art deco',
|
||
'H R Giger Necronom IV',
|
||
'dimethyltryptamine',
|
||
'lysergic',
|
||
'psilocybin',
|
||
'trippy',
|
||
'lucy in the sky with diamonds',
|
||
'fractal',
|
||
'da vinci',
|
||
'pencil illustration',
|
||
'blueprint',
|
||
'internal diagram',
|
||
'baroque',
|
||
'the last judgment',
|
||
'michelangelo'
|
||
]
|
||
|
||
HELP_TOPICS = {
|
||
'step': '''
|
||
Diffusion models are iterative processes – a repeated cycle that starts with a\
|
||
random noise generated from text input. With each step, some noise is removed\
|
||
, resulting in a higher-quality image over time. The repetition stops when the\
|
||
desired number of steps completes.
|
||
|
||
Around 25 sampling steps are usually enough to achieve high-quality images. Us\
|
||
ing more may produce a slightly different picture, but not necessarily better \
|
||
quality.
|
||
''',
|
||
|
||
'guidance': '''
|
||
The guidance scale is a parameter that controls how much the image generation\
|
||
process follows the text prompt. The higher the value, the more image sticks\
|
||
to a given text input. Value range 0 to 20. Recomended range: 4.5-7.5.
|
||
''',
|
||
|
||
'strength': '''
|
||
Noise is added to the image you use as an init image for img2img, and then the\
|
||
diffusion process continues according to the prompt. The amount of noise added\
|
||
depends on the \"Strength of img2img\"” parameter, which ranges from 0 to 1,\
|
||
where 0 adds no noise at all and you will get the exact image you added, and\
|
||
1 completely replaces the image with noise and almost acts as if you used\
|
||
normal txt2img instead of img2img.
|
||
'''
|
||
}
|
||
|
||
HELP_UNKWNOWN_PARAM = 'don\'t have any info on that.'
|
||
|
||
MP_ENABLED_ROLES = ['god']
|
||
|
||
MIN_STEP = 1
|
||
MAX_STEP = 100
|
||
MAX_WIDTH = 1024
|
||
MAX_HEIGHT = 1024
|
||
MAX_GUIDANCE = 20
|
||
|
||
DEFAULT_SEED = None
|
||
DEFAULT_WIDTH = 1024
|
||
DEFAULT_HEIGHT = 1024
|
||
DEFAULT_GUIDANCE = 7.5
|
||
DEFAULT_STRENGTH = 0.5
|
||
DEFAULT_STEP = 28
|
||
DEFAULT_CREDITS = 10
|
||
DEFAULT_MODEL = list(MODELS.keys())[-1]
|
||
DEFAULT_ROLE = 'pleb'
|
||
DEFAULT_UPSCALER = None
|
||
|
||
DEFAULT_CONFIG_PATH = 'skynet.toml'
|
||
|
||
DEFAULT_INITAL_MODEL = list(MODELS.keys())[-1]
|
||
|
||
DATE_FORMAT = '%B the %dth %Y, %H:%M:%S'
|
||
|
||
CONFIG_ATTRS = [
|
||
'algo',
|
||
'step',
|
||
'width',
|
||
'height',
|
||
'seed',
|
||
'guidance',
|
||
'strength',
|
||
'upscaler'
|
||
]
|
||
|
||
DEFAULT_EXPLORER_DOMAIN = 'explorer.skygpu.net'
|
||
DEFAULT_IPFS_DOMAIN = 'ipfs.skygpu.net'
|
||
|
||
DEFAULT_IPFS_REMOTE = '/ip4/169.197.140.154/tcp/4001/p2p/12D3KooWKWogLFNEcNNMKnzU7Snrnuj84RZdMBg3sLiQSQc51oEv'
|
||
DEFAULT_IPFS_LOCAL = 'http://127.0.0.1:5001'
|
||
|
||
TG_MAX_WIDTH = 1280
|
||
TG_MAX_HEIGHT = 1280
|
||
|
||
DEFAULT_SINGLE_CARD_MAP = 'cuda:0'
|
||
|
||
GPU_CONTRACT_ABI = {
|
||
"version": "eosio::abi/1.2",
|
||
"types": [],
|
||
"structs": [
|
||
{
|
||
"name": "account",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "user", "type": "name"},
|
||
{"name": "balance", "type": "asset"},
|
||
{"name": "nonce", "type": "uint64"}
|
||
]
|
||
},
|
||
{
|
||
"name": "card",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "id", "type": "uint64"},
|
||
{"name": "owner", "type": "name"},
|
||
{"name": "card_name", "type": "string"},
|
||
{"name": "version", "type": "string"},
|
||
{"name": "total_memory", "type": "uint64"},
|
||
{"name": "mp_count", "type": "uint32"},
|
||
{"name": "extra", "type": "string"}
|
||
]
|
||
},
|
||
{
|
||
"name": "clean",
|
||
"base": "",
|
||
"fields": []
|
||
},
|
||
{
|
||
"name": "config",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "token_contract", "type": "name"},
|
||
{"name": "token_symbol", "type": "symbol"}
|
||
]
|
||
},
|
||
{
|
||
"name": "dequeue",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "user", "type": "name"},
|
||
{"name": "request_id", "type": "uint64"}
|
||
]
|
||
},
|
||
{
|
||
"name": "enqueue",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "user", "type": "name"},
|
||
{"name": "request_body", "type": "string"},
|
||
{"name": "binary_data", "type": "string"},
|
||
{"name": "reward", "type": "asset"},
|
||
{"name": "min_verification", "type": "uint32"}
|
||
]
|
||
},
|
||
{
|
||
"name": "gcfgstruct",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "token_contract", "type": "name"},
|
||
{"name": "token_symbol", "type": "symbol"}
|
||
]
|
||
},
|
||
{
|
||
"name": "submit",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "worker", "type": "name"},
|
||
{"name": "request_id", "type": "uint64"},
|
||
{"name": "request_hash", "type": "checksum256"},
|
||
{"name": "result_hash", "type": "checksum256"},
|
||
{"name": "ipfs_hash", "type": "string"}
|
||
]
|
||
},
|
||
{
|
||
"name": "withdraw",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "user", "type": "name"},
|
||
{"name": "quantity", "type": "asset"}
|
||
]
|
||
},
|
||
{
|
||
"name": "work_request_struct",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "id", "type": "uint64"},
|
||
{"name": "user", "type": "name"},
|
||
{"name": "reward", "type": "asset"},
|
||
{"name": "min_verification", "type": "uint32"},
|
||
{"name": "nonce", "type": "uint64"},
|
||
{"name": "body", "type": "string"},
|
||
{"name": "binary_data", "type": "string"},
|
||
{"name": "timestamp", "type": "time_point_sec"}
|
||
]
|
||
},
|
||
{
|
||
"name": "work_result_struct",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "id", "type": "uint64"},
|
||
{"name": "request_id", "type": "uint64"},
|
||
{"name": "user", "type": "name"},
|
||
{"name": "worker", "type": "name"},
|
||
{"name": "result_hash", "type": "checksum256"},
|
||
{"name": "ipfs_hash", "type": "string"},
|
||
{"name": "submited", "type": "time_point_sec"}
|
||
]
|
||
},
|
||
{
|
||
"name": "workbegin",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "worker", "type": "name"},
|
||
{"name": "request_id", "type": "uint64"},
|
||
{"name": "max_workers", "type": "uint32"}
|
||
]
|
||
},
|
||
{
|
||
"name": "workcancel",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "worker", "type": "name"},
|
||
{"name": "request_id", "type": "uint64"},
|
||
{"name": "reason", "type": "string"}
|
||
]
|
||
},
|
||
{
|
||
"name": "worker",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "account", "type": "name"},
|
||
{"name": "joined", "type": "time_point_sec"},
|
||
{"name": "left", "type": "time_point_sec"},
|
||
{"name": "url", "type": "string"}
|
||
]
|
||
},
|
||
{
|
||
"name": "worker_status_struct",
|
||
"base": "",
|
||
"fields": [
|
||
{"name": "worker", "type": "name"},
|
||
{"name": "status", "type": "string"},
|
||
{"name": "started", "type": "time_point_sec"}
|
||
]
|
||
}
|
||
],
|
||
"actions": [
|
||
{"name": "clean", "type": "clean", "ricardian_contract": ""},
|
||
{"name": "config", "type": "config", "ricardian_contract": ""},
|
||
{"name": "dequeue", "type": "dequeue", "ricardian_contract": ""},
|
||
{"name": "enqueue", "type": "enqueue", "ricardian_contract": ""},
|
||
{"name": "submit", "type": "submit", "ricardian_contract": ""},
|
||
{"name": "withdraw", "type": "withdraw", "ricardian_contract": ""},
|
||
{"name": "workbegin", "type": "workbegin", "ricardian_contract": ""},
|
||
{"name": "workcancel", "type": "workcancel", "ricardian_contract": ""}
|
||
],
|
||
"tables": [
|
||
{
|
||
"name": "cards",
|
||
"index_type": "i64",
|
||
"key_names": [],
|
||
"key_types": [],
|
||
"type": "card"
|
||
},
|
||
{
|
||
"name": "gcfgstruct",
|
||
"index_type": "i64",
|
||
"key_names": [],
|
||
"key_types": [],
|
||
"type": "gcfgstruct"
|
||
},
|
||
{
|
||
"name": "queue",
|
||
"index_type": "i64",
|
||
"key_names": [],
|
||
"key_types": [],
|
||
"type": "work_request_struct"
|
||
},
|
||
{
|
||
"name": "results",
|
||
"index_type": "i64",
|
||
"key_names": [],
|
||
"key_types": [],
|
||
"type": "work_result_struct"
|
||
},
|
||
{
|
||
"name": "status",
|
||
"index_type": "i64",
|
||
"key_names": [],
|
||
"key_types": [],
|
||
"type": "worker_status_struct"
|
||
},
|
||
{
|
||
"name": "users",
|
||
"index_type": "i64",
|
||
"key_names": [],
|
||
"key_types": [],
|
||
"type": "account"
|
||
},
|
||
{
|
||
"name": "workers",
|
||
"index_type": "i64",
|
||
"key_names": [],
|
||
"key_types": [],
|
||
"type": "worker"
|
||
}
|
||
],
|
||
"ricardian_clauses": [],
|
||
"error_messages": [],
|
||
"abi_extensions": [],
|
||
"variants": [],
|
||
"action_results": []
|
||
}
|