Spaces:
Sleeping
Sleeping
Rifat Azad commited on
Commit ·
a99ad01
1
Parent(s): 818b408
update
Browse files- pydvpl_bot.py +9 -14
pydvpl_bot.py
CHANGED
|
@@ -646,22 +646,17 @@ async def image(ctx, *, prompt: str):
|
|
| 646 |
msg = await ctx.reply(f"Generating images for prompt: `{prompt}`. Please be patient...")
|
| 647 |
|
| 648 |
try:
|
| 649 |
-
generator = Craiyon()
|
| 650 |
-
generated_images = await generator.async_generate(prompt)
|
| 651 |
-
|
| 652 |
-
# Encode images to base64
|
| 653 |
-
b64_list = await craiyon_utils.async_encode_base64(generated_images.images)
|
| 654 |
-
|
| 655 |
-
# Prepare images for sending
|
| 656 |
-
images = []
|
| 657 |
-
for index, image_b64 in enumerate(b64_list):
|
| 658 |
-
img_bytes = BytesIO(base64.b64decode(image_b64))
|
| 659 |
-
image_file = discord.File(img_bytes, filename=f"result{index}.webp")
|
| 660 |
-
images.append(image_file)
|
| 661 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 662 |
await msg.edit(content=f"Sucessfully generated {prompt} images.")
|
| 663 |
-
# Send images to the user
|
| 664 |
-
await ctx.reply(files=images)
|
| 665 |
|
| 666 |
except Exception as e:
|
| 667 |
# Print the specific exception message for debugging
|
|
|
|
| 646 |
msg = await ctx.reply(f"Generating images for prompt: `{prompt}`. Please be patient...")
|
| 647 |
|
| 648 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 649 |
|
| 650 |
+
generator = Craiyon()
|
| 651 |
+
|
| 652 |
+
# Generate the image based on the prompt
|
| 653 |
+
result = generator.generate(prompt)
|
| 654 |
+
|
| 655 |
+
# Send each image URL to the Discord channel
|
| 656 |
+
for url in result.images:
|
| 657 |
+
await ctx.reply(url)
|
| 658 |
+
|
| 659 |
await msg.edit(content=f"Sucessfully generated {prompt} images.")
|
|
|
|
|
|
|
| 660 |
|
| 661 |
except Exception as e:
|
| 662 |
# Print the specific exception message for debugging
|