Spaces:
Running
on
Zero
Running
on
Zero
alfredplpl
commited on
Commit
•
c8d73ef
1
Parent(s):
114766c
Update app.py
Browse files
app.py
CHANGED
@@ -5,16 +5,25 @@ import spaces
|
|
5 |
import torch
|
6 |
import os
|
7 |
|
|
|
|
|
8 |
model_id = "aipicasso/emi-2"
|
9 |
token=os.environ["TOKEN"]
|
10 |
|
11 |
scheduler = EulerAncestralDiscreteScheduler.from_pretrained(model_id,subfolder="scheduler",token=token)
|
12 |
pipe_normal = StableDiffusionXLPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.bfloat16,token=token)
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
pipe_normal.to("cuda")
|
14 |
|
|
|
15 |
@spaces.GPU
|
16 |
-
def run_normal(prompt, negative_prompt="", guidance_scale=7, progress=gr.Progress(track_tqdm=True)):
|
17 |
-
return pipe_normal(prompt, negative_prompt=negative_prompt, guidance_scale=guidance_scale, num_inference_steps=20).images[0]
|
18 |
|
19 |
css = '''
|
20 |
.gradio-container{
|
@@ -23,14 +32,14 @@ margin: 0 auto;
|
|
23 |
}
|
24 |
'''
|
25 |
|
26 |
-
normal_examples = ["
|
27 |
with gr.Blocks(css=css) as demo:
|
28 |
gr.Markdown('''# Emi 2
|
29 |
Official demo for Emi 2
|
30 |
''')
|
31 |
with gr.Group():
|
32 |
with gr.Row():
|
33 |
-
prompt_normal = gr.Textbox(show_label=False, scale=4, placeholder="Your prompt, e.g.:
|
34 |
button_normal = gr.Button("Generate", min_width=120)
|
35 |
output_normal = gr.Image(label="Your result image", interactive=False)
|
36 |
with gr.Accordion("Advanced Settings", open=False):
|
|
|
5 |
import torch
|
6 |
import os
|
7 |
|
8 |
+
from huggingface_hub import hf_hub_download
|
9 |
+
|
10 |
model_id = "aipicasso/emi-2"
|
11 |
token=os.environ["TOKEN"]
|
12 |
|
13 |
scheduler = EulerAncestralDiscreteScheduler.from_pretrained(model_id,subfolder="scheduler",token=token)
|
14 |
pipe_normal = StableDiffusionXLPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.bfloat16,token=token)
|
15 |
+
|
16 |
+
negative_ti_file = hf_hub_download(repo_id="Aikimi/unaestheticXL_Negative_TI", filename="unaestheticXLv31.safetensors")
|
17 |
+
state_dict = load_file(negative_ti_file)
|
18 |
+
pipe.load_textual_inversion(state_dict["clip_g"], token="unaestheticXLv31", text_encoder=pipe.text_encoder_2, tokenizer=pipe.tokenizer_2)
|
19 |
+
pipe.load_textual_inversion(state_dict["clip_l"], token="unaestheticXLv31", text_encoder=pipe.text_encoder, tokenizer=pipe.tokenizer)
|
20 |
+
|
21 |
pipe_normal.to("cuda")
|
22 |
|
23 |
+
|
24 |
@spaces.GPU
|
25 |
+
def run_normal(prompt, negative_prompt="", guidance_scale=7.5, progress=gr.Progress(track_tqdm=True)):
|
26 |
+
return pipe_normal(prompt, negative_prompt="unaestheticXLv31"+negative_prompt, guidance_scale=guidance_scale, num_inference_steps=20).images[0]
|
27 |
|
28 |
css = '''
|
29 |
.gradio-container{
|
|
|
32 |
}
|
33 |
'''
|
34 |
|
35 |
+
normal_examples = ["1girl, face, brown bob short hair, brown eyes, looking at viewer"]
|
36 |
with gr.Blocks(css=css) as demo:
|
37 |
gr.Markdown('''# Emi 2
|
38 |
Official demo for Emi 2
|
39 |
''')
|
40 |
with gr.Group():
|
41 |
with gr.Row():
|
42 |
+
prompt_normal = gr.Textbox(show_label=False, scale=4, placeholder="Your prompt, e.g.: 1girl, face, brown bob short hair, brown eyes, looking at viewer")
|
43 |
button_normal = gr.Button("Generate", min_width=120)
|
44 |
output_normal = gr.Image(label="Your result image", interactive=False)
|
45 |
with gr.Accordion("Advanced Settings", open=False):
|