Update app.py
Browse files
app.py
CHANGED
|
@@ -32,12 +32,13 @@ bot = commands.Bot(command_prefix='!', intents=intents)
|
|
| 32 |
async def jojo(ctx):
|
| 33 |
attachment = await discord_before(ctx)
|
| 34 |
if attachment:
|
| 35 |
-
asyncio.
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
-
|
| 39 |
-
im = await asyncio.to_thread(generation, attachment)
|
| 40 |
-
await discord_after(ctx, im)
|
| 41 |
|
| 42 |
async def discord_before(ctx):
|
| 43 |
if ctx.message.attachments:
|
|
@@ -54,21 +55,32 @@ async def discord_before(ctx):
|
|
| 54 |
)
|
| 55 |
return None
|
| 56 |
|
| 57 |
-
async def generation(attachment):
|
| 58 |
if attachment:
|
| 59 |
style = 'JoJo'
|
| 60 |
im = jojogan.predict(attachment.url, style)
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
|
|
|
| 63 |
async def discord_after(ctx, im):
|
| 64 |
await asyncio.gather(
|
| 65 |
ctx.send(f'{ctx.author.mention} Here is the jojo version of it'),
|
| 66 |
ctx.send(file=discord.File(im)),
|
| 67 |
ctx.message.remove_reaction('β', bot.user),
|
| 68 |
ctx.message.add_reaction('β
')
|
| 69 |
-
)
|
| 70 |
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
def run_bot():
|
| 73 |
bot.run(DISCORD_TOKEN)
|
| 74 |
|
|
@@ -79,3 +91,26 @@ def greet(name):
|
|
| 79 |
|
| 80 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 81 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
async def jojo(ctx):
|
| 33 |
attachment = await discord_before(ctx)
|
| 34 |
if attachment:
|
| 35 |
+
blocking_coro = asyncio.to_thread(generation, ctx, attachment)
|
| 36 |
+
#result = await blocking_coro
|
| 37 |
+
task = asyncio.create_task(blocking_coro)
|
| 38 |
+
#await discord_after()
|
| 39 |
|
| 40 |
|
| 41 |
+
|
|
|
|
|
|
|
| 42 |
|
| 43 |
async def discord_before(ctx):
|
| 44 |
if ctx.message.attachments:
|
|
|
|
| 55 |
)
|
| 56 |
return None
|
| 57 |
|
| 58 |
+
async def generation(ctx, attachment):
|
| 59 |
if attachment:
|
| 60 |
style = 'JoJo'
|
| 61 |
im = jojogan.predict(attachment.url, style)
|
| 62 |
+
await asyncio.gather(
|
| 63 |
+
ctx.send(f'{ctx.author.mention} Here is the jojo version of it'),
|
| 64 |
+
ctx.send(file=discord.File(im)),
|
| 65 |
+
ctx.message.remove_reaction('β', bot.user),
|
| 66 |
+
ctx.message.add_reaction('β
')
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
|
| 70 |
+
'''
|
| 71 |
async def discord_after(ctx, im):
|
| 72 |
await asyncio.gather(
|
| 73 |
ctx.send(f'{ctx.author.mention} Here is the jojo version of it'),
|
| 74 |
ctx.send(file=discord.File(im)),
|
| 75 |
ctx.message.remove_reaction('β', bot.user),
|
| 76 |
ctx.message.add_reaction('β
')
|
| 77 |
+
)
|
| 78 |
|
| 79 |
+
'''
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
#--------------------------------------------------------
|
| 84 |
def run_bot():
|
| 85 |
bot.run(DISCORD_TOKEN)
|
| 86 |
|
|
|
|
| 91 |
|
| 92 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 93 |
demo.launch()
|
| 94 |
+
#--------------------------------------------------------
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
'''
|
| 102 |
+
def blocking_io():
|
| 103 |
+
#generate
|
| 104 |
+
#return image
|
| 105 |
+
|
| 106 |
+
async def main():
|
| 107 |
+
loop = asyncio.get_running_loop()
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
exeresult = await loop.run_in_executor(
|
| 112 |
+
None, blocking_io)
|
| 113 |
+
print('default thread pool', exeresult)
|
| 114 |
+
|
| 115 |
+
'''
|
| 116 |
+
|