반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 파이썬으로 디스코드 봇 만들기
- ARK
- 슬래시 명령어
- 자살명령어
- 디스코드 봇 만들기
- ARK Survival Evolved
- 공지
- 슬래시 커맨드
- discord embed
- 플러그인 제작
- 아크서바이벌 플러그인 만들기
- Ark Survival
- 플러그인
- 파이썬
- discord
- 개발자 툴
- 디스코드
- 마인크래프트 공지 플러그인
- slash command
- 명령어
- 만들기
- 디스코드 임베드
- 디스코드 봇
- ark plugin
- 마인크래프트 공지 플러그인 만들기
- 아크서바이벌 플러그인
- 파이썬 봇
- discord.py
- 아크 플러그인
- DISCORD BOT
Archives
- Today
- Total
Mojangcam
Discord Bot - 명령어 입력하면 AI가 그림그려주기 본문
반응형
Discord 코드 입니다.
import discord
from datetime import datetime
import torch
from torch import autocast
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
loading = 0
def ai_Drawing(promptin):
if loading == 0:
model_id = "Linaqruf/hitokomoru-diffusion-v2"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, low_cpu_memory=False)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cuda")
prompt = f"masterpiece, best quality, high quality, {promptin}"
negative_prompt = "worst quality, low quality, medium quality, deleted, lowres, comic, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, blurry"
with autocast("cuda"):
image = pipe(prompt,
negative_prompt=negative_prompt,
width=512,
height=728,
guidance_scale=12,
num_inference_steps=50).images[0]
image.save(f"AI_Drawing.png")
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as {0}!'.format(self.user))
await self.change_presence(status=discord.Status.online, activity=discord.Game("대기중"))
async def on_message(self, message):
if message.author == self.user:
return
if message.content.startswith('!그림'):
prompt = message.content[4:]
string = ""
for i in prompt:
string += i
print(string)
ai_Drawing(promptin=string)
with open('AI_Drawing.png', 'rb') as f:
picture = discord.File(f)
await message.channel.send(file=picture)
intents = discord.Intents.default()
intents.message_content = True
client = MyClient(intents=intents)
client.run(TOKEN)
Anaconda로 실행을 하셔야 하며, pytorch, diffusers 설치 해야합니다.
저는 gpu버전으로 cuda와 따로 설치를 해서 진행을 했습니다.
명령어는 !그림 [prompt] 입니다.
반응형
'Python' 카테고리의 다른 글
디스코드 봇 만들기 - Slash Command 완전 정복! (0) | 2025.04.14 |
---|---|
디스코드 봇 특정 채널에 메시지 보내기 (3) | 2023.12.22 |
디스코드 봇 임베드 만들기 (1) | 2023.12.22 |
디스코드 봇 공지 명령어 만들기 (0) | 2023.12.16 |
Python - 저항값 구하는 프로그램 코드 (2) | 2023.09.20 |