Spaces:
Runtime error
Runtime error
add application file
Browse files- app.py +58 -0
- requirements.txt +14 -0
app.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import StableDiffusionPipeline, ControlNetModel, StableDiffusionControlNetPipeline
|
3 |
+
from diffusers.utils import load_image
|
4 |
+
import torch
|
5 |
+
import cv2
|
6 |
+
import numpy as np
|
7 |
+
from PIL import Image
|
8 |
+
|
9 |
+
is_show_controlnet = True
|
10 |
+
prompts = ""
|
11 |
+
neg_prompt = "chinese letter"
|
12 |
+
|
13 |
+
repo_id = "calihyper/trad-kor-landscape-black"
|
14 |
+
#pipe = StableDiffusionPipeline.from_pretrained(repo_id).to("mps")
|
15 |
+
|
16 |
+
pipe = StableDiffusionPipeline.from_pretrained(repo_id).to("cuda")
|
17 |
+
|
18 |
+
def change_radio(input):
|
19 |
+
return input
|
20 |
+
|
21 |
+
def output_radio(output):
|
22 |
+
print(output)
|
23 |
+
|
24 |
+
def predict(prompt, style_prompt, neg_prompt, ins, gs, seed):
|
25 |
+
generator = torch.manual_seed(seed)
|
26 |
+
global pipe
|
27 |
+
output = pipe(
|
28 |
+
prompt + style_prompt,
|
29 |
+
negative_prompt=neg_prompt,
|
30 |
+
generator=generator,
|
31 |
+
num_inference_steps=ins,
|
32 |
+
guidance_scale=gs
|
33 |
+
)
|
34 |
+
return output.images[0]
|
35 |
+
|
36 |
+
with gr.Blocks() as demo:
|
37 |
+
gr.Markdown("# Aiffelthon Choosa Project")
|
38 |
+
|
39 |
+
with gr.Row():
|
40 |
+
with gr.Column():
|
41 |
+
out_image = gr.Image(shape=(512,512))
|
42 |
+
with gr.Column() as diff:
|
43 |
+
prompt = gr.Textbox(placeholder="prompts", label="prompt")
|
44 |
+
style_prompt = gr.Textbox(placeholder="style prompts", label="style prompt")
|
45 |
+
examples = gr.Examples(examples=["<trad-kor-landscape-black>", "<trad-kor-landscape-ink-wash-painting>", "<trad-kor-landscape-thick-brush-strokes>", "<trad-kor-plants-black>", "<trad-kor-plants-color>"],
|
46 |
+
inputs=style_prompt, label="style examples")
|
47 |
+
|
48 |
+
neg_prompt = gr.Textbox(placeholder="negative prompts", value=neg_prompt, label="negative prompt")
|
49 |
+
|
50 |
+
ins = gr.Slider(1, 60, 30, label="inference steps")
|
51 |
+
gs = gr.Slider(1, 10, 2.5, step=1, label="guidance scale")
|
52 |
+
|
53 |
+
seed = gr.Slider(0, 10, 2, step=1, label="seed")
|
54 |
+
btn1 = gr.Button("실행")
|
55 |
+
btn1.click(predict, [ prompt, style_prompt, neg_prompt, ins, gs, seed], out_image)
|
56 |
+
|
57 |
+
if __name__ == "__main__":
|
58 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-f https://download.pytorch.org/whl/cpu/torch_stable.html
|
2 |
+
-f https://data.pyg.org/whl/torch-2.0.0+cpu.html
|
3 |
+
torch
|
4 |
+
torchvision
|
5 |
+
diffusers
|
6 |
+
gradio
|
7 |
+
Pillow
|
8 |
+
numpy
|
9 |
+
transformers
|
10 |
+
torchvision
|
11 |
+
ftfy
|
12 |
+
altair
|
13 |
+
opencv-python
|
14 |
+
accelerate
|