nikhilg commited on
Commit
8449f5e
1 Parent(s): ff5ec05

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -14
README.md CHANGED
@@ -68,34 +68,33 @@ Running the pipeline with the default PNDM scheduler:
68
 
69
  ```python
70
  import torch
71
- import torchvision
72
  from diffusers import StableDiffusionGLIGENPipeline
73
  from diffusers.utils import load_image
74
 
75
- model_id = "masterful/gligen-1-4-inpainting-text-box"
76
- device = "cuda"
 
 
 
77
 
78
- pipe = StableDiffusionGLIGENPipeline.from_pretrained(model_id, variant="fp16", torch_dtype=torch.float16)
79
- pipe = pipe.to(device)
80
-
81
- input_image = load_image("https://hf.co/datasets/huggingface/documentation-images/resolve/main/diffusers/gligen/livingroom_modern.png")
82
  prompt = "a birthday cake"
83
- boxes = [[0.2676,0.6088,0.4773,0.7183]]
84
- phrases=["a birthday cake"]
85
 
86
  images = pipe(
87
  prompt=prompt,
88
- num_images_per_prompt=1,
89
  gligen_phrases=phrases,
90
  gligen_inpaint_image=input_image,
91
  gligen_boxes=boxes,
92
  gligen_scheduled_sampling_beta=1,
93
- output_type="np",
94
  num_inference_steps=50,
95
  ).images
96
 
97
- images = torch.stack([torch.from_numpy(image) for image in images]).permute(0, 3, 1, 2)
98
- torchvision.utils.save_image(images, "./gligen-1-4-inpainting-text-box.jpg", nrow=1, normalize=False)
99
  ```
100
 
101
 
@@ -183,4 +182,4 @@ Refer [`GLIGEN`](https://github.com/gligen/GLIGEN) for more details.
183
  }
184
  ```
185
 
186
- *This model card was written by: Robin Rombach and Patrick Esser and is based on the [DALL-E Mini model card](https://huggingface.co/dalle-mini/dalle-mini).*
 
68
 
69
  ```python
70
  import torch
 
71
  from diffusers import StableDiffusionGLIGENPipeline
72
  from diffusers.utils import load_image
73
 
74
+ # Insert objects described by text at the region defined by bounding boxes
75
+ pipe = StableDiffusionGLIGENPipeline.from_pretrained(
76
+ "masterful/gligen-1-4-inpainting-text-box", variant="fp16", torch_dtype=torch.float16
77
+ )
78
+ pipe = pipe.to("cuda")
79
 
80
+ input_image = load_image(
81
+ "https://hf.co/datasets/huggingface/documentation-images/resolve/main/diffusers/gligen/livingroom_modern.png"
82
+ )
 
83
  prompt = "a birthday cake"
84
+ boxes = [[0.2676, 0.6088, 0.4773, 0.7183]]
85
+ phrases = ["a birthday cake"]
86
 
87
  images = pipe(
88
  prompt=prompt,
 
89
  gligen_phrases=phrases,
90
  gligen_inpaint_image=input_image,
91
  gligen_boxes=boxes,
92
  gligen_scheduled_sampling_beta=1,
93
+ output_type="pil",
94
  num_inference_steps=50,
95
  ).images
96
 
97
+ images[0].save("./gligen-1-4-inpainting-text-box.jpg")
 
98
  ```
99
 
100
 
 
182
  }
183
  ```
184
 
185
+ *This model card was written by: [Nikhil Gajendrakumar](https://github.com/nikhil-masterful) and is based on the [DALL-E Mini model card](https://huggingface.co/dalle-mini/dalle-mini).*