lunarflu HF Staff commited on
Commit
9650ea7
Β·
1 Parent(s): 89a3df9
Files changed (1) hide show
  1. app.py +42 -43
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
- with rate_limiter:
56
- number_of_images = 4
57
- current_time = int(time.time())
58
- random.seed(current_time)
59
- seed = random.randint(0, 2**32 - 1)
60
- 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")
61
- png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
62
-
63
- if png_files:
64
- first_png = png_files[0]
65
- second_png = png_files[1]
66
- third_png = png_files[2]
67
- fourth_png = png_files[3]
68
-
69
- first_png_path = os.path.join(stage_1_results, first_png)
70
- second_png_path = os.path.join(stage_1_results, second_png)
71
- third_png_path = os.path.join(stage_1_results, third_png)
72
- fourth_png_path = os.path.join(stage_1_results, fourth_png)
73
-
74
- img1 = Image.open(first_png_path)
75
- img2 = Image.open(second_png_path)
76
- img3 = Image.open(third_png_path)
77
- img4 = Image.open(fourth_png_path)
78
-
79
- combined_image = Image.new('RGB', (img1.width * 2, img1.height * 2))
80
-
81
- combined_image.paste(img1, (0, 0))
82
- combined_image.paste(img2, (img1.width, 0))
83
- combined_image.paste(img3, (0, img1.height))
84
- combined_image.paste(img4, (img1.width, img1.height))
85
-
86
- combined_image_path = os.path.join(stage_1_results, 'combined_image.png')
87
- combined_image.save(combined_image_path)
88
-
89
- # Trigger the second stage prediction
90
- #await dfif2(ctx, stage_1_result_path)
91
-
92
- await ctx.reply('Here is the combined image. Select an option quickly!')
93
- with open(combined_image_path, 'rb') as f:
94
- await ctx.send(file=discord.File(f, 'combined_image.png'))
95
-
96
- reaction, user = await bot.wait_for('reaction_add', check=check_reaction)
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}")