Skip to content
Merged

ф #4

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ __**mdl**
change model from list
__**smplr**
change sampler from list
__**sh**
change shedulers from list
__**hr**
change hr_upscale from list
__**prompt**
Expand Down
41 changes: 39 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def getAttrtxt2img():
data['prompt'] = 'cat in space' # Ý
data['steps'] = 15
data['sampler_name'] = 'Euler a'
data['scheduler'] = 'karras'
dataParams = {"img_thumb": "true",
"img_tg": "false",
"img_real": "true",
Expand Down Expand Up @@ -261,14 +262,15 @@ def get_prompt_settings(typeCode = 'HTML'):
steps = data['steps']
negative_prompt = data['negative_prompt'].replace('<', '&lt;').replace('>', '&gt;')
sampler_name = data['sampler_name']
scheduler = data['scheduler']
if sd == '❌':
sd_model_checkpoint = dataParams['sd_model_checkpoint']
else:
sd_model_checkpoint = api.get_options()['sd_model_checkpoint']
if typeCode == 'HTML':
txt = f"prompt = <code>{prompt}</code>\nsteps = {steps} \ncfg_scale = {cfg_scale} \nwidth = {width} \nheight = {height} \nsampler_name = {sampler_name} \nsd_model_checkpoint = {sd_model_checkpoint} \nnegative_prompt = <code>{negative_prompt}</code> "
txt = f"prompt = <code>{prompt}</code>\nsteps = {steps} \ncfg_scale = {cfg_scale} \nwidth = {width} \nheight = {height} \nsampler_name = {sampler_name} \nscheduler = {scheduler} \nsd_model_checkpoint = {sd_model_checkpoint} \nnegative_prompt = <code>{negative_prompt}</code> "
else:
txt = f"prompt = {prompt}\n\nsteps = {steps} cfg_scale = {cfg_scale} width = {width} height = {height} sampler_name = {sampler_name} sd_model_checkpoint = {sd_model_checkpoint} \n\nnegative_prompt = {negative_prompt} "
txt = f"prompt = {prompt}\n\nsteps = {steps} cfg_scale = {cfg_scale} width = {width} height = {height} sampler_name = {sampler_name} scheduler = {scheduler} sd_model_checkpoint = {sd_model_checkpoint} \n\nnegative_prompt = {negative_prompt} "
return txt

# Translate
Expand Down Expand Up @@ -504,6 +506,10 @@ def get_samplers_list():
samplers = api.get_samplers()
return set_array(samplers, 'name', 'samplers')

def get_schedulers_list():
schedulers = api.get_schedulers()
return set_array(schedulers, 'name', 'schedulers')

# get hr
def get_hr_list():
hrs = [str(choice.value) for choice in webuiapi.HiResUpscaler]
Expand Down Expand Up @@ -875,6 +881,7 @@ async def inl_fp(message: Union[types.Message, types.CallbackQuery]) -> None:
data['denoising_strength'] = '0.3'
data['steps'] = 15
data['sampler_name'] = 'DPM++ SDE Karras'
data['scheduler'] = 'karras'
data['cfg_scale'] = '4'
data['width'] = '1024'
data['height'] = '1024'
Expand Down Expand Up @@ -1120,6 +1127,22 @@ async def inl_smplr(message: Union[types.Message, types.CallbackQuery]) -> None:
keyboard = InlineKeyboardMarkup(inline_keyboard=[getOpt(0), getStart(0)])
await getKeyboardUnion("Turn on SD"+sd, message, keyboard)

# Вызов get_schedulers
@dp.message_handler(commands=["sh"])
@dp.message_handler(commands=["scheduler"])
@dp.callback_query_handler(text="sh")
async def inl_sh(message: Union[types.Message, types.CallbackQuery]) -> None:
logging.info("inl_sh")
global sd
if sd == '✅':
menu = get_schedulers_list()
menu.append(getOpt(0))
menu.append(getStart(0))
await getKeyboardUnion("schedulers", message, InlineKeyboardMarkup(inline_keyboard=menu))
else:
keyboard = InlineKeyboardMarkup(inline_keyboard=[getOpt(0), getStart(0)])
await getKeyboardUnion("Turn on SD"+sd, message, keyboard)

# Вызов get_hr_list
@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS or len(ALLOWED_USERS) == 0, commands=["hr"])
@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS or len(ALLOWED_USERS) == 0, commands=["hr_upscaler"])
Expand Down Expand Up @@ -1319,6 +1342,20 @@ async def inl_samplers(callback: types.CallbackQuery) -> None:
menu.append(getStart(0))
await getKeyboardUnion('Теперь сэмплер = ' + str(smplr), callback, InlineKeyboardMarkup(inline_keyboard=menu), '')

# тыкнули на шедулер
@dp.callback_query_handler(text_startswith="schedulers")
async def inl_schedulers(callback: types.CallbackQuery) -> None:
logging.info('inl_schedulers')
sh = callback.data.split("|")[1]
options = {}
options['scheduler'] = sh
api.set_options(options)
data['scheduler'] = sh # Ý
menu = get_schedulers_list()
menu.append(getOpt(0))
menu.append(getStart(0))
await getKeyboardUnion('Теперь scheduler = ' + str(sh), callback, InlineKeyboardMarkup(inline_keyboard=menu), '')

# тыкнули на hr_upscaler
@dp.callback_query_handler(text_startswith="hrs")
async def inl_hrs(callback: types.CallbackQuery) -> None:
Expand Down
Loading