Download audio_to_text/captioning/utils/remove_optimizer.py from alonegg/AudioGPT: direct link, hf CLI and curl.
- Browser
- Download file 471 Bytes
-
https://huggingface.co/spaces/alonegg/AudioGPT/resolve/main/audio_to_text/captioning/utils/remove_optimizer.py
- Command line
-
hf download hf://spaces/alonegg/AudioGPT/audio_to_text/captioning/utils/remove_optimizer.py
-
curl -L -o remove_optimizer.py https://huggingface.co/spaces/alonegg/AudioGPT/resolve/main/audio_to_text/captioning/utils/remove_optimizer.py
471 Bytes
| import argparse | |
| import torch | |
| def main(checkpoint): | |
| state_dict = torch.load(checkpoint, map_location="cpu") | |
| if "optimizer" in state_dict: | |
| del state_dict["optimizer"] | |
| if "lr_scheduler" in state_dict: | |
| del state_dict["lr_scheduler"] | |
| torch.save(state_dict, checkpoint) | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("checkpoint", type=str) | |
| args = parser.parse_args() | |
| main(args.checkpoint) | |