Unverified Commit d7dd924e authored by Aryan's avatar Aryan Committed by GitHub
Browse files

Kontext fixes (#11815)

fix
parent 00f95b97
...@@ -302,11 +302,11 @@ image.save("flux-kontext.png") ...@@ -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: 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 ```python
from flux.safety import PixtralIntegrity from flux.content_filters import PixtralContentFilter
# ... pipeline invocation to generate images # ... pipeline invocation to generate images
integrity_checker = PixtralIntegrity(torch.device("cuda")) integrity_checker = PixtralContentFilter(torch.device("cuda"))
image_ = np.array(image) / 255.0 image_ = np.array(image) / 255.0
image_ = 2 * image_ - 1 image_ = 2 * image_ - 1
image_ = torch.from_numpy(image_).to("cuda", dtype=torch.float32).unsqueeze(0).permute(0, 3, 1, 2) image_ = torch.from_numpy(image_).to("cuda", dtype=torch.float32).unsqueeze(0).permute(0, 3, 1, 2)
......
...@@ -65,8 +65,10 @@ EXAMPLE_DOC_STRING = """ ...@@ -65,8 +65,10 @@ EXAMPLE_DOC_STRING = """
... ) ... )
>>> pipe.to("cuda") >>> pipe.to("cuda")
>>> image = load_image("inputs/yarn-art-pikachu.png").convert("RGB") >>> image = load_image(
>>> prompt = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/yarn-art-pikachu.png" ... "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 = pipe(
... image=image, ... image=image,
... prompt=prompt, ... prompt=prompt,
......
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