@@ -79,7 +79,7 @@ async def process_tags(gid,uid,tags,add_db=config['add_db'],trans=config['trans'
79
79
try :
80
80
tags = f"tags={ tags .strip ().lower ()} " #去除首尾空格换行#转小写#头部加上tags= #转小写方便处理
81
81
taglist = re .split ('&' ,tags ) #分割
82
- id = ["tags=" ,"ntags=" ,"seed=" ,"scale=" ,"shape=" ,"strength=" ,"r18=" ,"steps=" ,"sampler=" ,"restore_faces=" ,"tiling=" ]
82
+ id = ["tags=" ,"ntags=" ,"seed=" ,"scale=" ,"shape=" ,"strength=" ,"r18=" ,"steps=" ,"sampler=" ,"restore_faces=" ,"tiling=" , "bigger=" ]
83
83
tag_dict = {i : ("" if not [idx for idx in taglist if idx .startswith (i )] else [idx for idx in taglist if idx .startswith (i )][- 1 ]).replace (i , '' , 1 ) for i in id }#取出tags+ntags+seed+scale+shape,每种只取列表最后一个,并删掉id
84
84
except Exception as e :
85
85
error_msg = f"tags初始化失败{ e } "
@@ -141,6 +141,7 @@ async def process_tags(gid,uid,tags,add_db=config['add_db'],trans=config['trans'
141
141
tag_dict ["restore_faces=" ] = False #默认restore_faces
142
142
if not tag_dict ["tiling=" ] and tag_dict ["tiling=" ] != "True" :
143
143
tag_dict ["tiling=" ] = False #默认tiling
144
+ tag_dict ["bigger=" ] = False if not tag_dict ["bigger=" ] else True #默认bigger
144
145
#上传XP数据库
145
146
if add_db :
146
147
try :
@@ -208,6 +209,8 @@ async def get_imgdata_sd(tagdict:dict,way=1,shape="Portrait",b_io=None,size = No
208
209
width ,height = 768 ,512
209
210
elif shape == "Square" :
210
211
width ,height = 640 ,640
212
+ if tagdict ["bigger=" ]:
213
+ width ,height = width + 128 ,height + 128
211
214
url = f"{ config ['sd_api_ip' ]} /sdapi/v1/txt2img"
212
215
json_data = {
213
216
"enable_hr" : False ,
@@ -227,6 +230,15 @@ async def get_imgdata_sd(tagdict:dict,way=1,shape="Portrait",b_io=None,size = No
227
230
url = f"{ config ['sd_api_ip' ]} /sdapi/v1/img2img"
228
231
data = ["data:image/jpeg;base64," + base64 .b64encode (b_io .getvalue ()).decode ()]
229
232
width ,height = size
233
+ if tagdict ["bigger=" ]:
234
+ width ,height = width * 2 ,height * 2
235
+ c = width / height
236
+ n = 1000000 #最大像素
237
+ if width * height > n :
238
+ height = math .ceil (math .sqrt (n / c ))
239
+ width = math .ceil (c * height )
240
+ width = math .ceil (width / 64 )* 64
241
+ height = math .ceil (height / 64 )* 64 #等比缩放为64的倍数
230
242
if not tagdict ["strength=" ]:
231
243
tagdict ["strength=" ] = config ['strength_moren' ]#默认噪声
232
244
json_data = {
@@ -353,7 +365,7 @@ async def get_xp_pic_(msg,gid,uid):
353
365
async def get_pic_d (msg ):
354
366
error_msg = "" # 报错信息
355
367
try :
356
- image_url = re .search (r"\[CQ:image,file=(.*)url=(.*?)[,|\] ]" , str (msg ))
368
+ image_url = re .search (r"\[CQ:image,file=(.*)url=(.*?)[,\]; ]" , str (msg ))
357
369
url = image_url .group (2 )
358
370
except Exception as e :
359
371
error_msg = "你的图片呢?"
@@ -364,12 +376,6 @@ async def get_pic_d(msg):
364
376
a ,b = image .size
365
377
c = a / b
366
378
s = [0.6667 ,1.5 ,1 ]
367
- n = 1000000 #最大像素
368
- if a * b > n :
369
- b = math .ceil (math .sqrt (n / c ))
370
- a = math .ceil (c * b )
371
- a = math .ceil (a / 64 )* 64
372
- b = math .ceil (b / 64 )* 64 #等比缩放为64的倍数
373
379
size = (a ,b )
374
380
s1 = ["Portrait" ,"Landscape" ,"Square" ]
375
381
shape = s1 [s .index (nsmallest (1 , s , key = lambda x : abs (x - c ))[0 ])]#判断形状
0 commit comments