lunarflu HF Staff commited on
Commit
8bd9703
Β·
1 Parent(s): 83bbee8

[reactions] finding bugs

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -290,6 +290,7 @@ async def deepfloydif(ctx, *, prompt: str):
290
  # Stage 2
291
  async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id):
292
  try:
 
293
  selected_index_for_stage_2 = index
294
  seed_2 = 0
295
  guidance_scale_2 = 4
@@ -297,12 +298,14 @@ async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id
297
  number_of_inference_steps_2 = 50
298
  result_path = df.predict(stage_1_result_path, selected_index_for_stage_2, seed_2,
299
  guidance_scale_2, custom_timesteps_2, number_of_inference_steps_2, api_name='/upscale256')
300
-
 
301
  with open(result_path, 'rb') as f:
302
  await thread.send(f'Here is the upscaled image! :) ', file=discord.File(f, 'result.png'))
303
- dfif_command_message = await channel.fetch_message(dfif_command_message_id)
304
- await dfif_command_message.add_reaction('βœ…')
305
 
 
 
 
306
  #await ctx.reply('Here is the result of the second stage', file=discord.File(f, 'result.png'))
307
  #await ctx.message.add_reaction('βœ…') need to fix this
308
 
@@ -322,6 +325,7 @@ async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id
322
  async def on_reaction_add(reaction, user):
323
  try:
324
  # safety checks first ❌
 
325
  if user.bot:
326
  return
327
 
@@ -340,11 +344,15 @@ async def on_reaction_add(reaction, user):
340
 
341
  #channel check ❌
342
  if reaction.message.channel.id != 1100458786826747945:
343
- return
344
-
 
 
 
345
  if reaction.message.attachments:
346
- if user.id == reaction.message.mentions[0].id:
347
  # magic begins
 
348
  attachment = reaction.message.attachments[0]
349
  image_name = attachment.filename # named something like: tmpgtv4qjix1111269940599738479.png
350
  # remove .png first
@@ -354,7 +362,7 @@ async def on_reaction_add(reaction, user):
354
  messageid = partialpathmessageid[11:] # 1111269940599738479
355
  # add /tmp/ to partialpath, save as new variable
356
  fullpath = "/tmp/" + partialpath # should be /tmp/tmpgtv4qjix
357
-
358
  emoji = reaction.emoji
359
 
360
  if emoji == "1️⃣":
@@ -365,12 +373,12 @@ async def on_reaction_add(reaction, user):
365
  index = 2
366
  elif emoji == "4️⃣":
367
  index = 3
368
-
369
  index = index
370
  stage_1_result_path = fullpath
371
  thread = reaction.message.channel
372
  dfif_command_message_id = messageid
373
-
374
  await dfif2(index, stage_1_result_path, thread, dfif_command_message_id)
375
 
376
  '''
 
290
  # Stage 2
291
  async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id):
292
  try:
293
+ await thread.send(f"inside dfif2, upscaling")
294
  selected_index_for_stage_2 = index
295
  seed_2 = 0
296
  guidance_scale_2 = 4
 
298
  number_of_inference_steps_2 = 50
299
  result_path = df.predict(stage_1_result_path, selected_index_for_stage_2, seed_2,
300
  guidance_scale_2, custom_timesteps_2, number_of_inference_steps_2, api_name='/upscale256')
301
+
302
+ await thread.send(f"upscale done")
303
  with open(result_path, 'rb') as f:
304
  await thread.send(f'Here is the upscaled image! :) ', file=discord.File(f, 'result.png'))
 
 
305
 
306
+ dfif_command_message = await channel.fetch_message(dfif_command_message_id)
307
+ await dfif_command_message.add_reaction('βœ…')
308
+ await thread.send(f"upscale posted")
309
  #await ctx.reply('Here is the result of the second stage', file=discord.File(f, 'result.png'))
310
  #await ctx.message.add_reaction('βœ…') need to fix this
311
 
 
325
  async def on_reaction_add(reaction, user):
326
  try:
327
  # safety checks first ❌
328
+ '''
329
  if user.bot:
330
  return
331
 
 
344
 
345
  #channel check ❌
346
  if reaction.message.channel.id != 1100458786826747945:
347
+ return
348
+
349
+ '''
350
+
351
+ # 811235357663297546 = lunarflu
352
  if reaction.message.attachments:
353
+ if user.id == 811235357663297546: # if user.id == reaction.message.mentions[0].id:
354
  # magic begins
355
+ await reaction.message.channel.send("reaction detected")
356
  attachment = reaction.message.attachments[0]
357
  image_name = attachment.filename # named something like: tmpgtv4qjix1111269940599738479.png
358
  # remove .png first
 
362
  messageid = partialpathmessageid[11:] # 1111269940599738479
363
  # add /tmp/ to partialpath, save as new variable
364
  fullpath = "/tmp/" + partialpath # should be /tmp/tmpgtv4qjix
365
+ await reaction.message.channel.send(f"fullpath extracted, {fullpath}")
366
  emoji = reaction.emoji
367
 
368
  if emoji == "1️⃣":
 
373
  index = 2
374
  elif emoji == "4️⃣":
375
  index = 3
376
+ await reaction.message.channel.send(f"index extracted, {index}")
377
  index = index
378
  stage_1_result_path = fullpath
379
  thread = reaction.message.channel
380
  dfif_command_message_id = messageid
381
+ await reaction.message.channel.send(f"calling dfif2")
382
  await dfif2(index, stage_1_result_path, thread, dfif_command_message_id)
383
 
384
  '''