Commit 323dd8f1 authored by chenpangpang's avatar chenpangpang
Browse files

feat: gradio页面显示改成中文

parent 807e7a9c
...@@ -234,55 +234,23 @@ logo = r""" ...@@ -234,55 +234,23 @@ logo = r"""
<center><img src='https://photo-maker.github.io/assets/logo.png' alt='PhotoMaker logo' style="width:80px; margin-bottom:10px"></center> <center><img src='https://photo-maker.github.io/assets/logo.png' alt='PhotoMaker logo' style="width:80px; margin-bottom:10px"></center>
""" """
title = r""" title = r"""
<h1 align="center">PhotoMaker V2: Improved ID Fidelity and Better Controllability than PhotoMaker V1</h1> <h1 align="center">PhotoMaker V2:与PhotoMaker V1相比,改进了ID保真度和更好的可控性</h1>
""" """
description = r""" description = r"""
<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> 使用方法可参考🎬 <a href='https://photo-maker.github.io/assets/demo_pm_v2_full.mp4' target='_blank'>这个视频</a> 🎬.<br>
How to use PhotoMaker V2 can be found in 🎬 <a href='https://photo-maker.github.io/assets/demo_pm_v2_full.mp4' target='_blank'>this video</a> 🎬. 个性化步骤:<br>
<br> 1️⃣ 上传您想要自定义的某个人的图像。一张或多张图片都行,建议多张。此工具不进行人脸检测,上传图像中的人脸应该占据图像的大部分。<br>
<br> 2️⃣ 输入文本提示符,确保按照您想要自定义的类单词使用触发词: `img`, 例如: `man img` 、 `woman img` 或 `girl img`。<br>
For previous version of PhotoMaker, you could use our original gradio demos [PhotoMaker](https://huggingface.co/spaces/TencentARC/PhotoMaker) and [PhotoMaker-Style](https://huggingface.co/spaces/TencentARC/PhotoMaker-Style). 3️⃣ 选择您喜欢的风格模板。<br>
<br> 4️⃣ <b>(可选:新特性)</b> 选择“启用绘图涂鸦...”选项,然后在画布上绘图<br>
❗️❗️❗️[<b>Important</b>] Personalization steps:<br> 5️⃣ 单击提交按钮开始自定义。
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>
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>
3️⃣ Choose your preferred style template.<br>
4️⃣ <b>(Optional: but new feature)</b> Select the ‘Enable Drawing Doodle...’ option and draw on the canvas<br>
5️⃣ Click the <b>Submit</b> button to start customizing.
"""
article = r"""
If PhotoMaker V2 is helpful, please help to ⭐ the <a href='https://github.com/TencentARC/PhotoMaker' target='_blank'>Github Repo</a>. Thanks!
[![GitHub Stars](https://img.shields.io/github/stars/TencentARC/PhotoMaker?style=social)](https://github.com/TencentARC/PhotoMaker)
---
📝 **Citation**
<br>
If our work is useful for your research, please consider citing:
```bibtex
@article{li2023photomaker,
title={PhotoMaker: Customizing Realistic Human Photos via Stacked ID Embedding},
author={Li, Zhen and Cao, Mingdeng and Wang, Xintao and Qi, Zhongang and Cheng, Ming-Ming and Shan, Ying},
booktitle={IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2024}
}
```
📋 **License**
<br>
Apache-2.0 LICENSE. Please refer to the [LICENSE file](https://huggingface.co/TencentARC/PhotoMaker/blob/main/LICENSE) for details.
📧 **Contact**
<br>
If you have any questions, please feel free to reach me out at <b>zhenli1031@gmail.com</b>.
""" """
tips = r""" tips = r"""
### Usage tips of PhotoMaker ### 使用技巧
1. Upload **more photos**of the person to be customized to **improve ID fidelty**. 1. 上传多张要定制的人的照片,以**提高身份识别精度**。
2. If you find that the image quality is poor when using doodle for control, you can reduce the conditioning scale and factor of the adapter. 2. 如果您发现使用涂鸦进行控制时图像质量很差,您可以减少`conditioning scale`和`factor of the adapter`。
If you have any issues, leave the issue in the discussion page of the space. For a more stable (queue-free) experience, you can duplicate the space.
""" """
# We have provided some generate examples and comparisons at: [this website](). # We have provided some generate examples and comparisons at: [this website]().
...@@ -301,25 +269,25 @@ with gr.Blocks(css=css) as demo: ...@@ -301,25 +269,25 @@ with gr.Blocks(css=css) as demo:
with gr.Row(): with gr.Row():
with gr.Column(): with gr.Column():
files = gr.Files( files = gr.Files(
label="Drag (Select) 1 or more photos of your face", label="上传/选择一张或多张人脸照片",
file_types=["image"] file_types=["image"]
) )
uploaded_files = gr.Gallery(label="Your images", visible=False, columns=5, rows=1, height=200) uploaded_files = gr.Gallery(label="你的图片", visible=False, columns=5, rows=1, height=200)
with gr.Column(visible=False) as clear_button: with gr.Column(visible=False) as clear_button:
remove_and_reupload = gr.ClearButton(value="Remove and upload new ones", components=files, size="sm") remove_and_reupload = gr.ClearButton(value="移除并重新上传", components=files, size="sm")
prompt = gr.Textbox(label="Prompt", prompt = gr.Textbox(label="Prompt",
info="Try something like 'a photo of a man/woman img', 'img' is the trigger word.", info="尝试类似'a photo of a man/woman img'的词, 'img'是触发词,必须包含",
placeholder="A photo of a [man/woman img]...") placeholder="A photo of a [man/woman img]...")
style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME) style = gr.Dropdown(label="风格", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
aspect_ratio = gr.Dropdown(label="Output aspect ratio", choices=ASPECT_RATIO_LABELS, aspect_ratio = gr.Dropdown(label="输出纵横比", choices=ASPECT_RATIO_LABELS,
value=DEFAULT_ASPECT_RATIO) value=DEFAULT_ASPECT_RATIO)
submit = gr.Button("Submit") submit = gr.Button("提交")
enable_doodle = gr.Checkbox( enable_doodle = gr.Checkbox(
label="Enable Drawing Doodle for Control", value=enable_doodle_arg, label="启用绘图涂鸦进行控制", value=enable_doodle_arg,
info="After enabling this option, PhotoMaker will generate content based on your doodle on the canvas, driven by the T2I-Adapter (Quality may be decreased)", info="启用此选项后,PhotoMaker将通过T2I-Adapter根据您在画布上的涂鸦生成内容(质量可能会降低)",
) )
with gr.Accordion("T2I-Adapter-Doodle (Optional)", visible=False) as doodle_space: with gr.Accordion("T2I-Adapter-涂鸦 (可选)", visible=False) as doodle_space:
with gr.Row(): with gr.Row():
sketch_image = gr.Sketchpad( sketch_image = gr.Sketchpad(
label="Canvas", label="Canvas",
...@@ -345,7 +313,7 @@ with gr.Blocks(css=css) as demo: ...@@ -345,7 +313,7 @@ with gr.Blocks(css=css) as demo:
step=0.1, step=0.1,
value=0.8, value=0.8,
) )
with gr.Accordion(open=False, label="Advanced Options"): with gr.Accordion(open=False, label="高级选项"):
negative_prompt = gr.Textbox( negative_prompt = gr.Textbox(
label="Negative Prompt", label="Negative Prompt",
placeholder="low quality", placeholder="low quality",
...@@ -388,8 +356,8 @@ with gr.Blocks(css=css) as demo: ...@@ -388,8 +356,8 @@ with gr.Blocks(css=css) as demo:
) )
randomize_seed = gr.Checkbox(label="Randomize seed", value=True) randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
with gr.Column(): with gr.Column():
gallery = gr.Gallery(label="Generated Images") gallery = gr.Gallery(label="生成图片")
usage_tips = gr.Markdown(label="Usage tips of PhotoMaker", value=tips, visible=False) usage_tips = gr.Markdown(label="使用技巧", value=tips, visible=False)
files.upload(fn=swap_to_gallery, inputs=files, outputs=[uploaded_files, clear_button, files]) files.upload(fn=swap_to_gallery, inputs=files, outputs=[uploaded_files, clear_button, files])
remove_and_reupload.click(fn=remove_back_to_files, outputs=[uploaded_files, clear_button, files]) remove_and_reupload.click(fn=remove_back_to_files, outputs=[uploaded_files, clear_button, files])
...@@ -435,6 +403,4 @@ with gr.Blocks(css=css) as demo: ...@@ -435,6 +403,4 @@ with gr.Blocks(css=css) as demo:
outputs=[uploaded_files, clear_button, files], outputs=[uploaded_files, clear_button, files],
) )
gr.Markdown(article)
demo.launch(server_name='0.0.0.0', share=True) demo.launch(server_name='0.0.0.0', share=True)
...@@ -10,10 +10,8 @@ ...@@ -10,10 +10,8 @@
"## 说明\n", "## 说明\n",
"- 启动需要加载模型,需要1分钟左右的时间\n", "- 启动需要加载模型,需要1分钟左右的时间\n",
"- 启动和重启 Notebook 点上方工具栏中的「重启并运行所有单元格」。出现如下内容就算成功了:\n", "- 启动和重启 Notebook 点上方工具栏中的「重启并运行所有单元格」。出现如下内容就算成功了:\n",
" - `Running on local URL: http://0.0.0.0:7860`\n",
" - `Running on public URL: https://xxxxxxxxxxxxxxx.gradio.live`\n", " - `Running on public URL: https://xxxxxxxxxxxxxxx.gradio.live`\n",
"- 通过以下方式开启页面:\n", "- 通过以下方式开启页面:\n",
" - 控制台打开「自定义服务」了,访问自定义服务端口号设置为7860\n",
" - 直接打开显示的公开链接`public URL`\n", " - 直接打开显示的公开链接`public URL`\n",
"\n", "\n",
"## 功能介绍\n", "## 功能介绍\n",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment