mirror of
https://github.com/huggingface/diffusers.git
synced 2026-01-27 17:22:53 +03:00
@@ -302,11 +302,11 @@ image.save("flux-kontext.png")
|
||||
Flux Kontext comes with an integrity safety checker, which should be run after the image generation step. To run the safety checker, install the official repository from [black-forest-labs/flux](https://github.com/black-forest-labs/flux) and add the following code:
|
||||
|
||||
```python
|
||||
from flux.safety import PixtralIntegrity
|
||||
from flux.content_filters import PixtralContentFilter
|
||||
|
||||
# ... pipeline invocation to generate images
|
||||
|
||||
integrity_checker = PixtralIntegrity(torch.device("cuda"))
|
||||
integrity_checker = PixtralContentFilter(torch.device("cuda"))
|
||||
image_ = np.array(image) / 255.0
|
||||
image_ = 2 * image_ - 1
|
||||
image_ = torch.from_numpy(image_).to("cuda", dtype=torch.float32).unsqueeze(0).permute(0, 3, 1, 2)
|
||||
|
||||
@@ -65,8 +65,10 @@ EXAMPLE_DOC_STRING = """
|
||||
... )
|
||||
>>> pipe.to("cuda")
|
||||
|
||||
>>> image = load_image("inputs/yarn-art-pikachu.png").convert("RGB")
|
||||
>>> prompt = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/yarn-art-pikachu.png"
|
||||
>>> image = load_image(
|
||||
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/yarn-art-pikachu.png"
|
||||
... ).convert("RGB")
|
||||
>>> prompt = "Make Pikachu hold a sign that says 'Black Forest Labs is awesome', yarn art style, detailed, vibrant colors"
|
||||
>>> image = pipe(
|
||||
... image=image,
|
||||
... prompt=prompt,
|
||||
|
||||
Reference in New Issue
Block a user