mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 14:43:05 -04:00
support img2img
This commit is contained in:
parent
3499e007db
commit
a372a08b6e
1 changed files with 24 additions and 6 deletions
|
@ -2,12 +2,13 @@ const { createEmbed } = require("../../../labscore/utils/embed");
|
||||||
const { editOrReply } = require("../../../labscore/utils/message");
|
const { editOrReply } = require("../../../labscore/utils/message");
|
||||||
|
|
||||||
const superagent = require('superagent');
|
const superagent = require('superagent');
|
||||||
|
const { getRecentImage } = require("../../../labscore/utils/attachment");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'anime',
|
name: 'anime',
|
||||||
label: 'query',
|
label: 'query',
|
||||||
metadata: {
|
metadata: {
|
||||||
description: 'Uses Stable Diffusion to generate an image using anime styling from a text prompt.',
|
description: 'Uses Stable Diffusion to generate an image using anime styling from a text prompt.\n\n**Replying** to a message with an image will use said image as a base for the AI (img2img), this does __not__ support inpainting/adding elements to the image.',
|
||||||
description_short: 'AI Anime image generation',
|
description_short: 'AI Anime image generation',
|
||||||
explicit: true,
|
explicit: true,
|
||||||
examples: ['anime otter'],
|
examples: ['anime otter'],
|
||||||
|
@ -22,6 +23,15 @@ module.exports = {
|
||||||
run: async (context, args) => {
|
run: async (context, args) => {
|
||||||
if(!context.channel.nsfw) return editOrReply(context, {embeds:[createEmbed("nsfw", context)]})
|
if(!context.channel.nsfw) return editOrReply(context, {embeds:[createEmbed("nsfw", context)]})
|
||||||
if(args.query.length == 0) return editOrReply(context, {embeds:[createEmbed("warning", context, "Missing prompt")]})
|
if(args.query.length == 0) return editOrReply(context, {embeds:[createEmbed("warning", context, "Missing prompt")]})
|
||||||
|
|
||||||
|
let hasUrl = false;
|
||||||
|
let image;
|
||||||
|
if(context.message.messageReference){
|
||||||
|
image = await getRecentImage(context, 50)
|
||||||
|
hasUrl = true;
|
||||||
|
if(!image) return editOrReply(context, createEmbed("warning", context, "No images found."))
|
||||||
|
}
|
||||||
|
|
||||||
let response = await editOrReply(context, { embeds: [createEmbed("loading", context, `Generating image...`)] })
|
let response = await editOrReply(context, { embeds: [createEmbed("loading", context, `Generating image...`)] })
|
||||||
|
|
||||||
let noticeTimer = setTimeout(()=>{
|
let noticeTimer = setTimeout(()=>{
|
||||||
|
@ -35,11 +45,19 @@ module.exports = {
|
||||||
try{
|
try{
|
||||||
let t = Date.now();
|
let t = Date.now();
|
||||||
|
|
||||||
let img = await superagent.get(`${process.env.AI_SERVER}/anime`)
|
let img;
|
||||||
.query({
|
if(hasUrl){
|
||||||
prompt: args.query
|
img = await superagent.get(`${process.env.AI_SERVER}/anime/img2img`)
|
||||||
})
|
.query({
|
||||||
|
prompt: args.query,
|
||||||
|
url: image
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
img = await superagent.get(`${process.env.AI_SERVER}/anime`)
|
||||||
|
.query({
|
||||||
|
prompt: args.query
|
||||||
|
})
|
||||||
|
}
|
||||||
clearTimeout(noticeTimer)
|
clearTimeout(noticeTimer)
|
||||||
|
|
||||||
if(img.body.message) return await response.edit({embeds:[createEmbed("warning", context, img.body.message)]})
|
if(img.body.message) return await response.edit({embeds:[createEmbed("warning", context, img.body.message)]})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue