r2
Browse files
app.py
CHANGED
|
@@ -52,49 +52,48 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
| 52 |
def check_reaction(reaction, user):
|
| 53 |
return str(reaction.emoji) == 'π' and user == ctx.author
|
| 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 |
-
await ctx.send(f"{user.mention} reacted with a thumbs-up!")
|
| 98 |
|
| 99 |
except Exception as e:
|
| 100 |
print(f"Error: {e}")
|
|
|
|
| 52 |
def check_reaction(reaction, user):
|
| 53 |
return str(reaction.emoji) == 'π' and user == ctx.author
|
| 54 |
|
| 55 |
+
number_of_images = 4
|
| 56 |
+
current_time = int(time.time())
|
| 57 |
+
random.seed(current_time)
|
| 58 |
+
seed = random.randint(0, 2**32 - 1)
|
| 59 |
+
stage_1_results, stage_1_param_path, stage_1_result_path = df.predict(prompt, "blur", seed, number_of_images, 7.0, 'smart100', 50, api_name="/generate64")
|
| 60 |
+
png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
|
| 61 |
+
|
| 62 |
+
if png_files:
|
| 63 |
+
first_png = png_files[0]
|
| 64 |
+
second_png = png_files[1]
|
| 65 |
+
third_png = png_files[2]
|
| 66 |
+
fourth_png = png_files[3]
|
| 67 |
+
|
| 68 |
+
first_png_path = os.path.join(stage_1_results, first_png)
|
| 69 |
+
second_png_path = os.path.join(stage_1_results, second_png)
|
| 70 |
+
third_png_path = os.path.join(stage_1_results, third_png)
|
| 71 |
+
fourth_png_path = os.path.join(stage_1_results, fourth_png)
|
| 72 |
+
|
| 73 |
+
img1 = Image.open(first_png_path)
|
| 74 |
+
img2 = Image.open(second_png_path)
|
| 75 |
+
img3 = Image.open(third_png_path)
|
| 76 |
+
img4 = Image.open(fourth_png_path)
|
| 77 |
+
|
| 78 |
+
combined_image = Image.new('RGB', (img1.width * 2, img1.height * 2))
|
| 79 |
+
|
| 80 |
+
combined_image.paste(img1, (0, 0))
|
| 81 |
+
combined_image.paste(img2, (img1.width, 0))
|
| 82 |
+
combined_image.paste(img3, (0, img1.height))
|
| 83 |
+
combined_image.paste(img4, (img1.width, img1.height))
|
| 84 |
+
|
| 85 |
+
combined_image_path = os.path.join(stage_1_results, 'combined_image.png')
|
| 86 |
+
combined_image.save(combined_image_path)
|
| 87 |
+
|
| 88 |
+
# Trigger the second stage prediction
|
| 89 |
+
#await dfif2(ctx, stage_1_result_path)
|
| 90 |
+
|
| 91 |
+
await ctx.reply('Here is the combined image. Select an option quickly!')
|
| 92 |
+
with open(combined_image_path, 'rb') as f:
|
| 93 |
+
await ctx.send(file=discord.File(f, 'combined_image.png'))
|
| 94 |
+
|
| 95 |
+
reaction, user = await bot.wait_for('reaction_add', check=check_reaction)
|
| 96 |
+
await ctx.send(f"{user.mention} reacted with a thumbs-up!")
|
|
|
|
| 97 |
|
| 98 |
except Exception as e:
|
| 99 |
print(f"Error: {e}")
|