From d5df9a7b7c6e7b1bf8c6284e264a47af7222dafa Mon Sep 17 00:00:00 2001 From: smthemex <138738845+smthemex@users.noreply.github.com> Date: Fri, 20 Jun 2025 21:43:37 +0800 Subject: [PATCH] I --- LICENSE | 211 +++++++++++++++++++++++++++++++ __init__.py | 4 + generate.py | 296 +++++++++++++++++++++++++++++++++++++++++++ node_utils.py | 234 ++++++++++++++++++++++++++++++++++ requirements.txt | 318 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1063 insertions(+) create mode 100644 LICENSE create mode 100644 __init__.py create mode 100644 generate.py create mode 100644 node_utils.py create mode 100644 requirements.txt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2027815 --- /dev/null +++ b/LICENSE @@ -0,0 +1,211 @@ +Tencent is pleased to support the open source community by making SongGeneration available. + +Copyright (C) 2025 Tencent. All rights reserved. + +SongGeneration is licensed under the License Terms of SongGeneration except for the third-party components listed below, which is licensed under different terms. SongGeneration does not impose any additional limitations beyond what is outlined in the respective licenses of these third-party components. Users must comply with all terms and conditions of original licenses of these third-party components and must ensure that the usage of the third party components adheres to all relevant laws and regulations. + + +License Terms of SongGeneration: +-------------------------------------------------------------------- + +Permission is hereby granted, free of charge, to any person obtaining a copy of this Software and associated documentation files, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sublicense copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +- You agree to use the SongGeneration only for academic, research and education purposes, and refrain from using it for any commercial or production purposes under any circumstances. + +- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +For avoidance of doubts, "Software" means the SongGeneration inference-enabling code and the weights made available under this license excluding any pre-trained data and other AI components. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +Other dependencies and licenses: + + +Open Source Software Licensed under the MIT License and Other Licenses of the Third-Party Components therein: +-------------------------------------------------------------------- +1. stable_audio_tools +Copyright (c) 2023 Stability AI + + +Terms of the MIT: +-------------------------------------------------------------------- +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +For the license of other third party components, please refer to the following URL: +https://github.com/Stability-AI/stable-audio-tools/tree/main/LICENSES + + +Open Source Software Licensed under the MIT License: +-------------------------------------------------------------------- +1. demucs +Copyright (c) Meta Platforms, Inc. and affiliates. + + +A copy of the MIT is included in this file. + + + +Open Source Software Licensed under the BSD 3-Clause License and Other Licenses of the Third-Party Components therein: +-------------------------------------------------------------------- +1. torch +From PyTorch: + +Copyright (c) 2016- Facebook, Inc (Adam Paszke) +Copyright (c) 2014- Facebook, Inc (Soumith Chintala) +Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert) +Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu) +Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu) +Copyright (c) 2011-2013 NYU (Clement Farabet) +Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston) +Copyright (c) 2006 Idiap Research Institute (Samy Bengio) +Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz) + +From Caffe2: + +Copyright (c) 2016-present, Facebook Inc. All rights reserved. + +All contributions by Facebook: +Copyright (c) 2016 Facebook Inc. + +All contributions by Google: +Copyright (c) 2015 Google Inc. +All rights reserved. + +All contributions by Yangqing Jia: +Copyright (c) 2015 Yangqing Jia +All rights reserved. + +All contributions by Kakao Brain: +Copyright 2019-2020 Kakao Brain + +All contributions by Cruise LLC: +Copyright (c) 2022 Cruise LLC. +All rights reserved. + +All contributions from Caffe: +Copyright(c) 2013, 2014, 2015, the respective contributors +All rights reserved. + +All other contributions: +Copyright(c) 2015, 2016 the respective contributors +All rights reserved. + +Caffe2 uses a copyright model similar to Caffe: each contributor holds +copyright over their contributions to Caffe2. The project versioning records +all such contribution and copyright details. If a contributor wants to further +mark their specific copyright on a particular contribution, they should +indicate their copyright solely in the commit message of the change when it is +committed. + +All rights reserved. + + +Terms of the BSD 3-Clause: +-------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +For the license of other third party components, please refer to the following URL: +https://github.com/pytorch/pytorch/blob/v2.0.1/NOTICE + + +Open Source Software Licensed under the BSD 2-Clause License and Other Licenses of the Third-Party Components therein: +-------------------------------------------------------------------- +1. torchaudio +Copyright (c) 2017 Facebook Inc. (Soumith Chintala), +All rights reserved. + + +Terms of the BSD 2-Clause: +-------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +For the license of other third party components, please refer to the following URL: +https://github.com/pytorch/audio/blob/v2.0.2/LICENSE + + +Open Source Software License under the Apache License Version 2.0: +-------------------------------------------------------------------- +1. huggingface-hub +Copyright (c) huggingface-hub original author and authors + +2. transformers +Copyright 2018- The Hugging Face team. All rights reserved. + + +Terms of the Apache License Version 2.0: +-------------------------------------------------------------------- +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and + +You must cause any modified files to carry prominent notices stating that You changed the files; and + +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..fe34da9 --- /dev/null +++ b/__init__.py @@ -0,0 +1,4 @@ + +from .SongGeneration_node import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS + +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] diff --git a/generate.py b/generate.py new file mode 100644 index 0000000..7dbfb6d --- /dev/null +++ b/generate.py @@ -0,0 +1,296 @@ +import sys +import os +import folder_paths +import time +import json +import torch +import torchaudio +import numpy as np +from omegaconf import OmegaConf +from .SongGeneration.codeclm.models import builders +from .SongGeneration.codeclm.trainer.codec_song_pl import CodecLM_PL +from .SongGeneration.codeclm.models import CodecLM +from .SongGeneration.third_party.demucs.models.pretrained import get_model_from_yaml + +auto_prompt_type = ['Pop', 'R&B', 'Dance', 'Jazz', 'Folk', 'Rock', 'Chinese Style', 'Chinese Tradition', 'Metal', 'Reggae', 'Chinese Opera', 'Auto'] + +class Separator(): + def __init__(self, dm_model_path='third_party/demucs/ckpt/htdemucs.pth', dm_config_path='third_party/demucs/ckpt/htdemucs.yaml', gpu_id=0) -> None: + if torch.cuda.is_available() and gpu_id < torch.cuda.device_count(): + self.device = torch.device(f"cuda:{gpu_id}") + else: + self.device = torch.device("cpu") + self.demucs_model = self.init_demucs_model(dm_model_path, dm_config_path) + + def init_demucs_model(self, model_path, config_path): + model = get_model_from_yaml(config_path, model_path) + model.to(self.device) + model.eval() + return model + + def load_audio(self, f): + a, fs = torchaudio.load(f) + if (fs != 48000): + a = torchaudio.functional.resample(a, fs, 48000) + if a.shape[-1] >= 48000*10: + a = a[..., :48000*10] + else: + a = torch.cat([a, a], -1) + return a[:, 0:48000*10] + + def run(self, audio_path, output_dir='tmp', ext=".flac"): + os.makedirs(output_dir, exist_ok=True) + name, _ = os.path.splitext(os.path.split(audio_path)[-1]) + output_paths = [] + + for stem in self.demucs_model.sources: + output_path = os.path.join(output_dir, f"{name}_{stem}{ext}") + if os.path.exists(output_path): + output_paths.append(output_path) + if len(output_paths) == 1: # 4 + vocal_path = output_paths[0] + else: + drums_path, bass_path, other_path, vocal_path = self.demucs_model.separate(audio_path, output_dir, device=self.device) + for path in [drums_path, bass_path, other_path]: + os.remove(path) + full_audio = self.load_audio(audio_path) + vocal_audio = self.load_audio(vocal_path) + bgm_audio = full_audio - vocal_audio + return full_audio, vocal_audio, bgm_audio + + +def pre_data(Weigths_Path,dm_model_path,dm_config_path,save_dir,prompt_audio_path,auto_prompt_audio_type): + torch.backends.cudnn.enabled = False + OmegaConf.register_new_resolver("eval", lambda x: eval(x)) + OmegaConf.register_new_resolver("concat", lambda *x: [xxx for xx in x for xxx in xx]) + OmegaConf.register_new_resolver("get_fname", lambda: os.path.splitext(os.path.basename(sys.argv[1]))[0]) + OmegaConf.register_new_resolver("load_yaml", lambda x: list(OmegaConf.load(x))) + np.random.seed(int(time.time())) + + cfg_path = os.path.join(Weigths_Path, 'songgeneration_base_zh/config.yaml') + + cfg = OmegaConf.load(cfg_path) + cfg.mode = 'inference' + cfg.vae_config=f"{Weigths_Path}/vae/stable_audio_1920_vae.json" + cfg.vae_model=f"{Weigths_Path}/vae/autoencoder_music_1320k.ckpt" + + cfg.audio_tokenizer_checkpoint=f"Flow1dVAE1rvq_{Weigths_Path}/model_1rvq/model_2_fixed.safetensors" + cfg.audio_tokenizer_checkpoint_sep=f"Flow1dVAESeparate_{Weigths_Path}/model_septoken/model_2.safetensors" + cfg.conditioners.type_info.QwTextTokenizer.token_path=os.path.join(folder_paths.base_path,"custom_nodes/ComfyUI_SongGeneration/SongGeneration/third_party/Qwen2-7B") + max_duration = cfg.max_dur + + separator = Separator(dm_model_path, dm_config_path) + auto_prompt = torch.load(os.path.join(Weigths_Path,'prompt.pt'),weights_only=False) + + audio_tokenizer = builders.get_audio_tokenizer_model(cfg.audio_tokenizer_checkpoint, cfg) + if "audio_tokenizer_checkpoint_sep" in cfg.keys(): + seperate_tokenizer = builders.get_audio_tokenizer_model(cfg.audio_tokenizer_checkpoint_sep, cfg) + else: + seperate_tokenizer = None + audio_tokenizer = audio_tokenizer.eval().cuda() + if seperate_tokenizer is not None: + seperate_tokenizer = seperate_tokenizer.eval().cuda() + + merge_prompt = [item for sublist in auto_prompt.values() for item in sublist] + item=song_infer_lowram(seperate_tokenizer,separator,audio_tokenizer,merge_prompt,auto_prompt, save_dir,prompt_audio_path,auto_prompt_audio_type) + return item,max_duration,cfg + + +def infer_stage2(item,cfg,Weigths_Path,max_duration,lyric,descriptions,cfg_coef = 1.5, temp = 0.9,top_k = 50,top_p = 0.0,record_tokens = True,record_window = 50): + ckpt_path = os.path.join(Weigths_Path, 'songgeneration_base_zh/model.pt') + # Define model or load pretrained model + model_light = CodecLM_PL(cfg, ckpt_path) + model_light = model_light.eval() + model_light.audiolm.cfg = cfg + model = CodecLM(name = "tmp", + lm = model_light.audiolm, + audiotokenizer = None, + max_duration = max_duration, + seperate_tokenizer = None, + ) + del model_light + torch.cuda.empty_cache() + model.lm = model.lm.cuda().to(torch.float16) + + model.set_generation_params(duration=max_duration, extend_stride=5, temperature=temp, cfg_coef=cfg_coef, + top_k=top_k, top_p=top_p, record_tokens=record_tokens, record_window=record_window) + + items=inference_lowram_step2(model,lyric,descriptions,item) + model=None + torch.cuda.empty_cache() + + return items + + + + +def inference_lowram_step2(model,lyric,descriptions,item): + + pmt_wav = item['pmt_wav'] + vocal_wav = item['vocal_wav'] + bgm_wav = item['bgm_wav'] + melody_is_wav = item['melody_is_wav'] + + generate_inp = { + 'lyrics': [lyric.replace(" ", " ")], + 'descriptions': [descriptions], + 'melody_wavs': pmt_wav, + 'vocal_wavs': vocal_wav, + 'bgm_wavs': bgm_wav, + 'melody_is_wav': melody_is_wav, + } + with torch.autocast(device_type="cuda", dtype=torch.float16): + tokens = model.generate(**generate_inp, return_tokens=True) + item['tokens'] = tokens + + return item + + + +def inference_lowram_final(cfg,max_duration,item,save_dir): + target_wav_name = f"{save_dir}/song_audios{time.strftime('%m%d%H%S')}.flac" + seperate_tokenizer = builders.get_audio_tokenizer_model(cfg.audio_tokenizer_checkpoint_sep, cfg) + seperate_tokenizer = seperate_tokenizer.eval().cuda() + model = CodecLM(name = "tmp", + lm = None, + audiotokenizer = None, + max_duration = max_duration, + seperate_tokenizer = seperate_tokenizer, + ) + + with torch.no_grad(): + if 'raw_pmt_wav' in item: + wav_seperate = model.generate_audio(item['tokens'], item['raw_pmt_wav'], item['raw_vocal_wav'], item['raw_bgm_wav'], chunked=True) + del item['raw_pmt_wav'] + del item['raw_vocal_wav'] + del item['raw_bgm_wav'] + else: + wav_seperate = model.generate_audio(item['tokens'], chunked=True) + #torchaudio.save(item['wav_path'], wav_seperate[0].cpu().float(), cfg.sample_rate) + torchaudio.save(target_wav_name, wav_seperate[0].cpu().float(), cfg.sample_rate) + del item['tokens'] + del item['pmt_wav'] + del item['vocal_wav'] + del item['bgm_wav'] + del item['melody_is_wav'] + + return {"waveform": wav_seperate[0].cpu().float().unsqueeze(0), "sample_rate": cfg.sample_rate} + + + +def song_infer_lowram(seperate_tokenizer,separator,audio_tokenizer,merge_prompt,auto_prompt, save_dir,prompt_audio_path,auto_prompt_audio_type): #item dict + item = {} + target_wav_name = f"{save_dir}/song_audios{time.strftime('%m%d%H%S')}.flac" + if prompt_audio_path: + # assert os.path.exists(item['prompt_audio_path']), f"prompt_audio_path {item['prompt_audio_path']} not found" + # assert 'auto_prompt_audio_type' not in item, f"auto_prompt_audio_type and prompt_audio_path cannot be used together" + pmt_wav, vocal_wav, bgm_wav = separator.run(prompt_audio_path) + item['raw_pmt_wav'] = pmt_wav + item['raw_vocal_wav'] = vocal_wav + item['raw_bgm_wav'] = bgm_wav + if pmt_wav.dim() == 2: + pmt_wav = pmt_wav[None] + if pmt_wav.dim() != 3: + raise ValueError("Melody wavs should have a shape [B, C, T].") + pmt_wav = list(pmt_wav) + if vocal_wav.dim() == 2: + vocal_wav = vocal_wav[None] + if vocal_wav.dim() != 3: + raise ValueError("Vocal wavs should have a shape [B, C, T].") + vocal_wav = list(vocal_wav) + if bgm_wav.dim() == 2: + bgm_wav = bgm_wav[None] + if bgm_wav.dim() != 3: + raise ValueError("BGM wavs should have a shape [B, C, T].") + bgm_wav = list(bgm_wav) + if type(pmt_wav) == list: + pmt_wav = torch.stack(pmt_wav, dim=0) + if type(vocal_wav) == list: + vocal_wav = torch.stack(vocal_wav, dim=0) + if type(bgm_wav) == list: + bgm_wav = torch.stack(bgm_wav, dim=0) + pmt_wav = pmt_wav.cuda() + vocal_wav = vocal_wav.cuda() + bgm_wav = bgm_wav.cuda() + pmt_wav, _ = audio_tokenizer.encode(pmt_wav) + vocal_wav, bgm_wav = seperate_tokenizer.encode(vocal_wav, bgm_wav) + melody_is_wav = False + elif auto_prompt_audio_type: + #assert item["auto_prompt_audio_type"] in auto_prompt_type, f"auto_prompt_audio_type {item['auto_prompt_audio_type']} not found" + if auto_prompt_audio_type == "Auto": + prompt_token = merge_prompt[np.random.randint(0, len(merge_prompt))] + else: + prompt_token = auto_prompt[auto_prompt_audio_type][np.random.randint(0, len(auto_prompt[auto_prompt_audio_type]))] + pmt_wav = prompt_token[:,[0],:] + vocal_wav = prompt_token[:,[1],:] + bgm_wav = prompt_token[:,[2],:] + melody_is_wav = False + else: + pmt_wav = None + vocal_wav = None + bgm_wav = None + melody_is_wav = True + item['pmt_wav'] = pmt_wav + item['vocal_wav'] = vocal_wav + item['bgm_wav'] = bgm_wav + item['melody_is_wav'] = melody_is_wav + item["idx"] = 0 + item["wav_path"] = target_wav_name + + + del audio_tokenizer + del seperate_tokenizer + del separator + + return item + + + + + + +# def song_infer(model,separator,lyric,merge_prompt,auto_prompt, save_dir,cfg,prompt_audio_path,auto_prompt_audio_type,descriptions = None): #item dict + +# target_wav_name = f"{save_dir}/song_audios{time.strftime('%m%d%H%S')}.flac" + +# if prompt_audio_path: +# pmt_wav, vocal_wav, bgm_wav = separator.run(prompt_audio_path) +# melody_is_wav = True +# elif auto_prompt_audio_type: +# if auto_prompt_audio_type== "Auto": +# prompt_token = merge_prompt[np.random.randint(0, len(merge_prompt))] +# else: +# prompt_token = auto_prompt[auto_prompt_audio_type][np.random.randint(0, len(auto_prompt[auto_prompt_audio_type]))] #need check +# pmt_wav = prompt_token[:,[0],:] +# vocal_wav = prompt_token[:,[1],:] +# bgm_wav = prompt_token[:,[2],:] +# melody_is_wav = False +# else: +# pmt_wav = None +# vocal_wav = None +# bgm_wav = None +# melody_is_wav = True + +# generate_inp = { +# 'lyrics': [lyric.replace(" ", " ")], +# 'descriptions': [descriptions], +# 'melody_wavs': pmt_wav, +# 'vocal_wavs': vocal_wav, +# 'bgm_wavs': bgm_wav, +# 'melody_is_wav': melody_is_wav, +# } +# start_time = time.time() +# with torch.autocast(device_type="cuda", dtype=torch.float16): +# tokens = model.generate(**generate_inp, return_tokens=True) +# mid_time = time.time() + +# with torch.no_grad(): +# if melody_is_wav: +# wav_seperate = model.generate_audio(tokens, pmt_wav, vocal_wav, bgm_wav) +# else: +# wav_seperate = model.generate_audio(tokens) +# end_time = time.time() +# torchaudio.save(target_wav_name, wav_seperate[0].cpu().float(), cfg.sample_rate) +# print(f"process lm cost {mid_time - start_time}s, diffusion cost {end_time - mid_time}") + +# return {"waveform": wav_seperate[0].cpu().float().unsqueeze(0), "sample_rate": cfg.sample_rate} \ No newline at end of file diff --git a/node_utils.py b/node_utils.py new file mode 100644 index 0000000..73064e8 --- /dev/null +++ b/node_utils.py @@ -0,0 +1,234 @@ +# !/usr/bin/env python +# -*- coding: UTF-8 -*- +import os +import torch +from PIL import Image +import numpy as np +import cv2 +import gc + +from comfy.utils import common_upscale,ProgressBar +from huggingface_hub import hf_hub_download + +cur_path = os.path.dirname(os.path.abspath(__file__)) +device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu" + + +def gc_clear(): + gc.collect() + torch.cuda.empty_cache() + +def cv2pil(cv_image): + """ + 将OpenCV图像转换为PIL图像 + :param cv_image: OpenCV图像 + :return: PIL图像 + """ + # 将图像从BGR转换为RGB + rgb_image = cv2.cvtColor(cv_image, cv2.COLOR_BGR2RGB) + # 使用PIL的Image.fromarray方法将NumPy数组转换为PIL图像 + pil_image = Image.fromarray(rgb_image) + return pil_image + + +def add_mask(masks,images): + if images.max() > 1.0: + white_value = 255.0 + else: + white_value = 1.0 + + if masks.max() > 1.0: + masks = masks / 255.0 + + masks = masks.unsqueeze(-1) + + white_bg = torch.ones_like(images) * white_value + + if images.shape[-1] == 4: + images = images[..., :3] + + tensor_image = images * masks + white_bg * (1 - masks) + return tensor_image + + + +def tensor_to_pil(tensor): + image_np = tensor.squeeze().mul(255).clamp(0, 255).byte().numpy() + image = Image.fromarray(image_np, mode='RGB') + return image + +def tensor2pil_list(image,width,height): + B,_,_,_=image.size() + if B==1: + ref_image_list=[tensor2pil_upscale(image,width,height)] + else: + img_list = list(torch.chunk(image, chunks=B)) + ref_image_list = [tensor2pil_upscale(img,width,height) for img in img_list] + return ref_image_list + + +def tensor_upscale(img_tensor, width, height): + samples = img_tensor.movedim(-1, 1) + img = common_upscale(samples, width, height, "nearest-exact", "center") + samples = img.movedim(1, -1) + return samples + +def tensor2pil_upscale(img_tensor, width, height): + samples = img_tensor.movedim(-1, 1) + img = common_upscale(samples, width, height, "nearest-exact", "center") + samples = img.movedim(1, -1) + img_pil = tensor_to_pil(samples) + return img_pil + + +def tensor2cv(tensor_image,RGB2BGR=True): + if len(tensor_image.shape)==4:#bhwc to hwc + tensor_image=tensor_image.squeeze(0) + if tensor_image.is_cuda: + tensor_image = tensor_image.cpu().detach() + tensor_image=tensor_image.numpy() + #反归一化 + maxValue=tensor_image.max() + tensor_image=tensor_image*255/maxValue + img_cv2=np.uint8(tensor_image)#32 to uint8 + if RGB2BGR: + img_cv2=cv2.cvtColor(img_cv2,cv2.COLOR_RGB2BGR) + return img_cv2 + +def cvargb2tensor(img): + assert type(img) == np.ndarray, 'the img type is {}, but ndarry expected'.format(type(img)) + img = torch.from_numpy(img.transpose((2, 0, 1))) + return img.float().div(255).unsqueeze(0) # 255也可以改为256 + +def cv2tensor(img): + assert type(img) == np.ndarray, 'the img type is {}, but ndarry expected'.format(type(img)) + img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) + img = torch.from_numpy(img.transpose((2, 0, 1))) + return img.float().div(255).unsqueeze(0) # 255也可以改为256 + +def images_generator(img_list: list,): + #get img size + sizes = {} + for image_ in img_list: + if isinstance(image_,Image.Image): + count = sizes.get(image_.size, 0) + sizes[image_.size] = count + 1 + elif isinstance(image_,np.ndarray): + count = sizes.get(image_.shape[:2][::-1], 0) + sizes[image_.shape[:2][::-1]] = count + 1 + else: + raise "unsupport image list,must be pil or cv2!!!" + size = max(sizes.items(), key=lambda x: x[1])[0] + yield size[0], size[1] + + # any to tensor + def load_image(img_in): + if isinstance(img_in, Image.Image): + img_in=img_in.convert("RGB") + i = np.array(img_in, dtype=np.float32) + i = torch.from_numpy(i).div_(255) + if i.shape[0] != size[1] or i.shape[1] != size[0]: + i = torch.from_numpy(i).movedim(-1, 0).unsqueeze(0) + i = common_upscale(i, size[0], size[1], "lanczos", "center") + i = i.squeeze(0).movedim(0, -1).numpy() + return i + elif isinstance(img_in,np.ndarray): + i=cv2.cvtColor(img_in,cv2.COLOR_BGR2RGB).astype(np.float32) + i = torch.from_numpy(i).div_(255) + #print(i.shape) + return i + else: + raise "unsupport image list,must be pil,cv2 or tensor!!!" + + total_images = len(img_list) + processed_images = 0 + pbar = ProgressBar(total_images) + images = map(load_image, img_list) + try: + prev_image = next(images) + while True: + next_image = next(images) + yield prev_image + processed_images += 1 + pbar.update_absolute(processed_images, total_images) + prev_image = next_image + except StopIteration: + pass + if prev_image is not None: + yield prev_image + +def load_images(img_list: list,): + gen = images_generator(img_list) + (width, height) = next(gen) + images = torch.from_numpy(np.fromiter(gen, np.dtype((np.float32, (height, width, 3))))) + if len(images) == 0: + raise FileNotFoundError(f"No images could be loaded .") + return images + +def tensor2pil(tensor): + image_np = tensor.squeeze().mul(255).clamp(0, 255).byte().numpy() + image = Image.fromarray(image_np, mode='RGB') + return image + +def pil2narry(img): + narry = torch.from_numpy(np.array(img).astype(np.float32) / 255.0).unsqueeze(0) + return narry + +def equalize_lists(list1, list2): + """ + 比较两个列表的长度,如果不一致,则将较短的列表复制以匹配较长列表的长度。 + + 参数: + list1 (list): 第一个列表 + list2 (list): 第二个列表 + + 返回: + tuple: 包含两个长度相等的列表的元组 + """ + len1 = len(list1) + len2 = len(list2) + + if len1 == len2: + pass + elif len1 < len2: + print("list1 is shorter than list2, copying list1 to match list2's length.") + list1.extend(list1 * ((len2 // len1) + 1)) # 复制list1以匹配list2的长度 + list1 = list1[:len2] # 确保长度一致 + else: + print("list2 is shorter than list1, copying list2 to match list1's length.") + list2.extend(list2 * ((len1 // len2) + 1)) # 复制list2以匹配list1的长度 + list2 = list2[:len1] # 确保长度一致 + + return list1, list2 + +def file_exists(directory, filename): + # 构建文件的完整路径 + file_path = os.path.join(directory, filename) + # 检查文件是否存在 + return os.path.isfile(file_path) + +def download_weights(file_dir,repo_id,subfolder="",pt_name=""): + if subfolder: + file_path = os.path.join(file_dir,subfolder, pt_name) + sub_dir=os.path.join(file_dir,subfolder) + if not os.path.exists(sub_dir): + os.makedirs(sub_dir) + if not os.path.exists(file_path): + file_path = hf_hub_download( + repo_id=repo_id, + subfolder=subfolder, + filename=pt_name, + local_dir = file_dir, + ) + return file_path + else: + file_path = os.path.join(file_dir, pt_name) + if not os.path.exists(file_dir): + os.makedirs(file_dir) + if not os.path.exists(file_path): + file_path = hf_hub_download( + repo_id=repo_id, + filename=pt_name, + local_dir=file_dir, + ) + return file_path diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ae64ee3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,318 @@ +# absl-py==2.0.0 +# accelerate==0.30.1 +accelerate +# addict==2.4.0 +# aiofiles==23.2.1 +aiohttp +# aiosignal==1.3.1 +alias-free-torch +# aliyun-python-sdk-core==2.15.1 +# aliyun-python-sdk-kms==2.16.3 +# altair==5.3.0 +# annotated-types==0.6.0 +# antlr4-python3-runtime==4.8 +# anyio==4.3.0 +# argbind==0.3.9 +# asttokens==3.0.0 +# astunparse==1.6.3 +# async-timeout==4.0.3 +# attrs==23.1.0 +audiocraft +#audioread==3.0.1 +av +# backcall==0.2.0 +# beartype==0.18.5 +# bitarray==2.9.2 +# blis==0.7.11 +# boto3==1.29.6 +# botocore==1.32.6 +# braceexpand==0.1.7 +# cachetools==5.3.2 +# catalogue==2.0.10 +# certifi==2023.11.17 +# cffi==1.16.0 +# charset-normalizer==3.3.2 +# clean-fid==0.1.35 +# click==8.1.7 +# clip-anytorch==2.6.0 +# cloudpathlib==0.16.0 +cloudpickle +# cn2an==0.5.22 +# colorama==0.4.6 +colorlog +# confection==0.1.4 +# contourpy==1.1.1 +# crcmod==1.7 +# cryptography==43.0.0 +# cycler==0.12.1 +# cymem==2.0.8 +# Cython==3.0.10 +# dataclasses==0.6 +# datasets==2.18.0 +# dctorch==0.1.2 +# decorator==5.1.1 +# decord==0.6.0 +# deepspeed==0.14.0 +# demucs==4.0.1 +descript-audio-codec +descript-audiotools +diffusers +# dill==0.3.8 +# Distance==0.1.3 +# docker-pycreds==0.4.0 +# docopt==0.6.2 +# docstring_parser==0.16 +dora_search +einops +einops-exts +einx +# ema-pytorch==0.5.1 +# encodec==0.1.1 +# exceptiongroup==1.2.0 +# executing==2.2.0 +# expecttest==0.1.6 +#fairseq==0.12.2 #pip install fairseq -f https://download.pytorch.org/whl/cu124/torch_stable.html +fairseq +# fastapi==0.110.3 +# ffmpy==0.3.2 +# filelock==3.13.1 +# fire==0.7.0 +flashy +# flatten-dict==0.4.2 +# fonttools==4.49.0 +frozendict +# frozenlist==1.4.1 +# fsspec==2023.10.0 +# ftfy==6.1.3 +# future==1.0.0 +# g2p-en +# gitdb==4.0.11 +# GitPython==3.1.43 +# google-auth==2.23.4 +# google-auth-oauthlib==1.0.0 +# gradio==4.26.0 +# gradio_client==0.15.1 +# grpcio==1.59.3 +# h11==0.14.0 +# h5py==3.11.0 +# hf-xet==1.1.2 +# hjson==3.1.0 +# httpcore==1.0.5 +# httpx==0.27.0 +# huggingface-hub==0.25.2 +# hydra-colorlog==1.2.0 +# hydra-core==1.0.7 +# hypothesis==6.90.0 +# idna==3.4 +# imageio==2.35.1 +# importlib-metadata==6.8.0 +# importlib_resources==6.1.3 +# inflect==7.0.0 +# ipython==8.12.3 +# jedi==0.19.2 +# jieba-fast==0.53 +# Jinja2==3.1.2 +# jmespath==0.10.0 +# joblib==1.3.2 +# json5==0.9.25 +# jsonlines==4.0.0 +# jsonmerge==1.9.2 +# jsonschema==4.22.0 +# jsonschema-specifications==2023.12.1 +# julius==0.2.7 +# k-diffusion==0.1.1.post1 +kaldiio +# kiwisolver==1.4.5 +# kornia==0.7.3 +# kornia_rs==0.1.9 +lameenc +# langcodes==3.4.0 +# language_data==1.2.0 +# lazy_loader==0.3 +# librosa==0.9.1 +# lightning==2.2.1 +# lightning-utilities==0.10.1 +# lion-pytorch==0.2.2 +# llvmlite==0.41.1 +# local-attention==1.9.14 +# loguru==0.7.2 +# lxml==5.2.2 +# marisa-trie==1.1.1 +# Markdown==3.5.1 +# markdown-it-py==3.0.0 +# markdown2==2.5.1 +# MarkupSafe==2.1.3 +# matplotlib==3.7.5 +# matplotlib-inline==0.1.7 +# mdurl==0.1.2 +# modelscope==1.16.1 +# mpmath==1.3.0 +# msgpack==1.0.8 +# multidict==6.0.5 +# multiprocess==0.70.16 +# murmurhash==1.0.10 +# mypy-extensions==1.0.0 +# networkx==3.1 +# ninja==1.11.1.1 +# nltk==3.8.1 +nnAudio +# num2words==0.5.13 +# numba==0.58.1 +# numpy==1.23.5 +# nvidia-cublas-cu11==11.11.3.6 +# nvidia-cuda-cupti-cu11==11.8.87 +# nvidia-cuda-nvrtc-cu11==11.8.89 +# nvidia-cuda-runtime-cu11==11.8.89 +# nvidia-cudnn-cu11==8.7.0.84 +# nvidia-cufft-cu11==10.9.0.58 +# nvidia-curand-cu11==10.3.0.86 +# nvidia-cusolver-cu11==11.4.1.48 +# nvidia-cusparse-cu11==11.7.5.86 +# nvidia-nccl-cu11==2.19.3 +# nvidia-nvtx-cu11==11.8.86 +# oauthlib==3.2.2 +# omegaconf==2.2.0 # fix +omegaconf +# opencv-contrib-python==4.8.1.78 +opencv-python +openunmix +# orjson==3.10.3 +# oss2==2.18.6 +# packaging==23.2 +# pandas==2.0.3 +# parso==0.8.4 +peft +# pexpect==4.9.0 +# pickleshare==0.7.5 +# Pillow==10.1.0 +# pkgutil_resolve_name==1.3.10 +# platformdirs==4.2.0 +# pooch==1.8.1 +# portalocker==2.10.1 +# preshed==3.0.9 +# proces==0.1.7 +# prodict==0.8.18 +# progressbar==2.5 +# prompt_toolkit==3.0.51 +# protobuf==3.19.6 +# psutil==5.9.6 +# ptyprocess==0.7.0 +# pure_eval==0.2.3 +# py-cpuinfo==9.0.0 +# pyarrow==17.0.0 +# pyarrow-hotfix==0.6 +# pyasn1==0.5.1 +# pyasn1-modules==0.3.0 +# pybind11==2.11.1 +# pycparser==2.21 +# pycryptodome==3.20.0 +# pydantic==2.6.3 +# pydantic_core==2.16.3 +# pydub==0.25.1 +# Pygments==2.18.0 +# pyloudnorm==0.1.1 +# pynvml==11.5.0 +# pyparsing==3.1.2 +pypinyin +# pyre-extensions==0.0.29 +# pyreaper==0.0.10 +# PySoundFile==0.9.0.post1 +# pystoi==0.4.1 +# python-dateutil==2.8.2 +# python-multipart==0.0.9 +# pytorch-lightning==2.2.1 +# pytz==2023.3.post1 +# PyWavelets==1.4.1 +# PyYAML==6.0.1 +# randomname==0.2.1 +# referencing==0.35.1 +# regex==2023.10.3 +# requests==2.32.3 +# requests-oauthlib==1.3.1 +# resampy==0.4.3 +# retrying==1.3.4 +# rich==13.7.1 +# rpds-py==0.18.1 +# rsa==4.9 +# ruamel.yaml==0.18.5 +# ruamel.yaml.clib==0.2.8 +# ruff==0.4.4 +# s3transfer==0.7.0 +# sacrebleu==2.4.2 +# safetensors==0.4.3 +# scikit-image==0.21.0 +# scikit-learn==1.3.2 +# scipy==1.10.1 +# semantic-version==2.10.0 +# sentencepiece==0.2.0 +# sentry-sdk==2.10.0 +# setproctitle==1.3.3 +# shellingham==1.5.4 +# six==1.16.0 +# smart-open==6.4.0 +# smmap==5.0.1 +# sniffio==1.3.1 +# sortedcontainers==2.4.0 +# SoundFile==0.10.3.post1 +# sox==1.4.1 +# soxr==0.3.7 +# spacy==3.7.4 +# spacy-legacy==3.0.12 +# spacy-loggers==1.0.5 +# srsly==2.4.8 +# stack-data==0.6.3 +# starlette==0.37.2 +submitit +# sympy==1.12 +# tabulate==0.9.0 +# tensorboard==2.14.0 +# tensorboard-data-server==0.7.2 +# tensorboardX==2.6.2.2 +# termcolor==2.3.0 +# thinc==8.2.3 +# threadpoolctl==3.3.0 +# tifffile==2023.7.10 +# timm==0.9.11 +# tokenizers==0.15.2 +# tomlkit==0.12.0 +# toolz==0.12.1 +torch +# torch-stoi==0.2.3 +torchaudio +# torchdata==0.7.1 +# torchdiffeq==0.2.5 +# torchlibrosa==0.1.0 +# torchmetrics==1.3.1 +# torchsde==0.2.6 +# torchtext==0.17.0 +torchvision +tqdm +# traitlets==5.14.3 +# trampoline==0.1.2 +# transformers==4.37.2 +treetable +triton +# typeguard==2.13.0 +# typer==0.9.4 +# types-dataclasses==0.6.6 +# typing-inspect==0.9.0 +# typing_extensions==4.8.0 +# tzdata==2023.3 +# Unidecode==1.3.8 +# urllib3==1.26.18 +# uvicorn==0.29.0 +vector_quantize_pytorch +# wandb==0.17.4 +# wasabi==1.1.2 +# wcwidth==0.2.12 +# weasel==0.3.4 +# webdataset==0.2.86 +# websockets==11.0.3 +# Werkzeug==3.0.1 +# wget==3.2 +# wordsegment==1.3.1 +# x-clip==0.14.4 +x-transformers +xformers +# yarl==1.9.4 +# zipp==3.17.0