Update aiutils.py

This commit is contained in:
Abhi
2024-08-17 13:37:45 +05:30
committed by GitHub
parent 06af0febb3
commit 5172101e6a

View File

@@ -611,87 +611,6 @@ async def vkxl(c: Client, message: Message):
await message.edit_text(f"An error occurred: {format_exc(e)}")
@Client.on_message(filters.command("vfxl", prefix) & filters.me)
async def vfxl(c: Client, message: Message):
"""Text to Image Generation Using SDXL"""
await message.edit_text("<code>Please Wait...</code>")
try:
chat_id = message.chat.id
model_category = "FLUX.1"
models = await fetch_models(category=model_category)
if not message.reply_to_message and len(message.command) > 2:
model_found = False
for m in models:
if message.text.startswith(f"{prefix}vdxl {m}"):
model = m
prompt = message.text[len(f"{prefix}vdxl {m}") :].strip()
model_found = True
break
if not model_found:
return await message.edit_text(
f"<b>Usage: </b><code>{prefix}vdxl [model]* [prompt/reply to prompt]*</code>\n <b>Available Models:</b> <blockquote>{models}</blockquote>"
)
elif message.reply_to_message and len(message.command) > 1:
model = message.text.split(maxsplit=1)[1]
print(model)
if model in models:
prompt = message.reply_to_message.text
else:
return await message.edit_text(
f"<b>Usage: </b><code>{prefix}vdxl [model]* [prompt/reply to prompt]*</code>\n <b>Available Models:</b> <blockquote>{models}</blockquote>"
)
else:
return await message.edit_text(
f"<b>Usage: </b><code>{prefix}vdxl [model]* [prompt/reply to prompt]*</code>\n <b>Available Models:</b> <blockquote>{models}</blockquote>"
)
data = {
"prompt": prompt,
"model": model,
"negative_prompt": "canvas frame, cartoon, ((disfigured)), ((bad art)), ((deformed)),((extra limbs)),((close up)),((b&w)), weird colors, blurry, (((duplicate))), ((morbid)), ((mutilated)), [out of frame], extra fingers, mutated hands, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), (((deformed))), ((ugly)), blurry, ((bad anatomy)), (((bad proportions))), ((extra limbs)), cloned face, (((disfigured))), out of frame, ugly, extra limbs, (bad anatomy), gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), mutated hands, (fused fingers), (too many fingers), (((long neck))), Photoshop, video game, ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, mutation, mutated, extra limbs, extra legs, extra arms, disfigured, deformed, cross-eye, body out of frame, blurry, bad art, bad anatomy",
"token": vca_api_key,
"image_count": 1,
"width": 1024,
"height": 1024,
"steps": 30,
"cfg_scale": 8,
"sampler": "Euler",
"upscale": True,
}
response = await generate_images(data)
try:
with open("generated_image.png", "wb") as f:
f.write(response)
await message.delete()
await c.send_document(
chat_id,
document="generated_image.png",
caption=f"<b>Prompt: </b><code>{prompt}</code>\n<b>Model: </b><code>{model}</code>",
)
os.remove("generated_image.png")
except KeyError:
try:
error = response["error"]
await message.edit_text(f"<code>{error}</code>")
except KeyError:
detail = response["detail"]
await message.edit_text(f"<code>{detail}</code>")
except MessageTooLong:
await message.edit_text(
f"<b>Model List is too long</b> See the Full List <a href='https://visioncraft.top/image/models/{model_category}'> Here </a>"
)
return
except Exception as e:
await message.edit_text(f"An error occurred: {format_exc(e)}")
@Client.on_message(filters.command("vgif", prefix) & filters.me)
async def vgif(c: Client, message: Message):
"""Text2GIF Using VisionCraft API"""