Spaces:
Runtime error
Runtime error
File size: 23,188 Bytes
29b574d 38febe3 ee89b89 38febe3 35e2a53 38febe3 35e2a53 38febe3 35e2a53 38febe3 35e2a53 38febe3 828319c 38febe3 35e2a53 38febe3 35e2a53 38febe3 35e2a53 38febe3 35e2a53 38febe3 35e2a53 38febe3 6522dd8 38febe3 7531e70 38febe3 35e2a53 38febe3 35e2a53 38febe3 7531e70 38febe3 35e2a53 38febe3 35e2a53 38febe3 9534d17 38febe3 9534d17 38febe3 9534d17 7531e70 9534d17 38febe3 9534d17 d13ecf4 b0ac9df 38febe3 |
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
import discord
import os
from huggingface_hub import AsyncInferenceClient, login
import regex as re
import time
import requests
import json
import random
import asyncio
import typing
import gradio_client as grc
import gradio as gr
from multiprocessing import Process
os.mkdir("data")
# API
login(os.environ["HF_TOKEN"])
sd_turbo = "stabilityai/sd-turbo"
sdxl_turbo = "stabilityai/sd-turbo"
sdxl = "stabilityai/stable-diffusion-xl-base-1.0"
proteus = "dataautogpt3/ProteusV0.2"
sd_2_1 = "stabilityai/stable-diffusion-2-1"
open_journey = "prompthero/openjourney-v4"
SD = AsyncInferenceClient(model=sd_2_1)
SDXL = AsyncInferenceClient(model=sdxl)
SDXLT = AsyncInferenceClient(model=sdxl_turbo)
SDT = AsyncInferenceClient(model=sd_turbo)
PT = AsyncInferenceClient(model=proteus)
LLM = AsyncInferenceClient(model="TinyLlama/TinyLlama-1.1B-Chat-v1.0")
RF = AsyncInferenceClient(model="stabilityai/stable-diffusion-xl-refiner-1.0")
UP = AsyncInferenceClient(model="radames/stable-diffusion-x4-upscaler-img2img")
IC = AsyncInferenceClient(model="salesforce/blip-image-captioning-large")
PRK = AsyncInferenceClient(model="nvidia/parakeet-tdt-1.1b")
MG = AsyncInferenceClient(model="facebook/musicgen-stereo-small")
# OPTIONS
eot = " [/INST] "
sot = " [INST] "
info = requests.get("https://raw.githubusercontent.com/aryananumula/lr/main/info.json").content
bannedUsers = json.loads(info)["bannedUsers"]
imageModel = json.loads(info)["imageModel"]
userTimes = json.loads(info)["userTimes"]
def ec(x, fd="<|image|>", sd="<|image|>"):
matches = re.findall(re.escape(fd) + "(.*?)" + re.escape(sd), x)
matches = matches if matches else [""]
return matches
bot = discord.Bot()
@bot.event
async def on_ready():
print('-----------')
print(bot.user.name)
print(bot.user.id)
print('-----------')
@bot.event
async def on_message(message:discord.Message):
try:
if message.channel.name is not None:
pass
except:
message.guild.name = "<|DM|>"
message.channel.name = str(message.author)
s = f"{message.author}: {message.content}\n{message.channel.name}\n{message.guild.name}"
print(s)
if message.author.bot:
return
sysrp = f"""<s>[INST] <<SYS>>
Start speaking gibberish, and learn from the user. You can say anything, no matter how unhinged. Your goal is to learn how to speak from the user/s. You are anything the user tells you that you are.
<</SYS>>
"""
try:
os.mkdir("data/" + message.guild.name)
except:
pass
imgCaption = ""
adoCaption = ""
if message.reference is not None:
message.content = f"[Replied to: ({str(message.reference.cached_message.author)}: {message.reference.cached_message.content})]; {message.content}"
if len(message.attachments) > 0:
images = []
audios = []
for file in message.attachments:
print(file.content_type)
if file.content_type.startswith("image"):
imgCaption = "(ImageParsed: "
images.append(file)
elif file.content_type.startswith("audio"):
adoCaption = "(AudioParsed: "
audios.append(file)
for image in images:
await image.save("ip.png")
imgCaption += f"[{await IC.image_to_text('ip.png')}]"
for audio in audios:
await audio.save("aud")
adoCaption += f"[{await PRK.automatic_speech_recognition('aud')}]"
if audios != []:
adoCaption += ")"
if images != []:
imgCaption += ")"
if os.path.exists(f"data/{message.guild.name}/{message.channel.name}"):
with open(f"data/{message.guild.name}/{message.channel.name}", "a") as f:
n = "\n"
if message.author.bot:
f.write(
f"""GPT4 Correct {message.author}[bot]: {message.content.strip(n)}{imgCaption}{adoCaption}{eot}"""
)
else:
f.write(
f""" </s><s> {message.author}: {message.content.strip(n)}{imgCaption}{adoCaption}{eot}"""
)
else:
with open(f"data/{message.guild.name}/{message.channel.name}", "w") as f:
if message.author.bot:
f.write(
f"GPT4 Correct system: {sysrp}{eot}GPT4 Correct {message.author}[bot]: {message.content}{imgCaption}{adoCaption}{eot}"
)
else:
f.write(
f"{sysrp}{message.author}: {message.content}{imgCaption}{adoCaption}{eot}"
)
with open(f"data/{message.guild.name}/{message.channel.name}", "r") as f:
context = f.read()
try:
with open(f"{ctx.guild.name}.guild", "r") as f:
o = f.read()
except:
o = ""
if message.author.id in bannedUsers:
return 0
if (str(message.channel.id) in o.split("\n")) or (message.channel.name == "Direct") or True:
async with message.channel.typing():
# START LLM RESPONSE
context += f""
load = random.choice(
[
"https://cdn.dribbble.com/users/744913/screenshots/4094897/media/771a495231b798c0ccf7a59a19f31946.gif",
"https://cdn.dribbble.com/users/563824/screenshots/3633228/media/b620ccb3ae8c14ea5447d159ebb1da58.gif",
"https://cdn.dribbble.com/users/563824/screenshots/4155980/media/d3828cd14ed415eb6f90310991e06f27.gif",
"https://cdn.dribbble.com/users/107759/screenshots/3498589/media/5bc45101de34a80ea71238a02f3a75b5.gif",
]
)
imgn = random.choice(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ', 'CA', 'CB', 'CC', 'CD', 'CE', 'CF', 'CG', 'CH', 'CI', 'CJ', 'CK', 'CL', 'CM', 'CN', 'CO', 'CP', 'CQ', 'CR', 'CS', 'CT', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DA', 'DB', 'DC', 'DD', 'DE', 'DF', 'DG', 'DH', 'DI', 'DJ', 'DK', 'DL', 'DM', 'DN', 'DO', 'DP', 'DQ', 'DR', 'DS', 'DT', 'DU', 'DV', 'DW', 'DX', 'DY', 'DZ', 'EA', 'EB', 'EC', 'ED', 'EE', 'EF', 'EG', 'EH', 'EI', 'EJ', 'EK', 'EL', 'EM', 'EN', 'EO', 'EP', 'EQ', 'ER', 'ES', 'ET', 'EU', 'EV', 'EW', 'EX', 'EY', 'EZ', 'FA', 'FB', 'FC', 'FD', 'FE', 'FF', 'FG', 'FH', 'FI', 'FJ', 'FK', 'FL', 'FM', 'FN', 'FO', 'FP', 'FQ', 'FR', 'FS', 'FT', 'FU', 'FV', 'FW', 'FX', 'FY', 'FZ', 'GA', 'GB', 'GC', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GJ', 'GK', 'GL', 'GM', 'GN', 'GO', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GV', 'GW', 'GX', 'GY', 'GZ', 'HA', 'HB', 'HC', 'HD', 'HE', 'HF', 'HG', 'HH', 'HI', 'HJ', 'HK', 'HL', 'HM', 'HN', 'HO', 'HP', 'HQ', 'HR', 'HS', 'HT', 'HU', 'HV', 'HW', 'HX', 'HY', 'HZ', 'IA', 'IB', 'IC', 'ID', 'IE', 'IF', 'IG', 'IH', 'II', 'IJ', 'IK', 'IL', 'IM', 'IN', 'IO', 'IP', 'IQ', 'IR', 'IS', 'IT', 'IU', 'IV', 'IW', 'IX', 'IY', 'IZ', 'JA', 'JB', 'JC', 'JD', 'JE', 'JF', 'JG', 'JH', 'JI', 'JJ', 'JK', 'JL', 'JM', 'JN', 'JO', 'JP', 'JQ', 'JR', 'JS', 'JT', 'JU', 'JV', 'JW', 'JX', 'JY', 'JZ', 'KA', 'KB', 'KC', 'KD', 'KE', 'KF', 'KG', 'KH', 'KI', 'KJ', 'KK', 'KL', 'KM', 'KN', 'KO', 'KP', 'KQ', 'KR', 'KS', 'KT', 'KU', 'KV', 'KW', 'KX', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LD', 'LE', 'LF', 'LG', 'LH', 'LI', 'LJ', 'LK', 'LL', 'LM', 'LN', 'LO', 'LP', 'LQ', 'LR', 'LS', 'LT', 'LU', 'LV', 'LW', 'LX', 'LY', 'LZ', 'MA', 'MB', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MI', 'MJ', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NB', 'NC', 'ND', 'NE', 'NF', 'NG', 'NH', 'NI', 'NJ', 'NK', 'NL', 'NM', 'NN', 'NO', 'NP', 'NQ', 'NR', 'NS', 'NT', 'NU', 'NV', 'NW', 'NX', 'NY', 'NZ', 'OA', 'OB', 'OC', 'OD', 'OE', 'OF', 'OG', 'OH', 'OI', 'OJ', 'OK', 'OL', 'OM', 'ON', 'OO', 'OP', 'OQ', 'OR', 'OS', 'OT', 'OU', 'OV', 'OW', 'OX', 'OY', 'OZ', 'PA', 'PB', 'PC', 'PD', 'PE', 'PF', 'PG', 'PH', 'PI', 'PJ', 'PK', 'PL', 'PM', 'PN', 'PO', 'PP', 'PQ', 'PR', 'PS', 'PT', 'PU', 'PV', 'PW', 'PX', 'PY', 'PZ', 'QA', 'QB', 'QC', 'QD', 'QE', 'QF', 'QG', 'QH', 'QI', 'QJ', 'QK', 'QL', 'QM', 'QN', 'QO', 'QP', 'QQ', 'QR', 'QS', 'QT', 'QU', 'QV', 'QW', 'QX', 'QY', 'QZ', 'RA', 'RB', 'RC', 'RD', 'RE', 'RF', 'RG', 'RH', 'RI', 'RJ', 'RK', 'RL', 'RM', 'RN', 'RO', 'RP', 'RQ', 'RR', 'RS', 'RT', 'RU', 'RV', 'RW', 'RX', 'RY', 'RZ', 'SA', 'SB', 'SC', 'SD', 'SE', 'SF', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SP', 'SQ', 'SR', 'SS', 'ST', 'SU', 'SV', 'SW', 'SX', 'SY', 'SZ', 'TA', 'TB', 'TC', 'TD', 'TE', 'TF', 'TG', 'TH', 'TI', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TP', 'TQ', 'TR', 'TS', 'TT', 'TU', 'TV', 'TW', 'TX', 'TY', 'TZ', 'UA', 'UB', 'UC', 'UD', 'UE', 'UF', 'UG', 'UH', 'UI', 'UJ', 'UK', 'UL', 'UM', 'UN', 'UO', 'UP', 'UQ', 'UR', 'US', 'UT', 'UU', 'UV', 'UW', 'UX', 'UY', 'UZ', 'VA', 'VB', 'VC', 'VD', 'VE', 'VF', 'VG', 'VH', 'VI', 'VJ', 'VK', 'VL', 'VM', 'VN', 'VO', 'VP', 'VQ', 'VR', 'VS', 'VT', 'VU', 'VV', 'VW', 'VX', 'VY', 'VZ', 'WA', 'WB', 'WC', 'WD', 'WE', 'WF', 'WG', 'WH', 'WI', 'WJ', 'WK', 'WL', 'WM', 'WN', 'WO', 'WP', 'WQ', 'WR', 'WS', 'WT', 'WU', 'WV', 'WW', 'WX', 'WY', 'WZ', 'XA', 'XB', 'XC', 'XD', 'XE', 'XF', 'XG', 'XH', 'XI', 'XJ', 'XK', 'XL', 'XM', 'XN', 'XO', 'XP', 'XQ', 'XR', 'XS', 'XT', 'XU', 'XV', 'XW', 'XX', 'XY', 'XZ', 'YA', 'YB', 'YC', 'YD', 'YE', 'YF', 'YG', 'YH', 'YI', 'YJ', 'YK', 'YL', 'YM', 'YN', 'YO', 'YP', 'YQ', 'YR', 'YS', 'YT', 'YU', 'YV', 'YW', 'YX', 'YY', 'YZ', 'ZA', 'ZB', 'ZC', 'ZD', 'ZE', 'ZF', 'ZG', 'ZH', 'ZI', 'ZJ', 'ZK', 'ZL', 'ZM', 'ZN', 'ZO', 'ZP', 'ZQ', 'ZR', 'ZS', 'ZT', 'ZU', 'ZV', 'ZW', 'ZX', 'ZY', 'ZZ'])
output = await LLM.text_generation(context,
stop_sequences=["</s>"], max_new_tokens=1024)
title = ec(output, "<|title|>", "<|title|>")[0]
imgp = ec(output)[0]
mscp = ec(output, "<|music|>", "<|music|>")[0]
with open(f"data/{message.guild.name}/{message.channel.name}", "a") as f:
f.write(f"{output}")
embed = discord.Embed(title=title,
description=output.replace(
f"<|title|>{title}<|title|>", "").replace(f"<|image|>{imgp}<|image|>", ""),
color=0x1E81B0)
if imgp != "":
embed.set_image(url=load)
embed.set_footer(
text=
"""Creating..."""
)
else:
embed.set_footer(
text=
"""Information or code generated by Lyre may not always be correct. Lyre was made by Araeyn."""
)
e = await message.reply(embed=embed)
'''wds = output.split(" ")
for i in range(len(wds)):
title = ec(" ".join(wds[:i + 1]), "<|title|>", "<|title|>")[0]
imgp = ec(" ".join(wds[:i + 1]))[0]
embed = discord.Embed(title=title,
description=" ".join(wds[:i + 1]).replace(
f"<|title|>{title}<|title|>", "").replace(f"<|image|>{imgp}<|image|>", ""),
color=0x1E81B0)
if imgp != "":
embed.set_image(url=load)
embed.set_footer(
text=
"""Creating..."""
)
else:
embed.set_footer(
text=
"""Information or code generated by Lyre may not always be correct. Lyre was made by Araeyn."""
)
if i == 0:
e = await message.reply(embed=embed)
else:
await e.edit(embed=embed)
await asyncio.sleep(0.1)'''
if imgp != "":
np = """lowres, error, cropped, worst quality, low quality, ugly, duplicate, morbid, mutilated, out of frame, blurry, watermark, signature"""
st = time.time()
if imageModel == "Stable Diffusion 2-1":
image, m = (await SD.text_to_image(imgp, negative_prompt=np, num_inference_steps=70), "Stable Diffusion 2-1")
elif imageModel == "stable-diffusion-xl-base-1.0":
image, m = (await SDXL.text_to_image(imgp, negative_prompt=np, num_inference_steps=70), "stable-diffusion-xl-base-1.0")
elif imageModel == "sdxl-turbo":
image, m = (await SDXLT.text_to_image(imgp, negative_prompt=np, num_inference_steps=70, guidance_scale=0.0), "sdxl-turbo")
elif imageModel == "sd-turbo":
image, m = (await SDT.text_to_image(imgp, negative_prompt=np, num_inference_steps=70, guidance_scale=0.0), "sd-turbo")
elif imageModel == "Proteus v0.2":
image, m = (await PT.text_to_image(imgp, negative_prompt=np, num_inference_steps=35), "Proteus v0.2")
else:
raise NotImplementedError(f"Model {imageModel} not found. Report this to @araeyn if this keeps happening.")
image.save(f"{imgn}.png")
file = discord.File(f"{imgn}.png", filename=f"{imgn}.png", description=imgp)
embed.set_image(url=f"attachment://{imgn}.png")
embed.set_footer(
text=
"""Refining..."""
)
await e.edit(embed=embed, attachments=[file])
gt = time.time()
image, r = (await RF.image_to_image(f"{imgn}.png", num_inference_steps=35, prompt=imgp, negative_prompt=np), "stable-diffusion-xl-refiner-1.0")
rt = time.time()
embed.set_footer(
text=
f"Image generation model is {m}. Refiner model is {r}. Took {round((gt - st) * 100) / 100} seconds to generate. Took {round((rt - gt) * 100) / 100} seconds to refine."
)
image.save(f"{imgn}.png")
file = discord.File(f"{imgn}.png", filename=f"{imgn}.png")
embed.set_image(url=f"attachment://{imgn}.png")
await e.edit(embed=embed, attachments=[file])
@bot.command(description="Start a chatbot conversation in the channel.")
async def setup(ctx:discord.ApplicationContext):
with open(f"{ctx.guild.name}.guild", "a") as f:
f.write(f"{ctx.channel.id}\n")
embed = discord.Embed(title="setup", description=f"You can now chat with the bot in <#{ctx.channel.id}>")
await ctx.respond(embed=embed)
@bot.command(name="reset", description="Reset the chat history of a channel.")
@discord.commands.option(
"sys",
description="The new system prompt.",
required=False,
default=sysp
)
async def reset(ctx:discord.ApplicationContext, sys:str):
with open(f"data/{ctx.guild.name}/{ctx.channel.name}", "w") as f:
f.write(f"{sot}system: {sys}{eot}")
if sys == sysrp:
embed = discord.Embed(title="reset", description=f"Reset the channel history with default system prompt.")
else:
embed = discord.Embed(title="reset", description=f"Reset the channel history with custom system prompt.\n```\n{sys}```")
await ctx.respond(embed=embed)
@bot.command(name="create", description="Create an image using a specified model. Defaults to sdxl-turbo.")
@discord.commands.option(
"prompt",
description="The prompt for the image.",
required=True,
)
@discord.commands.option(
"model",
description="The model to use.",
required=False,
choices=["Stable Diffusion 2-1", "stable-diffusion-xl-base-1.0", "sdxl-turbo", "sd-turbo"],
default="sdxl-turbo"
)
@discord.commands.option(
"negative",
description="The negative prompt for the image. Defaults to None.",
required=False,
default=""
)
@discord.commands.option(
"steps",
description="The amount of steps for image generation. Range: 1 - 70.",
required=False,
default=35
)
async def create(ctx:discord.ApplicationContext, prompt:str, negative:str, steps:int, model:str):
refine = True
await ctx.defer()
st = time.time()
imgn = random.choice(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ', 'CA', 'CB', 'CC', 'CD', 'CE', 'CF', 'CG', 'CH', 'CI', 'CJ', 'CK', 'CL', 'CM', 'CN', 'CO', 'CP', 'CQ', 'CR', 'CS', 'CT', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DA', 'DB', 'DC', 'DD', 'DE', 'DF', 'DG', 'DH', 'DI', 'DJ', 'DK', 'DL', 'DM', 'DN', 'DO', 'DP', 'DQ', 'DR', 'DS', 'DT', 'DU', 'DV', 'DW', 'DX', 'DY', 'DZ', 'EA', 'EB', 'EC', 'ED', 'EE', 'EF', 'EG', 'EH', 'EI', 'EJ', 'EK', 'EL', 'EM', 'EN', 'EO', 'EP', 'EQ', 'ER', 'ES', 'ET', 'EU', 'EV', 'EW', 'EX', 'EY', 'EZ', 'FA', 'FB', 'FC', 'FD', 'FE', 'FF', 'FG', 'FH', 'FI', 'FJ', 'FK', 'FL', 'FM', 'FN', 'FO', 'FP', 'FQ', 'FR', 'FS', 'FT', 'FU', 'FV', 'FW', 'FX', 'FY', 'FZ', 'GA', 'GB', 'GC', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GJ', 'GK', 'GL', 'GM', 'GN', 'GO', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GV', 'GW', 'GX', 'GY', 'GZ', 'HA', 'HB', 'HC', 'HD', 'HE', 'HF', 'HG', 'HH', 'HI', 'HJ', 'HK', 'HL', 'HM', 'HN', 'HO', 'HP', 'HQ', 'HR', 'HS', 'HT', 'HU', 'HV', 'HW', 'HX', 'HY', 'HZ', 'IA', 'IB', 'IC', 'ID', 'IE', 'IF', 'IG', 'IH', 'II', 'IJ', 'IK', 'IL', 'IM', 'IN', 'IO', 'IP', 'IQ', 'IR', 'IS', 'IT', 'IU', 'IV', 'IW', 'IX', 'IY', 'IZ', 'JA', 'JB', 'JC', 'JD', 'JE', 'JF', 'JG', 'JH', 'JI', 'JJ', 'JK', 'JL', 'JM', 'JN', 'JO', 'JP', 'JQ', 'JR', 'JS', 'JT', 'JU', 'JV', 'JW', 'JX', 'JY', 'JZ', 'KA', 'KB', 'KC', 'KD', 'KE', 'KF', 'KG', 'KH', 'KI', 'KJ', 'KK', 'KL', 'KM', 'KN', 'KO', 'KP', 'KQ', 'KR', 'KS', 'KT', 'KU', 'KV', 'KW', 'KX', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LD', 'LE', 'LF', 'LG', 'LH', 'LI', 'LJ', 'LK', 'LL', 'LM', 'LN', 'LO', 'LP', 'LQ', 'LR', 'LS', 'LT', 'LU', 'LV', 'LW', 'LX', 'LY', 'LZ', 'MA', 'MB', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MI', 'MJ', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NB', 'NC', 'ND', 'NE', 'NF', 'NG', 'NH', 'NI', 'NJ', 'NK', 'NL', 'NM', 'NN', 'NO', 'NP', 'NQ', 'NR', 'NS', 'NT', 'NU', 'NV', 'NW', 'NX', 'NY', 'NZ', 'OA', 'OB', 'OC', 'OD', 'OE', 'OF', 'OG', 'OH', 'OI', 'OJ', 'OK', 'OL', 'OM', 'ON', 'OO', 'OP', 'OQ', 'OR', 'OS', 'OT', 'OU', 'OV', 'OW', 'OX', 'OY', 'OZ', 'PA', 'PB', 'PC', 'PD', 'PE', 'PF', 'PG', 'PH', 'PI', 'PJ', 'PK', 'PL', 'PM', 'PN', 'PO', 'PP', 'PQ', 'PR', 'PS', 'PT', 'PU', 'PV', 'PW', 'PX', 'PY', 'PZ', 'QA', 'QB', 'QC', 'QD', 'QE', 'QF', 'QG', 'QH', 'QI', 'QJ', 'QK', 'QL', 'QM', 'QN', 'QO', 'QP', 'QQ', 'QR', 'QS', 'QT', 'QU', 'QV', 'QW', 'QX', 'QY', 'QZ', 'RA', 'RB', 'RC', 'RD', 'RE', 'RF', 'RG', 'RH', 'RI', 'RJ', 'RK', 'RL', 'RM', 'RN', 'RO', 'RP', 'RQ', 'RR', 'RS', 'RT', 'RU', 'RV', 'RW', 'RX', 'RY', 'RZ', 'SA', 'SB', 'SC', 'SD', 'SE', 'SF', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SP', 'SQ', 'SR', 'SS', 'ST', 'SU', 'SV', 'SW', 'SX', 'SY', 'SZ', 'TA', 'TB', 'TC', 'TD', 'TE', 'TF', 'TG', 'TH', 'TI', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TP', 'TQ', 'TR', 'TS', 'TT', 'TU', 'TV', 'TW', 'TX', 'TY', 'TZ', 'UA', 'UB', 'UC', 'UD', 'UE', 'UF', 'UG', 'UH', 'UI', 'UJ', 'UK', 'UL', 'UM', 'UN', 'UO', 'UP', 'UQ', 'UR', 'US', 'UT', 'UU', 'UV', 'UW', 'UX', 'UY', 'UZ', 'VA', 'VB', 'VC', 'VD', 'VE', 'VF', 'VG', 'VH', 'VI', 'VJ', 'VK', 'VL', 'VM', 'VN', 'VO', 'VP', 'VQ', 'VR', 'VS', 'VT', 'VU', 'VV', 'VW', 'VX', 'VY', 'VZ', 'WA', 'WB', 'WC', 'WD', 'WE', 'WF', 'WG', 'WH', 'WI', 'WJ', 'WK', 'WL', 'WM', 'WN', 'WO', 'WP', 'WQ', 'WR', 'WS', 'WT', 'WU', 'WV', 'WW', 'WX', 'WY', 'WZ', 'XA', 'XB', 'XC', 'XD', 'XE', 'XF', 'XG', 'XH', 'XI', 'XJ', 'XK', 'XL', 'XM', 'XN', 'XO', 'XP', 'XQ', 'XR', 'XS', 'XT', 'XU', 'XV', 'XW', 'XX', 'XY', 'XZ', 'YA', 'YB', 'YC', 'YD', 'YE', 'YF', 'YG', 'YH', 'YI', 'YJ', 'YK', 'YL', 'YM', 'YN', 'YO', 'YP', 'YQ', 'YR', 'YS', 'YT', 'YU', 'YV', 'YW', 'YX', 'YY', 'YZ', 'ZA', 'ZB', 'ZC', 'ZD', 'ZE', 'ZF', 'ZG', 'ZH', 'ZI', 'ZJ', 'ZK', 'ZL', 'ZM', 'ZN', 'ZO', 'ZP', 'ZQ', 'ZR', 'ZS', 'ZT', 'ZU', 'ZV', 'ZW', 'ZX', 'ZY', 'ZZ'])
if not 1 <= steps <= 70:
embed = discord.Embed(title="Invalid Step Count", description=f"Please enter a number between 1 and 70.")
await ctx.respond(embed=embed)
return
if model == "Stable Diffusion 2-1":
image, m = (await SD.text_to_image(prompt=prompt, negative_prompt=negative, num_inference_steps=steps), "Stable Diffusion 2-1")
elif model == "stable-diffusion-xl-base-1.0":
image, m = (await SDXL.text_to_image(prompt=prompt, negative_prompt=negative, num_inference_steps=steps), "stable-diffusion-xl-base-1.0")
elif model == "sdxl-turbo":
image, m = (await SDXLT.text_to_image(prompt=prompt, negative_prompt=negative, num_inference_steps=steps, guidance_scale=0.0), "sdxl-turbo")
elif model == "sd-turbo":
image, m = (await SDT.text_to_image(prompt=prompt, negative_prompt=negative, num_inference_steps=steps, guidance_scale=0.0), "sd-turbo")
elif model == "Proteus v0.2":
image, m = (await PT.text_to_image(prompt=prompt, negative_prompt=negative, num_inference_steps=steps), "Proteus v0.2")
else:
raise NotImplementedError(f"Model {imageModel} not found. Report this to @araeyn if this keeps happening.")
embed = discord.Embed(title="create", description=f"```\n{prompt}\n```")
image.save(f"{imgn}.png")
file = discord.File(f"{imgn}.png", filename=f"{imgn}.png", description=prompt)
embed.set_image(url=f"attachment://{imgn}.png")
gt = time.time()
image, r = (await RF.image_to_image(f"{imgn}.png", num_inference_steps=35, prompt=prompt, negative_prompt=negative), "stable-diffusion-xl-refiner-1.0")
rt = time.time()
if refine:
embed.set_footer(
text=
f"Image generation model is {m}. Refiner model is {r}. Took {round((gt - st) * 100) / 100} seconds to generate. Took {round((rt - gt) * 100) / 100} seconds to refine."
)
else:
embed.set_footer(
text=
f"Image generation model is {m}. Took {round((gt - st) * 100) / 100} seconds to generate."
)
image.save(f"{imgn}.png")
file = discord.File(f"{imgn}.png", filename=f"{imgn}.png")
embed.set_image(url=f"attachment://{imgn}.png")
await ctx.respond(embed=embed, file=file)
def greet(name, intensity):
return "Hello, " + name + "!" * int(intensity)
demo = gr.Interface(
fn=greet,
inputs=["text", "slider"],
outputs=["text"],
)
Process(target=demo.launch, kwargs={"auth":("araeyn", "araeyn")}).start()
Process(target=bot.run, args=[os.environ.get("TOKEN")]).start() |