lunarflu HF Staff commited on
Commit
6d8cbbb
·
1 Parent(s): ec6916e

added [fullqueue]

Browse files
Files changed (1) hide show
  1. app.py +21 -10
app.py CHANGED
@@ -180,11 +180,12 @@ async def jojo(ctx):
180
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
181
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
182
  except Exception as e: # no generation / img + no face
 
183
  print(f"Error: {e}")
184
  await thread.send(f"{ctx.author.mention} Error: {e}")
185
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
186
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
187
-
188
  #----------------------------------------------------------------------------------------------------------------------------------------------
189
  # Disney ❌
190
  @bot.command()
@@ -205,7 +206,9 @@ async def disney(ctx):
205
  await thread.send(f"{ctx.author.mention} No attachments to be found...Can't animify dat! Try sending me an image 😉")
206
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
207
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
 
208
  except Exception as e: # no generation / img + no face
 
209
  print(f"Error: {e}")
210
  await thread.send(f"{ctx.author.mention} Error: {e}")
211
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
@@ -232,6 +235,7 @@ async def spidey(ctx):
232
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
233
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
234
  except Exception as e: # no generation / img + no face
 
235
  print(f"Error: {e}")
236
  await thread.send(f"{ctx.author.mention} Error: {e}")
237
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
@@ -258,11 +262,21 @@ async def sketch(ctx):
258
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
259
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
260
  except Exception as e: # no generation / img + no face
 
261
  print(f"Error: {e}")
262
  await thread.send(f"{ctx.author.mention} Error: {e}")
263
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
264
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
265
  #----------------------------------------------------------------------------------------------------------------------------------------------
 
 
 
 
 
 
 
 
 
266
  # deepfloydif stage 1 generation ✅
267
  def inference(prompt):
268
  negative_prompt = ''
@@ -323,6 +337,7 @@ async def deepfloydif(ctx, *, prompt: str):
323
  print(f"Error: {e}")
324
  thread = await ctx.message.create_thread(name=f'DFIF1 Error')
325
  await thread.send(f"{ctx.author.mention} Error during stage 1 pre-generation.")
 
326
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
327
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
328
 
@@ -345,6 +360,7 @@ async def deepfloydif(ctx, *, prompt: str):
345
  print(f"Error: {e}")
346
  thread = await ctx.message.create_thread(name=f'Generation Error')
347
  await thread.send(f"{ctx.author.mention} Error during stage 1 generation.")
 
348
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
349
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
350
  #posting images✅----------------------------------------------------------------
@@ -403,6 +419,7 @@ async def deepfloydif(ctx, *, prompt: str):
403
  print(f"Error: {e}")
404
  thread = await ctx.message.create_thread(name=f'Posting Error')
405
  await thread.send(f"{ctx.author.mention} Encountered error while posting combined image in thread.")
 
406
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
407
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
408
 
@@ -411,6 +428,7 @@ async def deepfloydif(ctx, *, prompt: str):
411
  print(f"Error: {e}")
412
  thread = await ctx.message.create_thread(name=f'deepfloydif Error')
413
  await thread.send(f"{ctx.author.mention} Overall error with deepfloydif.")
 
414
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
415
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
416
 
@@ -436,11 +454,7 @@ async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id
436
  #await thread.send(f"✅upscale done")
437
  with open(result_path, 'rb') as f:
438
  await thread.send(f'Here is the upscaled image! :) ', file=discord.File(f, 'result.png'))
439
-
440
- # using custom emoji that looks nicer
441
- emoji_guild = thread.guild
442
- success_emoji_id = 1098629085955113011
443
- success_emoji = discord.utils.get(emoji_guild.emojis, id=success_emoji_id)
444
  parent_channel = thread.parent
445
  dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
446
  await dfif_command_message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
@@ -448,15 +462,12 @@ async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id
448
 
449
  except Exception as e:
450
  print(f"Error: {e}")
451
-
452
- emoji_guild = thread.guild
453
- failure_emoji_id = 1098628957521313892
454
- failure_emoji = discord.utils.get(emoji_guild.emojis, id=failure_emoji_id)
455
  parent_channel = thread.parent
456
  dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
457
  await dfif_command_message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
458
  await dfif_command_message.add_reaction('<:disagree:1098628957521313892>')
459
  await thread.send(f"Error during stage 2 upscaling.")
 
460
  #----------------------------------------------------------------------------------------------------------------------------
461
  # react detector for stage 2 ✅
462
  @bot.event
 
180
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
181
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
182
  except Exception as e: # no generation / img + no face
183
+ await fullqueue(e, thread)
184
  print(f"Error: {e}")
185
  await thread.send(f"{ctx.author.mention} Error: {e}")
186
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
187
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
188
+
189
  #----------------------------------------------------------------------------------------------------------------------------------------------
190
  # Disney ❌
191
  @bot.command()
 
206
  await thread.send(f"{ctx.author.mention} No attachments to be found...Can't animify dat! Try sending me an image 😉")
207
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
208
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
209
+
210
  except Exception as e: # no generation / img + no face
211
+ await fullqueue(e, thread)
212
  print(f"Error: {e}")
213
  await thread.send(f"{ctx.author.mention} Error: {e}")
214
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
 
235
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
236
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
237
  except Exception as e: # no generation / img + no face
238
+ await fullqueue(e, thread)
239
  print(f"Error: {e}")
240
  await thread.send(f"{ctx.author.mention} Error: {e}")
241
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
 
262
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
263
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
264
  except Exception as e: # no generation / img + no face
265
+ await fullqueue(e, thread)
266
  print(f"Error: {e}")
267
  await thread.send(f"{ctx.author.mention} Error: {e}")
268
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
269
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
270
  #----------------------------------------------------------------------------------------------------------------------------------------------
271
+ async def fullqueue(e, thread):
272
+ error_message = str(e)
273
+ if "Error: Expecting value: line 1 column 1 (char 0)" in error_message:
274
+ await thread.send("Queue is full! Please try again.")
275
+ elif: "Error: Queue is full! Please try again." in error_message:
276
+ await thread.send("Queue is full! Please try again.")
277
+ elif: "local variable 'stage_1_results' referenced before assignment" in error_message:
278
+ await thread.send("Queue is full! Please try again.")
279
+ #----------------------------------------------------------------------------------------------------------------------------------------------
280
  # deepfloydif stage 1 generation ✅
281
  def inference(prompt):
282
  negative_prompt = ''
 
337
  print(f"Error: {e}")
338
  thread = await ctx.message.create_thread(name=f'DFIF1 Error')
339
  await thread.send(f"{ctx.author.mention} Error during stage 1 pre-generation.")
340
+ await fullqueue(e, thread)
341
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
342
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
343
 
 
360
  print(f"Error: {e}")
361
  thread = await ctx.message.create_thread(name=f'Generation Error')
362
  await thread.send(f"{ctx.author.mention} Error during stage 1 generation.")
363
+ await fullqueue(e, thread)
364
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
365
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
366
  #posting images✅----------------------------------------------------------------
 
419
  print(f"Error: {e}")
420
  thread = await ctx.message.create_thread(name=f'Posting Error')
421
  await thread.send(f"{ctx.author.mention} Encountered error while posting combined image in thread.")
422
+ await fullqueue(e, thread)
423
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
424
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
425
 
 
428
  print(f"Error: {e}")
429
  thread = await ctx.message.create_thread(name=f'deepfloydif Error')
430
  await thread.send(f"{ctx.author.mention} Overall error with deepfloydif.")
431
+ await fullqueue(e, thread)
432
  await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
433
  await ctx.message.add_reaction('<:disagree:1098628957521313892>')
434
 
 
454
  #await thread.send(f"✅upscale done")
455
  with open(result_path, 'rb') as f:
456
  await thread.send(f'Here is the upscaled image! :) ', file=discord.File(f, 'result.png'))
457
+
 
 
 
 
458
  parent_channel = thread.parent
459
  dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
460
  await dfif_command_message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
 
462
 
463
  except Exception as e:
464
  print(f"Error: {e}")
 
 
 
 
465
  parent_channel = thread.parent
466
  dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
467
  await dfif_command_message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
468
  await dfif_command_message.add_reaction('<:disagree:1098628957521313892>')
469
  await thread.send(f"Error during stage 2 upscaling.")
470
+ await fullqueue(e, thread)
471
  #----------------------------------------------------------------------------------------------------------------------------
472
  # react detector for stage 2 ✅
473
  @bot.event