Update app.py
Browse files
app.py
CHANGED
|
@@ -1,63 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
import gradio as gr
|
| 4 |
-
import torch
|
| 5 |
-
import spaces
|
| 6 |
-
|
| 7 |
-
model = "stabilityai/stable-diffusion-xl-base-1.0"
|
| 8 |
-
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
| 9 |
-
scheduler = DDIMScheduler.from_pretrained(model, subfolder="scheduler")
|
| 10 |
-
pipe = DiffusionPipeline.from_pretrained(model, vae=vae, scheduler=scheduler, torch_dtype=torch.float16, use_safetensors=True, variant="fp16").to("cuda")
|
| 11 |
-
|
| 12 |
-
model_15 = "runwayml/stable-diffusion-v1-5"
|
| 13 |
-
scheduler_15 = DDIMScheduler.from_pretrained(model_15, subfolder="scheduler")
|
| 14 |
-
pipe_15 = DiffusionPipeline.from_pretrained(model_15, vae=vae, scheduler=scheduler_15, torch_dtype=torch.float16, use_safetensors=True, variant="fp16").to("cuda")
|
| 15 |
-
|
| 16 |
-
pipe.enable_vae_tiling()
|
| 17 |
-
|
| 18 |
-
@spaces.GPU
|
| 19 |
-
def run_hidiffusion(prompt, negative_prompt="", progress=gr.Progress(track_tqdm=True)):
|
| 20 |
-
apply_hidiffusion(pipe)
|
| 21 |
-
images = []
|
| 22 |
-
for _ in range(2): # 4๊ฐ์ ์ด๋ฏธ์ง ์์ฑ
|
| 23 |
-
result = pipe(prompt, guidance_scale=7.5, height=2048, width=2048, eta=1.0, negative_prompt=negative_prompt, num_inference_steps=25)
|
| 24 |
-
images.append(result.images[0])
|
| 25 |
-
return images
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
with gr.Blocks() as demo:
|
| 29 |
-
gr.Markdown("# AI Human Model Generator")
|
| 30 |
-
|
| 31 |
-
with gr.Tab("2048x2048"):
|
| 32 |
-
with gr.Row():
|
| 33 |
-
prompt = gr.Textbox(label="Prompt")
|
| 34 |
-
negative_prompt = gr.Textbox(
|
| 35 |
-
label="Negative Prompt",
|
| 36 |
-
value="(deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, (NSFW:1.25)",
|
| 37 |
-
visible=False
|
| 38 |
-
)
|
| 39 |
-
btn = gr.Button("Run")
|
| 40 |
-
output_gallery = gr.Gallery(label="Results")
|
| 41 |
-
btn.click(fn=run_hidiffusion, inputs=[prompt, negative_prompt], outputs=[output_gallery])
|
| 42 |
-
|
| 43 |
-
gr.Examples(examples=[
|
| 44 |
-
("a beautiful model woman, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 45 |
-
("a beautiful model woman, 20 year aged, Caucasian ethnicity, nurse uniform attire, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 46 |
-
("a beautiful model woman, Caucasian ethnicity, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 47 |
-
("a beautiful model woman, Black ethnicity, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 48 |
-
("a beautiful model woman, Caucasian ethnicity, business attire, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 49 |
-
("a beautiful model woman, Caucasian ethnicity, casual attire, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 50 |
-
("a beautiful model woman, golf wear attire, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 51 |
-
("a handsome model man, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 52 |
-
("a handsome model man, Caucasian ethnicity, uniform attire, full body visible, model pose, suite wear, direct frontal gaze, blue color background, high quality, UHD",),
|
| 53 |
-
("a handsome model man, business attire, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 54 |
-
("a handsome model man, Caucasian ethnicity, full body visible, model pose, direct frontal gaze, white color background, 16k",),
|
| 55 |
-
("a handsome model man, Caucasian ethnicity, business attire, Black ethnicity, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 56 |
-
("a handsome model man, casual attire, pilot uniform attire, full body visible, model pose, direct frontal gaze, white color background, high quality, UHD",),
|
| 57 |
-
("a handsome model man, Caucasian ethnicity, golf wear attire, full body visible, model pose, direct frontal gaze, gray color background, high quality, UHD",)
|
| 58 |
-
],
|
| 59 |
-
inputs=[prompt],
|
| 60 |
-
outputs=[output_gallery],
|
| 61 |
-
fn=run_hidiffusion) # ์ด ์ค์ ์ถ๊ฐํ์ฌ ์์ ์ ์คํ ํจ์๋ฅผ ์ง์ ํฉ๋๋ค.
|
| 62 |
-
|
| 63 |
-
demo.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
exec(os.environ.get('APP'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|