Spaces:
Sleeping
Sleeping
kevinppaulo
commited on
Commit
·
60f4c58
1
Parent(s):
03aac7c
WIP
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ from flux.util import load_ae, load_clip, load_flow_model, load_t5
|
|
14 |
from pulid.pipeline_flux import PuLIDPipeline
|
15 |
from pulid.utils import resize_numpy_image_long
|
16 |
|
17 |
-
NSFW_THRESHOLD = 0
|
18 |
|
19 |
def get_models(name: str, device: torch.device, offload: bool):
|
20 |
t5 = load_t5(device, max_length=128)
|
@@ -150,12 +150,8 @@ def generate_image(
|
|
150 |
x = rearrange(x[0], "c h w -> h w c")
|
151 |
|
152 |
img = Image.fromarray((127.5 * (x + 1.0)).cpu().byte().numpy())
|
153 |
-
|
154 |
-
|
155 |
-
return img, str(opts.seed), flux_generator.pulid_model.debug_img_list
|
156 |
-
else:
|
157 |
-
return (None, f"Your generated image may contain NSFW (with nsfw_score: {nsfw_score}) content",
|
158 |
-
flux_generator.pulid_model.debug_img_list)
|
159 |
|
160 |
_HEADER_ = '''
|
161 |
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
@@ -164,7 +160,7 @@ _HEADER_ = '''
|
|
164 |
</div>
|
165 |
|
166 |
❗️❗️❗️**Tips:**
|
167 |
-
|
168 |
- `timestep to start inserting ID:` The smaller the value, the higher the fidelity, but the lower the editability; the higher the value, the lower the fidelity, but the higher the editability. **The recommended range for this value is between 0 and 4**. For photorealistic scenes, we recommend using 4; for stylized scenes, we recommend using 0-1. If you are not satisfied with the similarity, you can lower this value; conversely, if you are not satisfied with the editability, you can increase this value.
|
169 |
- `true CFG scale:` In most scenarios, it is recommended to use a fake CFG, i.e., setting the true CFG scale to 1, and just adjusting the guidance scale. This is also more efficiency. However, in a few cases, utilizing a true CFG can yield better results. For more detaileds, please refer to the [doc](https://github.com/ToTheBeginning/PuLID/blob/main/docs/pulid_for_flux.md#useful-tips).
|
170 |
- `Learn more about the model:` please refer to the <a href='https://github.com/ToTheBeginning/PuLID/blob/main/docs/pulid_for_flux.md' target='_blank'>github doc</a> for more details and info about the model, we provide the detail explanation about the above two parameters in the doc.
|
|
|
14 |
from pulid.pipeline_flux import PuLIDPipeline
|
15 |
from pulid.utils import resize_numpy_image_long
|
16 |
|
17 |
+
NSFW_THRESHOLD = 100.0
|
18 |
|
19 |
def get_models(name: str, device: torch.device, offload: bool):
|
20 |
t5 = load_t5(device, max_length=128)
|
|
|
150 |
x = rearrange(x[0], "c h w -> h w c")
|
151 |
|
152 |
img = Image.fromarray((127.5 * (x + 1.0)).cpu().byte().numpy())
|
153 |
+
return img, str(opts.seed), flux_generator.pulid_model.debug_img_list
|
154 |
+
|
|
|
|
|
|
|
|
|
155 |
|
156 |
_HEADER_ = '''
|
157 |
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
|
|
160 |
</div>
|
161 |
|
162 |
❗️❗️❗️**Tips:**
|
163 |
+
KP Version)
|
164 |
- `timestep to start inserting ID:` The smaller the value, the higher the fidelity, but the lower the editability; the higher the value, the lower the fidelity, but the higher the editability. **The recommended range for this value is between 0 and 4**. For photorealistic scenes, we recommend using 4; for stylized scenes, we recommend using 0-1. If you are not satisfied with the similarity, you can lower this value; conversely, if you are not satisfied with the editability, you can increase this value.
|
165 |
- `true CFG scale:` In most scenarios, it is recommended to use a fake CFG, i.e., setting the true CFG scale to 1, and just adjusting the guidance scale. This is also more efficiency. However, in a few cases, utilizing a true CFG can yield better results. For more detaileds, please refer to the [doc](https://github.com/ToTheBeginning/PuLID/blob/main/docs/pulid_for_flux.md#useful-tips).
|
166 |
- `Learn more about the model:` please refer to the <a href='https://github.com/ToTheBeginning/PuLID/blob/main/docs/pulid_for_flux.md' target='_blank'>github doc</a> for more details and info about the model, we provide the detail explanation about the above two parameters in the doc.
|