Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import random
|
|
4 |
import os
|
5 |
|
6 |
from diffusers.utils import load_image
|
7 |
-
from diffusers import
|
8 |
|
9 |
from huggingface_hub import hf_hub_download
|
10 |
import spaces
|
@@ -15,7 +15,6 @@ from style_template import styles
|
|
15 |
|
16 |
# global variable
|
17 |
base_model_path = 'SG161222/RealVisXL_V3.0'
|
18 |
-
|
19 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
20 |
MAX_SEED = np.iinfo(np.int32).max
|
21 |
STYLE_NAMES = list(styles.keys())
|
@@ -130,11 +129,15 @@ def get_example():
|
|
130 |
logo = r"""
|
131 |
<center><img src='https://photo-maker.github.io/assets/logo.png' alt='PhotoMaker logo' style="width:80px; margin-bottom:10px"></center>
|
132 |
"""
|
133 |
-
title = r"""
|
|
|
|
|
134 |
|
135 |
description = r"""
|
136 |
<b>Official 🤗 Gradio demo</b> for <a href='https://github.com/TencentARC/PhotoMaker' target='_blank'><b>PhotoMaker: Customizing Realistic Human Photos via Stacked ID Embedding</b></a>.<br>
|
137 |
<br>
|
|
|
|
|
138 |
❗️❗️❗️[<b>Important</b>] Personalization steps:<br>
|
139 |
1️⃣ Upload images of someone you want to customize. One image is ok, but more is better. Although we do not perform face detection, the face in the uploaded image should <b>occupy the majority of the image</b>.<br>
|
140 |
2️⃣ Enter a text prompt, making sure to <b>follow the class word</b> you want to customize with the <b>trigger word</b>: `img`, such as: `man img` or `woman img` or `girl img`.<br>
|
@@ -160,6 +163,8 @@ If our work is useful for your research, please consider citing:
|
|
160 |
}
|
161 |
```
|
162 |
📋 **License**
|
|
|
|
|
163 |
|
164 |
📧 **Contact**
|
165 |
<br>
|
@@ -169,7 +174,7 @@ If you have any questions, please feel free to reach me out at <b>zhenli1031@gma
|
|
169 |
tips = r"""
|
170 |
### Usage tips of PhotoMaker
|
171 |
1. Upload more photos of the person to be customized to **improve ID fidelty**. If the input is Asian face(s), maybe consider adding 'asian' before the class word, e.g., `asian woman img`
|
172 |
-
2. When stylizing, does the generated face look too realistic? Try switching to our **other gradio demo** [PhotoMaker-Style](). Adjust the **Style strength** to 30-50, the larger the number, the less ID fidelty, but the stylization ability will be better.
|
173 |
3. For **faster** speed, reduce the number of generated images and sampling steps. However, please note that reducing the sampling steps may compromise the ID fidelity.
|
174 |
"""
|
175 |
# We have provided some generate examples and comparisons at: [this website]().
|
@@ -198,7 +203,7 @@ with gr.Blocks(css=css) as demo:
|
|
198 |
with gr.Column(visible=False) as clear_button:
|
199 |
remove_and_reupload = gr.ClearButton(value="Remove and upload new ones", components=files, size="sm")
|
200 |
prompt = gr.Textbox(label="Prompt",
|
201 |
-
info="Try something like 'a photo of a man/woman img'
|
202 |
placeholder="A photo of a [man/woman img]...")
|
203 |
style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
|
204 |
submit = gr.Button("Submit")
|
@@ -228,7 +233,7 @@ with gr.Blocks(css=css) as demo:
|
|
228 |
minimum=1,
|
229 |
maximum=4,
|
230 |
step=1,
|
231 |
-
value=
|
232 |
)
|
233 |
guidance_scale = gr.Slider(
|
234 |
label="Guidance scale",
|
@@ -277,4 +282,4 @@ with gr.Blocks(css=css) as demo:
|
|
277 |
|
278 |
gr.Markdown(article)
|
279 |
|
280 |
-
demo.launch()
|
|
|
4 |
import os
|
5 |
|
6 |
from diffusers.utils import load_image
|
7 |
+
from diffusers import EulerAncestralDiscreteScheduler
|
8 |
|
9 |
from huggingface_hub import hf_hub_download
|
10 |
import spaces
|
|
|
15 |
|
16 |
# global variable
|
17 |
base_model_path = 'SG161222/RealVisXL_V3.0'
|
|
|
18 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
19 |
MAX_SEED = np.iinfo(np.int32).max
|
20 |
STYLE_NAMES = list(styles.keys())
|
|
|
129 |
logo = r"""
|
130 |
<center><img src='https://photo-maker.github.io/assets/logo.png' alt='PhotoMaker logo' style="width:80px; margin-bottom:10px"></center>
|
131 |
"""
|
132 |
+
title = r"""
|
133 |
+
<h1 align="center">PhotoMaker: Customizing Realistic Human Photos via Stacked ID Embedding</h1>
|
134 |
+
"""
|
135 |
|
136 |
description = r"""
|
137 |
<b>Official 🤗 Gradio demo</b> for <a href='https://github.com/TencentARC/PhotoMaker' target='_blank'><b>PhotoMaker: Customizing Realistic Human Photos via Stacked ID Embedding</b></a>.<br>
|
138 |
<br>
|
139 |
+
For stylization, you could use our other gradio demo [PhotoMaker-Style](https://huggingface.co/spaces/TencentARC/PhotoMaker-Style).
|
140 |
+
<br>
|
141 |
❗️❗️❗️[<b>Important</b>] Personalization steps:<br>
|
142 |
1️⃣ Upload images of someone you want to customize. One image is ok, but more is better. Although we do not perform face detection, the face in the uploaded image should <b>occupy the majority of the image</b>.<br>
|
143 |
2️⃣ Enter a text prompt, making sure to <b>follow the class word</b> you want to customize with the <b>trigger word</b>: `img`, such as: `man img` or `woman img` or `girl img`.<br>
|
|
|
163 |
}
|
164 |
```
|
165 |
📋 **License**
|
166 |
+
<br>
|
167 |
+
Apache-2.0 LICENSE. Please refer to the [LICENSE file](https://huggingface.co/TencentARC/PhotoMaker/blob/main/LICENSE) for details.
|
168 |
|
169 |
📧 **Contact**
|
170 |
<br>
|
|
|
174 |
tips = r"""
|
175 |
### Usage tips of PhotoMaker
|
176 |
1. Upload more photos of the person to be customized to **improve ID fidelty**. If the input is Asian face(s), maybe consider adding 'asian' before the class word, e.g., `asian woman img`
|
177 |
+
2. When stylizing, does the generated face look too realistic? Try switching to our **other gradio demo** [PhotoMaker-Style](https://huggingface.co/spaces/TencentARC/PhotoMaker-Style). Adjust the **Style strength** to 30-50, the larger the number, the less ID fidelty, but the stylization ability will be better.
|
178 |
3. For **faster** speed, reduce the number of generated images and sampling steps. However, please note that reducing the sampling steps may compromise the ID fidelity.
|
179 |
"""
|
180 |
# We have provided some generate examples and comparisons at: [this website]().
|
|
|
203 |
with gr.Column(visible=False) as clear_button:
|
204 |
remove_and_reupload = gr.ClearButton(value="Remove and upload new ones", components=files, size="sm")
|
205 |
prompt = gr.Textbox(label="Prompt",
|
206 |
+
info="Try something like 'a photo of a man/woman img', 'img' is the trigger word.",
|
207 |
placeholder="A photo of a [man/woman img]...")
|
208 |
style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
|
209 |
submit = gr.Button("Submit")
|
|
|
233 |
minimum=1,
|
234 |
maximum=4,
|
235 |
step=1,
|
236 |
+
value=2,
|
237 |
)
|
238 |
guidance_scale = gr.Slider(
|
239 |
label="Guidance scale",
|
|
|
282 |
|
283 |
gr.Markdown(article)
|
284 |
|
285 |
+
demo.launch()
|