Skip to content

Commit 9c89c8b

Browse files
committed
add --half to convert_original_stable_diffusion_to_diffusers.py
1 parent ef4c2fa commit 9c89c8b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

scripts/convert_original_stable_diffusion_to_diffusers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515
""" Conversion script for the LDM checkpoints. """
1616

17+
import torch
1718
import argparse
1819

1920
from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt
@@ -123,6 +124,7 @@
123124
parser.add_argument(
124125
"--controlnet", action="store_true", default=None, help="Set flag if this is a controlnet checkpoint."
125126
)
127+
parser.add_argument("--half", action="store_true", help="Save weights in half precision.")
126128
args = parser.parse_args()
127129

128130
pipe = download_from_original_stable_diffusion_ckpt(
@@ -143,6 +145,9 @@
143145
controlnet=args.controlnet,
144146
)
145147

148+
if args.half:
149+
pipe.to(torch_dtype=torch.float16)
150+
146151
if args.controlnet:
147152
# only save the controlnet model
148153
pipe.controlnet.save_pretrained(args.dump_path, safe_serialization=args.to_safetensors)

0 commit comments

Comments
 (0)