File size: 1,672 Bytes
5bf5ca7
 
 
 
 
2a77ce8
5bf5ca7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2a77ce8
 
 
 
 
 
5bf5ca7
2a77ce8
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
56
57
import discord
import os

import gradio_client as gr 

import gradio as gr

# Get Gradio client
jojogan = gr.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("DISCORD_PAINTER_TOKEN", None)
intents = discord.Intents.default()
intents.message_content = True
client = MyClient(intents=intents)

async def run_bot():
  client.run(DISCORD_TOKEN)

asyncio.create_task(run_bot)

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")

demo.launch()