lunarflu HF Staff commited on
Commit
8e113ec
·
1 Parent(s): 9841fc8

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -375,11 +375,11 @@ async def deepfloydif(ctx, *, prompt: str):
375
  # prompt, negative_prompt, seed, number_of_images, guidance_scale, custom_timesteps_1, number_of_inference_steps, api_name='/generate64')
376
 
377
  # run blocking function in executor
378
- await thread.send(f'✅running blocking function in executor')
379
  loop = asyncio.get_running_loop()
380
  result = await loop.run_in_executor(None, inference, prompt)
381
  await thread.send(f'{ctx.author.mention}after executor')
382
- await thread.send(f'✅run_in_executor ran successfully')
383
  stage_1_results = result[0]
384
  stage_1_result_path = result[2]
385
 
@@ -396,7 +396,7 @@ async def deepfloydif(ctx, *, prompt: str):
396
  await thread.edit(archived=True)
397
  #posting images✅----------------------------------------------------------------
398
  try:
399
- await thread.send(f'✅combining images...')
400
  #old, see: https://huggingface.co/spaces/DeepFloyd/IF/commit/fb79844b1d0b013a28ac435a36f804d8030fba50
401
  #png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
402
  png_files = list(glob.glob(f"{stage_1_results}/**/*.png"))
@@ -431,10 +431,12 @@ async def deepfloydif(ctx, *, prompt: str):
431
  combined_image_dfif = await thread.send(f'{ctx.author.mention}React with the image number you want to upscale!', file=discord.File(
432
  f, f'{partialpath}{dfif_command_message_id}.png')) # named something like: tmpgtv4qjix1111269940599738479.png
433
 
434
- await thread.send(f'✅reacting with 1234...')
435
  emoji_list = ['↖️', '↗️', '↙️', '↘️']
436
  await react1234(emoji_list, combined_image_dfif)
437
-
 
 
438
  ''' individual images
439
  if png_files:
440
  for i, png_file in enumerate(png_files):
@@ -471,6 +473,11 @@ async def deepfloydif(ctx, *, prompt: str):
471
  # Stage 2 ✅
472
  async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id): # add safetychecks
473
  try:
 
 
 
 
 
474
  number = index + 1
475
  if number == 1:
476
  position = "top left"
@@ -490,8 +497,6 @@ async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id
490
  with open(result_path, 'rb') as f:
491
  await thread.send(f'Here is the upscaled image! :) ', file=discord.File(f, 'result.png'))
492
 
493
- parent_channel = thread.parent
494
- dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
495
  await dfif_command_message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
496
  await dfif_command_message.add_reaction('<:agree:1098629085955113011>')
497
  await thread.edit(archived=True)
 
375
  # prompt, negative_prompt, seed, number_of_images, guidance_scale, custom_timesteps_1, number_of_inference_steps, api_name='/generate64')
376
 
377
  # run blocking function in executor
378
+ #await thread.send(f'✅running blocking function in executor')
379
  loop = asyncio.get_running_loop()
380
  result = await loop.run_in_executor(None, inference, prompt)
381
  await thread.send(f'{ctx.author.mention}after executor')
382
+ #await thread.send(f'✅run_in_executor ran successfully')
383
  stage_1_results = result[0]
384
  stage_1_result_path = result[2]
385
 
 
396
  await thread.edit(archived=True)
397
  #posting images✅----------------------------------------------------------------
398
  try:
399
+ #await thread.send(f'✅combining images...')
400
  #old, see: https://huggingface.co/spaces/DeepFloyd/IF/commit/fb79844b1d0b013a28ac435a36f804d8030fba50
401
  #png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
402
  png_files = list(glob.glob(f"{stage_1_results}/**/*.png"))
 
431
  combined_image_dfif = await thread.send(f'{ctx.author.mention}React with the image number you want to upscale!', file=discord.File(
432
  f, f'{partialpath}{dfif_command_message_id}.png')) # named something like: tmpgtv4qjix1111269940599738479.png
433
 
434
+ #await thread.send(f'✅reacting with 1234...')
435
  emoji_list = ['↖️', '↗️', '↙️', '↘️']
436
  await react1234(emoji_list, combined_image_dfif)
437
+
438
+ await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
439
+ await ctx.message.add_reaction('<:agree:1098629085955113011>')
440
  ''' individual images
441
  if png_files:
442
  for i, png_file in enumerate(png_files):
 
473
  # Stage 2 ✅
474
  async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id): # add safetychecks
475
  try:
476
+ parent_channel = thread.parent
477
+ dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
478
+ await dfif_command_message.remove_reaction(<:agree:1098629085955113011>, bot.user)
479
+ await dfif_command_message.add_reaction('<a:loading:1114111677990981692>')
480
+
481
  number = index + 1
482
  if number == 1:
483
  position = "top left"
 
497
  with open(result_path, 'rb') as f:
498
  await thread.send(f'Here is the upscaled image! :) ', file=discord.File(f, 'result.png'))
499
 
 
 
500
  await dfif_command_message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
501
  await dfif_command_message.add_reaction('<:agree:1098629085955113011>')
502
  await thread.edit(archived=True)