lunarflu HF Staff commited on
Commit
b6b7b30
·
1 Parent(s): 11ad260

[decorators] individual images test

Browse files
Files changed (1) hide show
  1. app.py +14 -30
app.py CHANGED
@@ -60,7 +60,7 @@ async def deepfloydif(ctx, *, prompt: str):
60
  seed = random.randint(0, 2**32 - 1)
61
  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")
62
  png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
63
-
64
  if png_files:
65
  first_png = png_files[0]
66
  second_png = png_files[1]
@@ -87,35 +87,19 @@ async def deepfloydif(ctx, *, prompt: str):
87
  combined_image_path = os.path.join(stage_1_results, 'combined_image.png')
88
  combined_image.save(combined_image_path)
89
 
90
- # Trigger the second stage prediction
91
- #await dfif2(ctx, stage_1_result_path)
92
-
93
-
94
- with open(combined_image_path, 'rb') as f:
95
- threadmsg = await thread.send(f'{ctx.author.mention}React with the image number you want to upscale!', file=discord.File(f, 'combined_image.png'))
96
-
97
- # bot reacts with appropriate emojis to the post, both showing the user what options they have,
98
- # as well as showing which post to react to.
99
- for emoji in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']:
100
- await threadmsg.add_reaction(emoji)
101
-
102
- reaction, user = await bot.wait_for('reaction_add', check=check_reaction)
103
- if str(reaction.emoji) == '1️⃣':
104
- await thread.send(f"{ctx.author.mention}Upscaling the first image...")
105
- index = 0
106
- await dfif2(ctx, index, stage_1_result_path, thread)
107
- elif str(reaction.emoji) == '2️⃣':
108
- await thread.send(f"{ctx.author.mention}Upscaling the second image...")
109
- index = 1
110
- await dfif2(ctx, index, stage_1_result_path, thread)
111
- elif str(reaction.emoji) == '3️⃣':
112
- await thread.send(f"{ctx.author.mention}Upscaling the third image...")
113
- index = 2
114
- await dfif2(ctx, index, stage_1_result_path, thread)
115
- elif str(reaction.emoji) == '4️⃣':
116
- await thread.send(f"{ctx.author.mention}Upscaling the fourth image...")
117
- index = 3
118
- await dfif2(ctx, index, stage_1_result_path, thread)
119
 
120
  #deepfloydif try/except
121
  except Exception as e:
 
60
  seed = random.randint(0, 2**32 - 1)
61
  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")
62
  png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
63
+ '''
64
  if png_files:
65
  first_png = png_files[0]
66
  second_png = png_files[1]
 
87
  combined_image_path = os.path.join(stage_1_results, 'combined_image.png')
88
  combined_image.save(combined_image_path)
89
 
90
+ '''
91
+
92
+ if png_files:
93
+ for i, png_file in enumerate(png_files):
94
+ png_file_path = os.path.join(stage_1_results, png_file)
95
+ img = Image.open(png_file_path)
96
+ image_path = os.path.join(stage_1_results, f'image{i+1}.png')
97
+ img.save(image_path)
98
+ with open(image_path, 'rb') as f:
99
+ await thread.send(f'{ctx.author.mention}Image {i+1}', file=discord.File(f, f'image{i+1}.png'))
100
+ await asyncio.sleep(1) # Add a delay between posting each image
101
+
102
+ await thread.send(f'{ctx.author.mention}React with 👍 to the image you want to upscale!')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  #deepfloydif try/except
105
  except Exception as e: