lunarflu HF Staff commited on
Commit
ac1b5ab
·
1 Parent(s): ed3ceba

async def create_thread_dfif(ctx):

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -56,7 +56,8 @@ async def deepfloydif(ctx, *, prompt: str):
56
  return user == ctx.author and str(reaction.emoji) in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
57
 
58
  await ctx.message.add_reaction('👍')
59
-
 
60
  number_of_images = 4
61
  current_time = int(time.time())
62
  random.seed(current_time)
@@ -64,6 +65,7 @@ async def deepfloydif(ctx, *, prompt: str):
64
  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")
65
  png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
66
 
 
67
  if png_files:
68
  first_png = png_files[0]
69
  second_png = png_files[1]
@@ -93,8 +95,15 @@ async def deepfloydif(ctx, *, prompt: str):
93
  # Trigger the second stage prediction
94
  #await dfif2(ctx, stage_1_result_path)
95
 
96
- with open(combined_image_path, 'rb') as f:
97
- sent_message = await ctx.reply('Here is the combined image. React with the image number you want to upscale!', file=discord.File(f, 'combined_image.png'))
 
 
 
 
 
 
 
98
 
99
  # bot reacts with appropriate emojis to the post, both showing the user what options they have,
100
  # as well as showing which post to react to.
@@ -144,9 +153,19 @@ async def dfif2(ctx, index: int, stage_1_result_path):
144
  print(f"Error: {e}")
145
  await ctx.reply('An error occurred while processing stage 2 upscaling. Please try again later.')
146
  #----------------------------------------------------------------------------------------------------------------------------
 
 
 
 
 
 
 
 
 
 
 
147
 
148
 
149
-
150
 
151
  def run_bot():
152
  bot.run(DISCORD_TOKEN)
 
56
  return user == ctx.author and str(reaction.emoji) in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
57
 
58
  await ctx.message.add_reaction('👍')
59
+
60
+ #generate images----------------------------------------------------
61
  number_of_images = 4
62
  current_time = int(time.time())
63
  random.seed(current_time)
 
65
  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")
66
  png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
67
 
68
+ #combine images into one image--------------------------------------
69
  if png_files:
70
  first_png = png_files[0]
71
  second_png = png_files[1]
 
95
  # Trigger the second stage prediction
96
  #await dfif2(ctx, stage_1_result_path)
97
 
98
+
99
+
100
+
101
+
102
+ await create_thread_dfif(ctx)
103
+
104
+
105
+ #with open(combined_image_path, 'rb') as f:
106
+ # sent_message = await ctx.reply('Here is the combined image. React with the image number you want to upscale!', file=discord.File(f, 'combined_image.png'))
107
 
108
  # bot reacts with appropriate emojis to the post, both showing the user what options they have,
109
  # as well as showing which post to react to.
 
153
  print(f"Error: {e}")
154
  await ctx.reply('An error occurred while processing stage 2 upscaling. Please try again later.')
155
  #----------------------------------------------------------------------------------------------------------------------------
156
+ async def create_thread_dfif(ctx):
157
+ with open(combined_image_path, 'rb') as f:
158
+ thread_channel = await ctx.channel.create_thread(name='Image Thread')
159
+ sent_message = await ctx.reply('Here is the combined image. React with the image number you want to upscale!', file=discord.File(f, 'combined_image.png'))
160
+ #----------------------------------------------------------------------------------------------------------------------------
161
+
162
+
163
+
164
+
165
+
166
+
167
 
168
 
 
169
 
170
  def run_bot():
171
  bot.run(DISCORD_TOKEN)