Turn arbitrary style transfer into discord bot

Hello I have been trying to turn https://glitch.com/~style-transfer into a discord bot, I already have the basic discord bot here running and sending messages https://glitch.com/~discord-bot-example. What i tried was basically adding the script.js to server.js on certain messages like
“do style transfer”, then pull the image from the canvas document.getElementByid(‘content’), document.getElementByid(‘style’), document.getElementByid(‘stylized’), but the canvas would not even load, is this the right approach or what else can I do?

Hey @Neural I haven’t transmuted a site into a bot myself, but what I think you’re running into is that a bot’s server.js file is running on the server, not in the browser, so it doesn’t have access to the DOM, and methods like document.getElementById() aren’t available.

Assuming you’re trying to build a command that will take a source photo and style image and return a stylized result, I think you’ll need to have your users tell the bot where to find the source and style images and then build up a canvas in your bot and send it back to the guild or member.

Does any of that make sense?

Hi, I am looking into building a canvas thanks for the link, I am new to discord bots, I can get style transfer running otherwise

@cori update on this I found this repo https://github.com/ZuomingShi/StyleTransferBot which is a discord bot for style transfer and was able to get it setup in glitch but when I do node index.js it shows Ready to server in blank channels on blank servers, for a total of blank users. I put those blanks in for the real numbers but after i do commands with the bot like * @styletransferbot please paint me some "maple leaves" in the style of "starry night" nothing shows in logs and the bot doesnt do anything

I think I’d need to take a closer look at you bot to have anything useful to contribute here. Can you share your project’s name?

@cori sure, I was able to get the bot to respond "I’m away right now, try me in a minute or when you see me online!’ and the project name is determined-windscreen

@cori any idea what could be causing this, for @botname help I get a string of numbers and for @botname please paint me some “maple leaves” in the style of “starry night” I get I’m away right now, try me in a minute or when you see me online!

@cori I am still not sure what the problem could be, can you please assist on this, thanks

Hey @Neural for your help command you’ve told your bot to respond with a user id at https://glitch.com/edit/#!/determined-windscreen?path=StyleTransferBot/commands/help.js:3:0, so that’s why you’re seeing that result.

In the other case, in https://glitch.com/edit/#!/determined-windscreen?path=StyleTransferBot/commands/getimage.js:209:0 you’re looking for the file at the path set in https://glitch.com/edit/#!/determined-windscreen?path=StyleTransferBot/commands/getimage.js:3:0. That file is there, so your bot responds appropriately. It looks like your cleanup code never deleted the global.lock file, so once it’s created your bot will always respond in that way.

@cori thanks I was able to fix the help.js issue and now it shows the help menu for @bot help and I think I just figured out the other issue but will let you know if that problem persists thanks!

@cori So I was able to get it to show the base and style image but when I do @bot progress I get “No requests ever ran” and progress.json isnt being saved
(node:3232) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat ‘/app/StyleTransferBot/requests/userid/results.jpg’

@cori I think the model file was missing and it is 500 mb so when i try to download it there is no space left on disk, is there a way I can run the python command with the model file?