Commit 00ab9fe9 authored by Paper99's avatar Paper99
Browse files

Fix: solve some environment and demo issues

parent f959a0ea
...@@ -25,7 +25,6 @@ Official implementation of **[PhotoMaker: Customizing Realistic Human Photos via ...@@ -25,7 +25,6 @@ Official implementation of **[PhotoMaker: Customizing Realistic Human Photos via
2. Ensures impressive ID fidelity, offering diversity, promising text controllability, and high-quality generation. 2. Ensures impressive ID fidelity, offering diversity, promising text controllability, and high-quality generation.
3. Can serve as an **Adapter** to collaborate with other Base Models alongside LoRA modules in community. 3. Can serve as an **Adapter** to collaborate with other Base Models alongside LoRA modules in community.
--- ---
<div align="center"> <div align="center">
...@@ -75,7 +74,19 @@ Note: only change the base model and add the LoRA modules for better stylization ...@@ -75,7 +74,19 @@ Note: only change the base model and add the LoRA modules for better stylization
- Python >= 3.8 (Recommend to use [Anaconda](https://www.anaconda.com/download/#linux) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html)) - Python >= 3.8 (Recommend to use [Anaconda](https://www.anaconda.com/download/#linux) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html))
- [PyTorch >= 2.0.0](https://pytorch.org/) - [PyTorch >= 2.0.0](https://pytorch.org/)
```bash ```bash
conda create --name photomaker python=3.10
pip install -U pip
# Install requirements
pip install -r requirements.txt pip install -r requirements.txt
# Install photomaker
pip install git+https://github.com/TencentARC/PhotoMaker.git
```
Then you can run the following command to use it
```python
from photomaker import PhotoMakerStableDiffusionXLPipeline
``` ```
# ⏬ Download Models # ⏬ Download Models
...@@ -98,7 +109,7 @@ import torch ...@@ -98,7 +109,7 @@ import torch
import os import os
from diffusers.utils import load_image from diffusers.utils import load_image
from diffusers import EulerDiscreteScheduler from diffusers import EulerDiscreteScheduler
from photomaker.pipeline import PhotoMakerStableDiffusionXLPipeline from photomaker import PhotoMakerStableDiffusionXLPipeline
### Load base model ### Load base model
pipe = PhotoMakerStableDiffusionXLPipeline.from_pretrained( pipe = PhotoMakerStableDiffusionXLPipeline.from_pretrained(
...@@ -181,7 +192,7 @@ You could customize this script in [this file](gradio_demo/app.py). ...@@ -181,7 +192,7 @@ You could customize this script in [this file](gradio_demo/app.py).
- 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. - 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.
# 🤗 Acknowledgements # 🤗 Acknowledgements
- T2I-Adapter is co-hosted by Tencent ARC Lab and Nankai University [MCG-NKU](https://mmcheng.net/cmm/). - PhotoMaker is co-hosted by Tencent ARC Lab and Nankai University [MCG-NKU](https://mmcheng.net/cmm/).
- Inspired from many excellent demos and repos, including [IP-Adapter](https://github.com/tencent-ailab/IP-Adapter), [multimodalart/Ip-Adapter-FaceID](https://huggingface.co/spaces/multimodalart/Ip-Adapter-FaceID), [FastComposer](https://github.com/mit-han-lab/fastcomposer), and [T2I-Adapter](https://github.com/TencentARC/T2I-Adapter). Thanks for their great works! - Inspired from many excellent demos and repos, including [IP-Adapter](https://github.com/tencent-ailab/IP-Adapter), [multimodalart/Ip-Adapter-FaceID](https://huggingface.co/spaces/multimodalart/Ip-Adapter-FaceID), [FastComposer](https://github.com/mit-han-lab/fastcomposer), and [T2I-Adapter](https://github.com/TencentARC/T2I-Adapter). Thanks for their great works!
- Thanks for Venus team in Tencent PCG for their feedback and suggestions. - Thanks for Venus team in Tencent PCG for their feedback and suggestions.
......
...@@ -10,7 +10,7 @@ from huggingface_hub import hf_hub_download ...@@ -10,7 +10,7 @@ from huggingface_hub import hf_hub_download
import spaces import spaces
import gradio as gr import gradio as gr
from photomaker.pipeline import PhotoMakerStableDiffusionXLPipeline from photomaker import PhotoMakerStableDiffusionXLPipeline
from style_template import styles from style_template import styles
# global variable # global variable
...@@ -28,6 +28,7 @@ pipe = PhotoMakerStableDiffusionXLPipeline.from_pretrained( ...@@ -28,6 +28,7 @@ pipe = PhotoMakerStableDiffusionXLPipeline.from_pretrained(
torch_dtype=torch.bfloat16, torch_dtype=torch.bfloat16,
use_safetensors=True, use_safetensors=True,
variant="fp16", variant="fp16",
# local_files_only=True,
).to(device) ).to(device)
pipe.load_photomaker_adapter( pipe.load_photomaker_adapter(
...@@ -36,6 +37,7 @@ pipe.load_photomaker_adapter( ...@@ -36,6 +37,7 @@ pipe.load_photomaker_adapter(
weight_name=os.path.basename(photomaker_ckpt), weight_name=os.path.basename(photomaker_ckpt),
trigger_word="img" trigger_word="img"
) )
pipe.id_encoder.to(device)
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config) pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
# pipe.set_adapters(["photomaker"], adapter_weights=[1.0]) # pipe.set_adapters(["photomaker"], adapter_weights=[1.0])
...@@ -282,4 +284,4 @@ with gr.Blocks(css=css) as demo: ...@@ -282,4 +284,4 @@ with gr.Blocks(css=css) as demo:
gr.Markdown(article) gr.Markdown(article)
demo.launch() demo.launch(share=False)
\ No newline at end of file \ No newline at end of file
from .model import PhotoMakerIDEncoder
from .pipeline import PhotoMakerStableDiffusionXLPipeline
__all__ = [
"PhotoMakerIDEncoder",
"PhotoMakerStableDiffusionXLPipeline",
]
\ No newline at end of file
...@@ -18,7 +18,7 @@ from diffusers.utils import ( ...@@ -18,7 +18,7 @@ from diffusers.utils import (
logging, logging,
) )
from photomaker.model import PhotoMakerIDEncoder from . import PhotoMakerIDEncoder
PipelineImageInput = Union[ PipelineImageInput = Union[
PIL.Image.Image, PIL.Image.Image,
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
"from diffusers import EulerDiscreteScheduler\n", "from diffusers import EulerDiscreteScheduler\n",
"from huggingface_hub import hf_hub_download\n", "from huggingface_hub import hf_hub_download\n",
"\n", "\n",
"from photomaker.pipeline import PhotoMakerStableDiffusionXLPipeline" "from photomaker import PhotoMakerStableDiffusionXLPipeline"
] ]
}, },
{ {
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
"from diffusers import DDIMScheduler\n", "from diffusers import DDIMScheduler\n",
"from huggingface_hub import hf_hub_download\n", "from huggingface_hub import hf_hub_download\n",
"\n", "\n",
"from photomaker.pipeline import PhotoMakerStableDiffusionXLPipeline" "from photomaker import PhotoMakerStableDiffusionXLPipeline"
] ]
}, },
{ {
[tool.poetry]
name = "photomaker"
version = "0.1.0"
description = "PhotoMaker: Customizing Realistic Human Photos via Stacked ID Embedding"
authors = ["Li, Zhen", "Cao, Mingdeng", "Wang, Xintao", "Qi, Zhongang", "Cheng, Ming-Ming", "Shan, Ying"]
license = "Apache-2.0"
readme = "README.md"
packages = [{ include = "photomaker" }]
[tool.poetry.dependencies]
python = ">=3.7"
[tool.ruff]
line-length = 119
# Deprecation of Cuda 11.6, Python 3.7 support for PyTorch 2.0
target-version = "py38"
# A list of file patterns to omit from linting, in addition to those specified by exclude.
extend-exclude = ["__pycache__", "*.pyc", "*.egg-info", ".cache"]
select = ["E", "F", "W", "C90", "I", "UP", "B", "C4", "RET", "RUF", "SIM"]
ignore = [
"UP006", # UP006: Use list instead of typing.List for type annotations
"UP007", # UP007: Use X | Y for type annotations
"UP009",
"UP035",
"UP038",
"E402",
"RET504",
]
[tool.isort]
profile = "black"
[tool.black]
line-length = 119
skip-string-normalization = 1
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
\ No newline at end of file
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