File size: 1,691 Bytes
5546580 05024ea 5546580 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import discord
import gradio_client
import gradio as gr
import os
import threading
# Get Gradio client
jojogan = gradio_client.Client("akhaliq/JoJoGAN")
# Set up discord bot
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content.find("!help") != -1:
await message.reply("Use !jojo !disney !spidey or !sketch. Have fun!", mention_author=True)
style = None
if message.content.startswith('!jojo'):
style = 'JoJo'
if message.content.startswith('!disney'):
style = 'Disney'
if message.content.startswith('!spidey'):
style = 'Spider-Verse'
if message.content.startswith('!sketch'):
style = 'sketch'
if style:
if message.attachments:
attachment = message.attachments[0]
im = jojogan.predict(attachment.url, style)
await message.reply(f'Here is the {style} version of it', file=discord.File(im))
else:
await message.channel.send("No attachments to be found...Can't animify dat! Try sending me an image π")
DISCORD_TOKEN = os.environ.get("GRADIOTEST_TOKEN", None)
intents = discord.Intents.default()
intents.message_content = True
client = MyClient(intents=intents)
def run_bot():
client.run(DISCORD_TOKEN)
threading.Thread(target=run_bot).start()
def greet(name):
return "Hello " + name + "!"
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch() |