Unverified Commit 9062b284 authored by Alon Burg's avatar Alon Burg Committed by GitHub
Browse files

Support fp16 in conversion from original ckpt (#2733)

add --half to convert_original_stable_diffusion_to_diffusers.py
parent b3d5cc4a
......@@ -14,6 +14,7 @@
# limitations under the License.
""" Conversion script for the LDM checkpoints. """
import torch
import argparse
from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt
......@@ -123,6 +124,7 @@ if __name__ == "__main__":
parser.add_argument(
"--controlnet", action="store_true", default=None, help="Set flag if this is a controlnet checkpoint."
)
parser.add_argument("--half", action="store_true", help="Save weights in half precision.")
args = parser.parse_args()
pipe = download_from_original_stable_diffusion_ckpt(
......@@ -143,6 +145,9 @@ if __name__ == "__main__":
controlnet=args.controlnet,
)
if args.half:
pipe.to(torch_dtype=torch.float16)
if args.controlnet:
# only save the controlnet model
pipe.controlnet.save_pretrained(args.dump_path, safe_serialization=args.to_safetensors)
......
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