Spaces:
Runtime error
Runtime error
Delete ap1234.py
#1
by rnlduatm - opened
- .gitattributes +0 -1
- Text2Long_text.py +2 -2
- ap1234.py +0 -7
- app.py +9 -51
- app3.py +3 -44
- dsavv.py +1 -1
- image.py +0 -20
- manual_4cut_comic.py +0 -41
- model/animagine_xl.py +0 -47
- model/animesai.py +0 -23
- model/generate_sdxl_with_refiner.py +0 -39
- model/ghibli.py +0 -18
- model/output_waifu_cpu.png +0 -3
- model/realistic.py +0 -21
- model/sd_turbo.py +0 -21
- model/waifu.py +0 -43
- requirements.txt +0 -8
.gitattributes
CHANGED
|
@@ -33,4 +33,3 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
-
*.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
Text2Long_text.py
CHANGED
|
@@ -9,7 +9,7 @@ tokenizer = AutoTokenizer.from_pretrained("skt/kogpt2-base-v2")
|
|
| 9 |
model = AutoModelForCausalLM.from_pretrained("skt/kogpt2-base-v2").to(device)
|
| 10 |
|
| 11 |
# 3. ํ๊ตญ์ด ์์ค ์์ฑ ํจ์
|
| 12 |
-
def generate_korean_story(prompt, max_length=
|
| 13 |
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
| 14 |
|
| 15 |
outputs = model.generate(
|
|
@@ -31,7 +31,7 @@ def generate_korean_story(prompt, max_length=100):
|
|
| 31 |
# 4. ์คํ
|
| 32 |
if __name__ == "__main__":
|
| 33 |
user_prompt = input("๐ ์์ค์ ์์ ๋ฌธ์ฅ์ ์
๋ ฅํ์ธ์ (ํ๊ตญ์ด): ")
|
| 34 |
-
result = generate_korean_story(user_prompt, max_length=
|
| 35 |
|
| 36 |
print("\n๐ ์์ฑ๋ ํ๊ตญ์ด ์์ค:\n")
|
| 37 |
print(result)
|
|
|
|
| 9 |
model = AutoModelForCausalLM.from_pretrained("skt/kogpt2-base-v2").to(device)
|
| 10 |
|
| 11 |
# 3. ํ๊ตญ์ด ์์ค ์์ฑ ํจ์
|
| 12 |
+
def generate_korean_story(prompt, max_length=300):
|
| 13 |
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
| 14 |
|
| 15 |
outputs = model.generate(
|
|
|
|
| 31 |
# 4. ์คํ
|
| 32 |
if __name__ == "__main__":
|
| 33 |
user_prompt = input("๐ ์์ค์ ์์ ๋ฌธ์ฅ์ ์
๋ ฅํ์ธ์ (ํ๊ตญ์ด): ")
|
| 34 |
+
result = generate_korean_story(user_prompt, max_length=500)
|
| 35 |
|
| 36 |
print("\n๐ ์์ฑ๋ ํ๊ตญ์ด ์์ค:\n")
|
| 37 |
print(result)
|
ap1234.py
DELETED
|
@@ -1,7 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
|
| 3 |
-
def greet(name):
|
| 4 |
-
return "Helloasdfasdf " + name + "!!"
|
| 5 |
-
|
| 6 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -1,57 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from model.animagine_xl import generate_animagine_xl
|
| 3 |
-
from model.animesai import generate_animesai
|
| 4 |
-
from model.generate_sdxl_with_refiner import generate_sdxl_with_refiner
|
| 5 |
-
from model.ghibli import generate_ghibli
|
| 6 |
-
from model.realistic import generate_realistic
|
| 7 |
-
from model.sd_turbo import generate_sd_turbo
|
| 8 |
-
from model.waifu import generate_waifu
|
| 9 |
from Text2Long_text import generate_korean_story
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
"
|
| 17 |
-
"
|
| 18 |
-
|
| 19 |
-
"Ghibli": generate_ghibli,
|
| 20 |
-
"Realistic": generate_realistic,
|
| 21 |
-
"SD Turbo": generate_sd_turbo,
|
| 22 |
-
"Waifu Diffusion": generate_waifu,
|
| 23 |
-
"ํ๊ตญ์ด ๊ธด ์ด์ผ๊ธฐ ์์ฑ": lambda prompt: generate_korean_story(prompt, max_length=100),
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
def generate_story_then_images(prompt, selected_models):
|
| 27 |
-
# 1. ์ ํ์ง ์ค 'ํ๊ตญ์ด ๊ธด ์ด์ผ๊ธฐ ์์ฑ'์ด ํฌํจ๋์ด ์์ผ๋ฉด ๋จผ์ ์คํ ๋ฆฌ๋ฅผ ์์ฑ
|
| 28 |
-
story = ""
|
| 29 |
-
if "ํ๊ตญ์ด ๊ธด ์ด์ผ๊ธฐ ์์ฑ" in selected_models:
|
| 30 |
-
story = generate_korean_story(prompt, max_length=100)
|
| 31 |
-
# 2. ์ด๋ฏธ์ง ์์ฑ ๋ชจ๋ธ๋ค์๋ ์ด์ผ๊ธฐ(์คํ ๋ฆฌ)๊ฐ ์์ผ๋ฉด ๊ทธ๊ฑธ ํ๋กฌํํธ๋ก ๋ฃ์ด์ค
|
| 32 |
-
img_prompt = story if story else prompt
|
| 33 |
-
images = [
|
| 34 |
-
MODEL_FUNCTIONS[name](img_prompt)
|
| 35 |
-
for name in selected_models
|
| 36 |
-
if name != "ํ๊ตญ์ด ๊ธด ์ด์ผ๊ธฐ ์์ฑ"
|
| 37 |
-
]
|
| 38 |
-
return images, story
|
| 39 |
-
|
| 40 |
-
with gr.Blocks() as demo:
|
| 41 |
-
gr.Markdown("## ์ํ๋ ์์ฑ ๋ชจ๋ธ๋ก ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๊ฑฐ๋, ๊ธด ํ๊ตญ์ด ์ด์ผ๊ธฐ๋ฅผ ๋จผ์ ๋ง๋ค๊ณ ๊ทธ ์ด์ผ๊ธฐ๋ก ์ด๋ฏธ์ง๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค.")
|
| 42 |
-
prompt = gr.Textbox(label="ํ๋กฌํํธ(ํ
์คํธ๋ฅผ ์
๋ ฅํ์ธ์)")
|
| 43 |
-
models = gr.CheckboxGroup(
|
| 44 |
-
choices=list(MODEL_FUNCTIONS.keys()),
|
| 45 |
-
label="์ฌ์ฉํ ๋ชจ๋ธ์ ์ ํํ์ธ์"
|
| 46 |
-
)
|
| 47 |
-
gallery = gr.Gallery(label="์์ฑ ์ด๋ฏธ์ง (์ ํํ ๋ชจ๋ธ๋ณ)")
|
| 48 |
-
long_textbox = gr.Textbox(label="์์ฑ๋ ์ด์ผ๊ธฐ(ํ
์คํธ)", lines=10, interactive=False)
|
| 49 |
-
generate_btn = gr.Button("์์ฑํ๊ธฐ")
|
| 50 |
-
|
| 51 |
-
generate_btn.click(
|
| 52 |
-
fn=generate_story_then_images,
|
| 53 |
-
inputs=[prompt, models],
|
| 54 |
-
outputs=[gallery, long_textbox]
|
| 55 |
-
)
|
| 56 |
|
| 57 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from Text2Long_text import generate_korean_story
|
| 3 |
|
| 4 |
+
def make_story(user_prompt):
|
| 5 |
+
# generate_korean_story ํจ์์ ์ ์ ์
๋ ฅ๊ณผ ๊ธธ์ด ์ ๋ฌ
|
| 6 |
+
return generate_korean_story(user_prompt, max_length=500)
|
| 7 |
|
| 8 |
+
# Gradio ์ธํฐํ์ด์ค
|
| 9 |
+
demo = gr.Interface(
|
| 10 |
+
fn=make_story,
|
| 11 |
+
inputs=gr.Textbox(label="ํ๋กฌํํธ(์ด์ผ๊ธฐ ์ฃผ์ ๋๋ ์ฒซ ๋ฌธ์ฅ) ์
๋ ฅ"),
|
| 12 |
+
outputs=gr.Textbox(label="AI๊ฐ ์์ฑํ ๊ธด ํ๊ตญ์ด ์ด์ผ๊ธฐ")
|
| 13 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
demo.launch()
|
app3.py
CHANGED
|
@@ -1,44 +1,3 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
# 1. ๋๋ฐ์ด์ค ์ค์
|
| 6 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 7 |
-
|
| 8 |
-
# 2. ํ๊ตญ์ด GPT-2 ๋ชจ๋ธ๊ณผ ํ ํฌ๋์ด์ ๋ก๋
|
| 9 |
-
tokenizer = AutoTokenizer.from_pretrained("skt/kogpt2-base-v2")
|
| 10 |
-
model = AutoModelForCausalLM.from_pretrained("skt/kogpt2-base-v2").to(device)
|
| 11 |
-
|
| 12 |
-
# 3. ํ๊ตญ์ด ์์ค ์์ฑ ํจ์ (4๋ฌธ์ฅ๋ง ์ถ๋ ฅ)
|
| 13 |
-
def generate_korean_story(prompt, max_length=300, num_sentences=4):
|
| 14 |
-
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
| 15 |
-
|
| 16 |
-
outputs = model.generate(
|
| 17 |
-
input_ids,
|
| 18 |
-
max_length=max_length,
|
| 19 |
-
min_length=100,
|
| 20 |
-
do_sample=True,
|
| 21 |
-
temperature=0.9,
|
| 22 |
-
top_k=50,
|
| 23 |
-
top_p=0.95,
|
| 24 |
-
repetition_penalty=1.2,
|
| 25 |
-
no_repeat_ngram_size=3,
|
| 26 |
-
eos_token_id=tokenizer.eos_token_id
|
| 27 |
-
)
|
| 28 |
-
|
| 29 |
-
full_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 30 |
-
|
| 31 |
-
# ๋ฌธ์ฅ ๋จ์๋ก ์๋ฅด๊ธฐ (์ ๊ทํํ์์ผ๋ก ๋ง์นจํ/๋ฌผ์ํ/๋๋ํ ๊ธฐ์ค)
|
| 32 |
-
sentences = re.split(r'(?<=[.?!])\s+', full_text.strip())
|
| 33 |
-
|
| 34 |
-
# ์์์ 4๋ฌธ์ฅ๋ง ์ ํ ํ ํฉ์น๊ธฐ
|
| 35 |
-
story = " ".join(sentences[:num_sentences])
|
| 36 |
-
return story
|
| 37 |
-
|
| 38 |
-
# 4. ์คํ
|
| 39 |
-
if __name__ == "__main__":
|
| 40 |
-
user_prompt = input("๐ ์์ค์ ์์ ๋ฌธ์ฅ์ ์
๋ ฅํ์ธ์ (ํ๊ตญ์ด): ")
|
| 41 |
-
result = generate_korean_story(user_prompt, max_length=500, num_sentences=4)
|
| 42 |
-
|
| 43 |
-
print("\n๐ ์์ฑ๋ ํ๊ตญ์ด ์์ค (4๋ฌธ์ฅ):\n")
|
| 44 |
-
print(result)
|
|
|
|
| 1 |
+
asdasdasd
|
| 2 |
+
asdasdsa
|
| 3 |
+
asdasdasdas
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dsavv.py
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
fdagabb
|
|
|
|
| 1 |
+
fdagabb
|
image.py
DELETED
|
@@ -1,20 +0,0 @@
|
|
| 1 |
-
from diffusers import StableDiffusionXLPipeline
|
| 2 |
-
import torch
|
| 3 |
-
|
| 4 |
-
# ๋ชจ๋ธ ๋ก๋ (SDXL Base 1.0)
|
| 5 |
-
pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 6 |
-
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 7 |
-
torch_dtype=torch.float16,
|
| 8 |
-
variant="fp16",
|
| 9 |
-
use_safetensors=True
|
| 10 |
-
).to("cuda")
|
| 11 |
-
|
| 12 |
-
# ํ
์คํธ ํ๋กฌํํธ
|
| 13 |
-
prompt = '๊ทธ๋
๋ฅผ ๋ฐ๋ผ๋ณด๋ ํ ๋จ์์ ์ผ๋ง'
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# ์ด๋ฏธ์ง ์์ฑ
|
| 17 |
-
image = pipe(prompt=prompt).images[0]
|
| 18 |
-
image.save("output_scene2.png")
|
| 19 |
-
print("โ
์ด๋ฏธ์ง ์ ์ฅ ์๋ฃ: output_scene2.png")
|
| 20 |
-
print("ํ์ธ์ฉ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
manual_4cut_comic.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
from diffusers import StableDiffusionPipeline
|
| 2 |
-
import torch
|
| 3 |
-
from PIL import Image
|
| 4 |
-
import os
|
| 5 |
-
|
| 6 |
-
# ์ด๋ฏธ์ง ์์ฑ ํ์ดํ๋ผ์ธ
|
| 7 |
-
image_gen = StableDiffusionPipeline.from_pretrained(
|
| 8 |
-
"CompVis/stable-diffusion-v1-4",
|
| 9 |
-
torch_dtype=torch.float16,
|
| 10 |
-
).to("cuda" if torch.cuda.is_available() else "cpu")
|
| 11 |
-
|
| 12 |
-
def generate_comic_manual(cuts, output_dir="comic_outputs"):
|
| 13 |
-
"""
|
| 14 |
-
cuts: 4๊ฐ์ ํ
์คํธ(์ปท ์ค๋ช
)๊ฐ ๋ด๊ธด ๋ฆฌ์คํธ
|
| 15 |
-
"""
|
| 16 |
-
if len(cuts) != 4:
|
| 17 |
-
raise ValueError("์ ํํ 4๊ฐ์ ์ปท ์ค๋ช
์ ์
๋ ฅํด์ฃผ์ธ์.")
|
| 18 |
-
|
| 19 |
-
os.makedirs(output_dir, exist_ok=True)
|
| 20 |
-
|
| 21 |
-
image_paths = []
|
| 22 |
-
for i, cut in enumerate(cuts):
|
| 23 |
-
print(f"์ปท {i+1}: {cut}")
|
| 24 |
-
image = image_gen(cut).images[0]
|
| 25 |
-
path = os.path.join(output_dir, f"cut_{i+1}.png")
|
| 26 |
-
image.save(path)
|
| 27 |
-
image_paths.append(path)
|
| 28 |
-
|
| 29 |
-
print(f"\nโ
์ ์ฅ ์๋ฃ! ์ด {len(image_paths)}์ฅ์ ์ปท์ด ์์ฑ๋์์ต๋๋ค.")
|
| 30 |
-
return image_paths
|
| 31 |
-
|
| 32 |
-
# ์ฌ์ฉ ์์
|
| 33 |
-
if __name__ == "__main__":
|
| 34 |
-
cuts = [
|
| 35 |
-
"A cat launches in a rocket into space",
|
| 36 |
-
"A cat arrives on an alien planet",
|
| 37 |
-
"The cat meets a robot friend",
|
| 38 |
-
"The cat returns to Earth and writes in a diary"
|
| 39 |
-
]
|
| 40 |
-
|
| 41 |
-
generate_comic_manual(cuts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model/animagine_xl.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
| 1 |
-
# from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
|
| 2 |
-
# import torch
|
| 3 |
-
|
| 4 |
-
# def generate_animagine_xl(prompt: str):
|
| 5 |
-
# model_id = "Linaqruf/animagine-xl"
|
| 6 |
-
# pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 7 |
-
# model_id,
|
| 8 |
-
# torch_dtype=torch.float16,
|
| 9 |
-
# use_safetensors=True,
|
| 10 |
-
# variant="fp16"
|
| 11 |
-
# )
|
| 12 |
-
# pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 13 |
-
# pipe = pipe.to("cuda")
|
| 14 |
-
# image = pipe(prompt=prompt, width=1024, height=1024).images[0]
|
| 15 |
-
# image.save("output_animagine_xl.png")
|
| 16 |
-
# print("โ
์ ์ฅ ์๋ฃ: output_animagine_xl.png")
|
| 17 |
-
# return image
|
| 18 |
-
|
| 19 |
-
# if __name__ == "__main__":
|
| 20 |
-
# prompt = "๊ทธ๋
๋ฅผ ๋ฐ๋ผ๋ณด๋ ํ ๋จ์์ ์ผ๋ง"
|
| 21 |
-
# generate_animagine_xl(prompt)
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
|
| 25 |
-
import torch
|
| 26 |
-
|
| 27 |
-
# (1) ๋ชจ๋ธ๊ณผ ์ค์ผ์ค๋ฌ๋ฅผ ์ ์ญ์์ ํ ๋ฒ๋ง ์ด๊ธฐํ
|
| 28 |
-
model_id = "Linaqruf/animagine-xl"
|
| 29 |
-
pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 30 |
-
model_id,
|
| 31 |
-
torch_dtype=torch.float16,
|
| 32 |
-
use_safetensors=True,
|
| 33 |
-
variant="fp16"
|
| 34 |
-
)
|
| 35 |
-
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 36 |
-
pipe = pipe.to("cpu") # ๋๋ "cpu"๋ก ๋ณ๊ฒฝ ๊ฐ๋ฅ
|
| 37 |
-
|
| 38 |
-
# (2) ์ด๋ฏธ์ง ์์ฑ ํจ์
|
| 39 |
-
def generate_animagine_xl(prompt: str):
|
| 40 |
-
image = pipe(prompt=prompt, width=1024, height=1024).images[0]
|
| 41 |
-
image.save("output_animagine_xl.png")
|
| 42 |
-
print("โ
์ ์ฅ ์๋ฃ: output_animagine_xl.png")
|
| 43 |
-
return image
|
| 44 |
-
|
| 45 |
-
if __name__ == "__main__":
|
| 46 |
-
prompt = "๊ทธ๋
๋ฅผ ๋ฐ๋ผ๋ณด๋ ํ ๋จ์์ ์ผ๋ง"
|
| 47 |
-
generate_animagine_xl(prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model/animesai.py
DELETED
|
@@ -1,23 +0,0 @@
|
|
| 1 |
-
from diffusers import StableDiffusionXLPipeline, AutoencoderKL
|
| 2 |
-
import torch
|
| 3 |
-
|
| 4 |
-
def generate_animesai(prompt: str):
|
| 5 |
-
model_id = "enhanceaiteam/AnimeSAI"
|
| 6 |
-
vae = AutoencoderKL.from_pretrained(
|
| 7 |
-
"madebyollin/sdxl-vae-fp16-fix",
|
| 8 |
-
torch_dtype=torch.float16
|
| 9 |
-
).to("cuda")
|
| 10 |
-
pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 11 |
-
model_id,
|
| 12 |
-
vae=vae,
|
| 13 |
-
torch_dtype=torch.float16,
|
| 14 |
-
use_safetensors=True
|
| 15 |
-
).to("cuda")
|
| 16 |
-
image = pipe(prompt=prompt, width=1024, height=1024, guidance_scale=7).images[0]
|
| 17 |
-
image.save("output_animesai.png")
|
| 18 |
-
print("โ
์ ์ฅ ์๋ฃ: output_animesai.png")
|
| 19 |
-
return image
|
| 20 |
-
|
| 21 |
-
if __name__ == "__main__":
|
| 22 |
-
prompt = "๊ทธ๋
๋ฅผ ๋ฐ๋ผ๋ณด๋ ํ ๋จ์์ ์ผ๋ง"
|
| 23 |
-
generate_animesai(prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model/generate_sdxl_with_refiner.py
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
from diffusers import StableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline
|
| 2 |
-
import torch
|
| 3 |
-
from PIL import Image
|
| 4 |
-
|
| 5 |
-
def generate_sdxl_with_refiner(prompt: str):
|
| 6 |
-
# 1๋จ๊ณ: Base ๋ชจ๋ธ๋ก ์ด๊ธฐ ์ด๋ฏธ์ง ์์ฑ
|
| 7 |
-
base_model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
| 8 |
-
base_pipe = StableDiffusionXLPipeline.from_pretrained(
|
| 9 |
-
base_model_id,
|
| 10 |
-
torch_dtype=torch.float16,
|
| 11 |
-
variant="fp16",
|
| 12 |
-
use_safetensors=True
|
| 13 |
-
).to("cuda")
|
| 14 |
-
|
| 15 |
-
base_image = base_pipe(prompt=prompt, num_inference_steps=30).images[0]
|
| 16 |
-
|
| 17 |
-
# 2๋จ๊ณ: Refiner ๋ชจ๋ธ๋ก ์ด๋ฏธ์ง ๊ฐ์
|
| 18 |
-
refiner_model_id = "stabilityai/stable-diffusion-xl-refiner-1.0"
|
| 19 |
-
refiner_pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
|
| 20 |
-
refiner_model_id,
|
| 21 |
-
torch_dtype=torch.float16,
|
| 22 |
-
variant="fp16",
|
| 23 |
-
use_safetensors=True
|
| 24 |
-
).to("cuda")
|
| 25 |
-
|
| 26 |
-
# Refiner๋ PIL ์ด๋ฏธ์ง๋ฅผ ์
๋ ฅ๋ฐ์ ํ์ฒ๋ฆฌ
|
| 27 |
-
refined_image = refiner_pipe(
|
| 28 |
-
prompt=prompt,
|
| 29 |
-
image=base_image,
|
| 30 |
-
strength=0.3 # ์ผ๋ง๋ ๋ง์ด ๋ณด์ ํ ์ง (0~1)
|
| 31 |
-
).images[0]
|
| 32 |
-
|
| 33 |
-
refined_image.save("output_sdxl_refined.png")
|
| 34 |
-
return refined_image
|
| 35 |
-
|
| 36 |
-
if __name__ == "__main__":
|
| 37 |
-
prompt = '๊ทธ๋
๋ฅผ ๋ฐ๋ผ๋ณด๋ ํ ๋จ์์ ์ผ๋ง'
|
| 38 |
-
img = generate_sdxl_with_refiner(prompt)
|
| 39 |
-
img.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model/ghibli.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
from diffusers import StableDiffusionPipeline
|
| 2 |
-
import torch
|
| 3 |
-
|
| 4 |
-
def generate_ghibli(prompt: str):
|
| 5 |
-
model_id = "nitrosocke/Ghibli-Diffusion"
|
| 6 |
-
pipe = StableDiffusionPipeline.from_pretrained(
|
| 7 |
-
model_id,
|
| 8 |
-
torch_dtype=torch.float16,
|
| 9 |
-
use_safetensors=True
|
| 10 |
-
).to("cuda")
|
| 11 |
-
image = pipe(prompt=prompt).images[0]
|
| 12 |
-
image.save("output_ghibli.png")
|
| 13 |
-
print("โ
์ ์ฅ ์๋ฃ: output_ghibli.png")
|
| 14 |
-
return image
|
| 15 |
-
|
| 16 |
-
if __name__ == "__main__":
|
| 17 |
-
prompt = "๊ทธ๋
๋ฅผ ๋ฐ๋ผ๋ณด๋ ํ ๋จ์์ ์ผ๋ง"
|
| 18 |
-
generate_ghibli(prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model/output_waifu_cpu.png
DELETED
Git LFS Details
|
model/realistic.py
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
from diffusers import StableDiffusionPipeline
|
| 2 |
-
import torch
|
| 3 |
-
|
| 4 |
-
def generate_realistic(prompt: str):
|
| 5 |
-
model_id = "SG161222/Realistic_Vision_V6.0_B1_noVAE"
|
| 6 |
-
pipe = StableDiffusionPipeline.from_pretrained(
|
| 7 |
-
model_id,
|
| 8 |
-
torch_dtype=torch.float16,
|
| 9 |
-
use_safetensors=False,
|
| 10 |
-
# variant="fp16"
|
| 11 |
-
).to("cuda")
|
| 12 |
-
|
| 13 |
-
image = pipe(prompt=prompt).images[0]
|
| 14 |
-
return image
|
| 15 |
-
|
| 16 |
-
if __name__ == "__main__":
|
| 17 |
-
prompt = '๊ทธ๋
๋ฅผ ๋ฐ๋ผ๋ณด๋ ํ ๋จ์์ ์ผ๋ง'
|
| 18 |
-
image = generate_realistic(prompt)
|
| 19 |
-
image.save("output_realistic.png")
|
| 20 |
-
print("โ
์ ์ฅ ์๋ฃ: output_realistic.png")
|
| 21 |
-
image.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model/sd_turbo.py
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
from diffusers import StableDiffusionPipeline
|
| 2 |
-
import torch
|
| 3 |
-
|
| 4 |
-
def generate_sd_turbo(prompt: str):
|
| 5 |
-
model_id = "stabilityai/sd-turbo"
|
| 6 |
-
|
| 7 |
-
pipe = StableDiffusionPipeline.from_pretrained(
|
| 8 |
-
model_id,
|
| 9 |
-
torch_dtype=torch.float16,
|
| 10 |
-
use_safetensors=True
|
| 11 |
-
).to("cuda")
|
| 12 |
-
|
| 13 |
-
image = pipe(prompt=prompt, guidance_scale=0.0).images[0]
|
| 14 |
-
image.save("output_sd_turbo.png")
|
| 15 |
-
return image
|
| 16 |
-
|
| 17 |
-
if __name__ == "__main__":
|
| 18 |
-
prompt = "๊ทธ๋
๋ฅผ ๋ฐ๋ผ๋ณด๋ ํ ๋จ์์ ์ผ๋ง"
|
| 19 |
-
img = generate_sd_turbo(prompt)
|
| 20 |
-
print("โ
์ ์ฅ ์๋ฃ: output_sd_turbo.png")
|
| 21 |
-
img.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model/waifu.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
| 1 |
-
# from diffusers import StableDiffusionPipeline
|
| 2 |
-
# import torch
|
| 3 |
-
|
| 4 |
-
# def generate_waifu(prompt: str):
|
| 5 |
-
# model_id = "hakurei/waifu-diffusion"
|
| 6 |
-
# pipe = StableDiffusionPipeline.from_pretrained(
|
| 7 |
-
# model_id,
|
| 8 |
-
# torch_dtype=torch.float16,
|
| 9 |
-
# use_safetensors=False,
|
| 10 |
-
# revision="fp16"
|
| 11 |
-
# ).to("cuda")
|
| 12 |
-
|
| 13 |
-
# image = pipe(prompt=prompt).images[0]
|
| 14 |
-
# return image
|
| 15 |
-
|
| 16 |
-
# if __name__ == "__main__":
|
| 17 |
-
# prompt = '๊ทธ๋
๋ฅผ ๋ฐ๋ผ๋ณด๋ ํ ๋จ์์ ์ผ๋ง'
|
| 18 |
-
# image = generate_waifu(prompt)
|
| 19 |
-
# image.save("output_waifu.png")
|
| 20 |
-
# print("โ
์ ์ฅ ์๋ฃ: output_waifu.png")
|
| 21 |
-
# image.show()
|
| 22 |
-
|
| 23 |
-
from diffusers import StableDiffusionPipeline
|
| 24 |
-
import torch
|
| 25 |
-
|
| 26 |
-
model_id = "hakurei/waifu-diffusion"
|
| 27 |
-
pipe = StableDiffusionPipeline.from_pretrained(
|
| 28 |
-
model_id,
|
| 29 |
-
torch_dtype=torch.float32,
|
| 30 |
-
use_safetensors=False
|
| 31 |
-
).to("cpu") # CPU๋ก ๋ช
์
|
| 32 |
-
|
| 33 |
-
def generate_waifu(prompt: str):
|
| 34 |
-
image = pipe(prompt=prompt).images[0]
|
| 35 |
-
return image
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
if __name__ == "__main__":
|
| 39 |
-
prompt = '๊ทธ๋
๋ฅผ ๋ฐ๋ผ๋ณด๋ ํ ๋จ์์ ์ผ๋ง'
|
| 40 |
-
image = generate_waifu(prompt)
|
| 41 |
-
image.save("output_waifu_cpu.png")
|
| 42 |
-
print("โ
์ ์ฅ ์๋ฃ: output_waifu_cpu.png")
|
| 43 |
-
image.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
DELETED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
torch
|
| 2 |
-
gradio
|
| 3 |
-
transformers
|
| 4 |
-
diffusers
|
| 5 |
-
Pillow
|
| 6 |
-
accelerate
|
| 7 |
-
safetensors
|
| 8 |
-
scipy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|