lunarflu HF Staff commited on
Commit
bc0d1ce
·
1 Parent(s): 698f849

revert to stable [1.0

Browse files
Files changed (1) hide show
  1. app.py +10 -18
app.py CHANGED
@@ -53,11 +53,10 @@ async def deepfloydif(ctx, *, prompt: str):
53
  prompt = re.sub(r'[^\w\s]', '', prompt) # Remove special characters
54
 
55
  def check_reaction(reaction, user):
56
- return user == ctx.author and str(reaction.emoji) in ['1️⃣', '2️⃣', '3️⃣', '4️⃣'] # is this used?
57
 
58
  await ctx.message.add_reaction('👍')
59
-
60
- #generate images----------------------------------------------------
61
  number_of_images = 4
62
  current_time = int(time.time())
63
  random.seed(current_time)
@@ -65,7 +64,6 @@ async def deepfloydif(ctx, *, prompt: str):
65
  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")
66
  png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
67
 
68
- #combine images into one image--------------------------------------
69
  if png_files:
70
  first_png = png_files[0]
71
  second_png = png_files[1]
@@ -91,13 +89,13 @@ async def deepfloydif(ctx, *, prompt: str):
91
 
92
  combined_image_path = os.path.join(stage_1_results, 'combined_image.png')
93
  combined_image.save(combined_image_path)
94
-
95
- # open combined image in a thread, mention the user
 
 
96
  with open(combined_image_path, 'rb') as f:
97
- thread_channel = await ctx.channel.create_thread(name='Image Thread')
98
- sent_message = await thread_channel.send('Here is the combined image. React with the image number you want to upscale!',
99
- file=discord.File(f, 'combined_image.png'))
100
-
101
  # bot reacts with appropriate emojis to the post, both showing the user what options they have,
102
  # as well as showing which post to react to.
103
  for emoji in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']:
@@ -119,8 +117,7 @@ async def deepfloydif(ctx, *, prompt: str):
119
  elif str(reaction.emoji) == '4️⃣':
120
  await ctx.reply("Upscaling the fourth image...")
121
  index = 3
122
- await dfif2(ctx, index, stage_1_result_path)
123
-
124
 
125
  #deepfloydif try/except
126
  except Exception as e:
@@ -149,12 +146,7 @@ async def dfif2(ctx, index: int, stage_1_result_path):
149
  #----------------------------------------------------------------------------------------------------------------------------
150
 
151
 
152
-
153
-
154
-
155
-
156
-
157
-
158
 
159
  def run_bot():
160
  bot.run(DISCORD_TOKEN)
 
53
  prompt = re.sub(r'[^\w\s]', '', prompt) # Remove special characters
54
 
55
  def check_reaction(reaction, user):
56
+ return user == ctx.author and str(reaction.emoji) in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
57
 
58
  await ctx.message.add_reaction('👍')
59
+
 
60
  number_of_images = 4
61
  current_time = int(time.time())
62
  random.seed(current_time)
 
64
  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")
65
  png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
66
 
 
67
  if png_files:
68
  first_png = png_files[0]
69
  second_png = png_files[1]
 
89
 
90
  combined_image_path = os.path.join(stage_1_results, 'combined_image.png')
91
  combined_image.save(combined_image_path)
92
+
93
+ # Trigger the second stage prediction
94
+ #await dfif2(ctx, stage_1_result_path)
95
+
96
  with open(combined_image_path, 'rb') as f:
97
+ 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'))
98
+
 
 
99
  # bot reacts with appropriate emojis to the post, both showing the user what options they have,
100
  # as well as showing which post to react to.
101
  for emoji in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']:
 
117
  elif str(reaction.emoji) == '4️⃣':
118
  await ctx.reply("Upscaling the fourth image...")
119
  index = 3
120
+ await dfif2(ctx, index, stage_1_result_path)
 
121
 
122
  #deepfloydif try/except
123
  except Exception as e:
 
146
  #----------------------------------------------------------------------------------------------------------------------------
147
 
148
 
149
+
 
 
 
 
 
150
 
151
  def run_bot():
152
  bot.run(DISCORD_TOKEN)