lunarflu HF Staff commited on
Commit
c141883
·
1 Parent(s): 7f0e43f

moved thread inside dfif1

Browse files
Files changed (1) hide show
  1. app.py +26 -31
app.py CHANGED
@@ -95,10 +95,33 @@ async def deepfloydif(ctx, *, prompt: str):
95
  # creates a thread, passing the combined_image_path in
96
  await create_thread_dfif(ctx, combined_image_path)
97
 
 
 
 
 
 
 
 
 
 
98
 
99
- #with open(combined_image_path, 'rb') as f:
100
- # 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'))
101
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
 
104
  #deepfloydif try/except
@@ -126,34 +149,6 @@ async def dfif2(ctx, index: int, stage_1_result_path):
126
  print(f"Error: {e}")
127
  await ctx.reply('An error occurred while processing stage 2 upscaling. Please try again later.')
128
  #----------------------------------------------------------------------------------------------------------------------------
129
- async def create_thread_dfif(ctx, combined_image_path):
130
- with open(combined_image_path, 'rb') as f:
131
- thread_channel = await ctx.channel.create_thread(name='Image Thread')
132
- 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'))
133
-
134
- # bot reacts with appropriate emojis to the post, both showing the user what options they have,
135
- # as well as showing which post to react to.
136
- for emoji in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']:
137
- await sent_message.add_reaction(emoji)
138
-
139
- reaction, user = await bot.wait_for('reaction_add', check=check_reaction)
140
- if str(reaction.emoji) == '1️⃣':
141
- await ctx.reply("Upscaling the first image...")
142
- index = 0
143
- await dfif2(ctx, index, stage_1_result_path)
144
- elif str(reaction.emoji) == '2️⃣':
145
- await ctx.reply("Upscaling the second image...")
146
- index = 1
147
- await dfif2(ctx, index, stage_1_result_path)
148
- elif str(reaction.emoji) == '3️⃣':
149
- await ctx.reply("Upscaling the third image...")
150
- index = 2
151
- await dfif2(ctx, index, stage_1_result_path)
152
- elif str(reaction.emoji) == '4️⃣':
153
- await ctx.reply("Upscaling the fourth image...")
154
- index = 3
155
- await dfif2(ctx, index, stage_1_result_path)
156
- #----------------------------------------------------------------------------------------------------------------------------
157
 
158
 
159
 
 
95
  # creates a thread, passing the combined_image_path in
96
  await create_thread_dfif(ctx, combined_image_path)
97
 
98
+ # open combined image in a thread, mention the user
99
+ with open(combined_image_path, 'rb') as f:
100
+ thread_channel = await ctx.channel.create_thread(name='Image Thread')
101
+ 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'))
102
+
103
+ # bot reacts with appropriate emojis to the post, both showing the user what options they have,
104
+ # as well as showing which post to react to.
105
+ for emoji in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']:
106
+ await sent_message.add_reaction(emoji)
107
 
108
+ reaction, user = await bot.wait_for('reaction_add', check=check_reaction)
109
+ if str(reaction.emoji) == '1️⃣':
110
+ await ctx.reply("Upscaling the first image...")
111
+ index = 0
112
+ await dfif2(ctx, index, stage_1_result_path)
113
+ elif str(reaction.emoji) == '2️⃣':
114
+ await ctx.reply("Upscaling the second image...")
115
+ index = 1
116
+ await dfif2(ctx, index, stage_1_result_path)
117
+ elif str(reaction.emoji) == '3️⃣':
118
+ await ctx.reply("Upscaling the third image...")
119
+ index = 2
120
+ await dfif2(ctx, index, stage_1_result_path)
121
+ elif str(reaction.emoji) == '4️⃣':
122
+ await ctx.reply("Upscaling the fourth image...")
123
+ index = 3
124
+ await dfif2(ctx, index, stage_1_result_path)
125
 
126
 
127
  #deepfloydif try/except
 
149
  print(f"Error: {e}")
150
  await ctx.reply('An error occurred while processing stage 2 upscaling. Please try again later.')
151
  #----------------------------------------------------------------------------------------------------------------------------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
 
154