vinesmsuic commited on
Commit
5ac1f2b
·
1 Parent(s): 6a1fcd8
Files changed (1) hide show
  1. README.md +59 -1
README.md CHANGED
@@ -1,3 +1,61 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ license: creativeml-openrail-m
5
+ tags:
6
+ - stable-diffusion
7
+ - stable-diffusion-diffusers
8
+ - text-to-image
9
+ - diffusers
10
  ---
11
+
12
+ diffuser port of https://huggingface.co/osunlp/InstructPix2Pix-MagicBrush.
13
+ diffuser version of `MagicBrush-epoch-52-step-4999.ckpt` **with EMA**.
14
+
15
+ ```python
16
+ from PIL import Image, ImageOps
17
+ import requests
18
+ import torch
19
+ from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
20
+ from PIL import Image
21
+
22
+ url = "https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png"
23
+
24
+ def download_image(url):
25
+ image = Image.open(requests.get(url, stream=True).raw)
26
+ image = ImageOps.exif_transpose(image)
27
+ image = image.convert("RGB")
28
+ return image
29
+
30
+ image = download_image(url)
31
+ prompt = "make the mountains snowy"
32
+
33
+ class MagicBrush():
34
+ def __init__(self, weight="vinesmsuic/magicbrush-ema"):
35
+ self.pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(
36
+ weight,
37
+ torch_dtype=torch.float16
38
+ ).to("cuda")
39
+ self.pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(self.pipe.scheduler.config)
40
+
41
+ def infer_one_image(self, src_image, instruct_prompt, seed):
42
+ generator = torch.manual_seed(seed)
43
+ image = self.pipe(instruct_prompt, image=src_image, num_inference_steps=20, image_guidance_scale=1.5, guidance_scale=7, generator=generator).images[0]
44
+ return image
45
+
46
+ model = MagicBrush()
47
+ image_output = model.infer_one_image(image, prompt, 42)
48
+ image_output
49
+ ```
50
+
51
+ ![](https://i.imgur.com/rL3zEkh.png)
52
+
53
+ ## License
54
+
55
+ This model is open access and available to all, with a CreativeML OpenRAIL-M license further specifying rights and usage.
56
+ The CreativeML OpenRAIL License specifies:
57
+
58
+ 1. You can't use the model to deliberately produce nor share illegal or harmful outputs or content
59
+ 2. The authors claims no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in the license
60
+ 3. You may re-distribute the weights and use the model commercially and/or as a service. If you do, please be aware you have to include the same use restrictions as the ones in the license and share a copy of the CreativeML OpenRAIL-M to all your users (please read the license entirely and carefully)
61
+ [Please read the full license here](https://huggingface.co/spaces/CompVis/stable-diffusion-license)