lunarflu HF Staff commited on
Commit
da77733
·
1 Parent(s): 918ede3

reaction emoji -> await dfif2(ctx, index, stage_1_result_path)

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -41,8 +41,9 @@ bot = commands.Bot(command_prefix='!', intents=intents)
41
  async def on_ready():
42
  print('Logged on as', bot.user)
43
  bot.log_channel = bot.get_channel(1100458786826747945) # 1100458786826747945 = bot-test, 1107006391547342910 = lunarbot server
44
-
45
 
 
 
46
  @bot.command()
47
  async def deepfloydif(ctx, *, prompt: str):
48
  try:
@@ -101,32 +102,34 @@ async def deepfloydif(ctx, *, prompt: str):
101
  reaction, user = await bot.wait_for('reaction_add', check=check_reaction)
102
  if str(reaction.emoji) == '1️⃣':
103
  await ctx.send("You chose the first image!")
 
104
  elif str(reaction.emoji) == '2️⃣':
105
  await ctx.send("You chose the second image!")
 
106
  elif str(reaction.emoji) == '3️⃣':
107
  await ctx.send("You chose the third image!")
 
108
  elif str(reaction.emoji) == '4️⃣':
109
- await ctx.send("You chose the fourth image!")
 
110
 
 
111
  except Exception as e:
112
  print(f"Error: {e}")
113
  await ctx.reply('An error occurred while processing your request. Please wait 5 seconds before retrying.')
114
 
115
- #new stage 2----------------------------------------------------------------------------------------------------------------------------------------------
116
  # Stage 2
117
- @bot.command()
118
- async def dfif2(ctx, index: int, stage_1_result_path, image_paths):
119
  try:
120
- image_path = image_paths[index]
121
-
122
- selected_index_for_stage_2 = image_path
123
  seed_2 = 0
124
  guidance_scale_2 = 4
125
  custom_timesteps_2 = 'smart50'
126
  number_of_inference_steps_2 = 50
127
- result_path = df.predict(stage_1_result_path, selected_index_for_stage_2, seed_2, guidance_scale_2, custom_timesteps_2, number_of_inference_steps_2, api_name='/upscale256')
128
-
129
- # Process the result_path or perform any additional operations
130
 
131
  with open(result_path, 'rb') as f:
132
  await ctx.reply('Here is the result of the second stage', file=discord.File(f, 'result.png'))
@@ -134,7 +137,7 @@ async def dfif2(ctx, index: int, stage_1_result_path, image_paths):
134
  except Exception as e:
135
  print(f"Error: {e}")
136
  await ctx.reply('An error occurred while processing stage 2 upscaling. Please try again later.')
137
-
138
 
139
 
140
 
 
41
  async def on_ready():
42
  print('Logged on as', bot.user)
43
  bot.log_channel = bot.get_channel(1100458786826747945) # 1100458786826747945 = bot-test, 1107006391547342910 = lunarbot server
 
44
 
45
+ #----------------------------------------------------------------------------------------------------------------------------------------------
46
+ # Stage 1
47
  @bot.command()
48
  async def deepfloydif(ctx, *, prompt: str):
49
  try:
 
102
  reaction, user = await bot.wait_for('reaction_add', check=check_reaction)
103
  if str(reaction.emoji) == '1️⃣':
104
  await ctx.send("You chose the first image!")
105
+ await dfif2(ctx, 0, stage_1_result_path)
106
  elif str(reaction.emoji) == '2️⃣':
107
  await ctx.send("You chose the second image!")
108
+ await dfif2(ctx, 1, stage_1_result_path)
109
  elif str(reaction.emoji) == '3️⃣':
110
  await ctx.send("You chose the third image!")
111
+ await dfif2(ctx, 2, stage_1_result_path)
112
  elif str(reaction.emoji) == '4️⃣':
113
+ await ctx.send("You chose the fourth image!")
114
+ await dfif2(ctx, 3, stage_1_result_path)
115
 
116
+ #deepfloydif try/except
117
  except Exception as e:
118
  print(f"Error: {e}")
119
  await ctx.reply('An error occurred while processing your request. Please wait 5 seconds before retrying.')
120
 
121
+ #----------------------------------------------------------------------------------------------------------------------------
122
  # Stage 2
123
+ async def dfif2(ctx, index, stage_1_result_path):
 
124
  try:
125
+ selected_index_for_stage_2 = index
 
 
126
  seed_2 = 0
127
  guidance_scale_2 = 4
128
  custom_timesteps_2 = 'smart50'
129
  number_of_inference_steps_2 = 50
130
+ result_path = df.predict(stage_1_result_path, selected_index_for_stage_2, seed_2,
131
+ guidance_scale_2, custom_timesteps_2, number_of_inference_steps_2, api_name='/upscale256')
132
+
133
 
134
  with open(result_path, 'rb') as f:
135
  await ctx.reply('Here is the result of the second stage', file=discord.File(f, 'result.png'))
 
137
  except Exception as e:
138
  print(f"Error: {e}")
139
  await ctx.reply('An error occurred while processing stage 2 upscaling. Please try again later.')
140
+ #----------------------------------------------------------------------------------------------------------------------------
141
 
142
 
143