GrandaddyShmax / audiocraft_plus

Audiocraft is a library for audio processing and generation with deep learning. It features the state-of-the-art EnCodec audio compressor / tokenizer, along with MusicGen, a simple and controllable music generation LM with textual and melodic conditioning.
MIT License
561 stars 63 forks source link

UnboundLocalError: local variable 'sentencepiece_model_pb2' referenced before assignment #41

Open initcold opened 1 year ago

initcold commented 1 year ago

python3 app.py --listen 192.168.2.91 False Running on local URL: http://192.168.2.91:7860

To create a public link, set share=True in launch(). Loading model GrandaddyShmax/audiogen-medium Downloading (…)ssion_state_dict.bin: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 236M/236M [00:02<00:00, 115MB/s] Downloading state_dict.bin: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3.68G/3.68G [00:33<00:00, 111MB/s] Downloading (…)ve/main/spiece.model: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 792k/792k [00:00<00:00, 1.71MB/s] Downloading (…)lve/main/config.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.21k/1.21k [00:00<00:00, 12.4MB/s] Traceback (most recent call last): File "/home/koen/.local/lib/python3.10/site-packages/gradio/routes.py", line 488, in run_predict output = await app.get_blocks().process_api( File "/home/koen/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1431, in process_api result = await self.call_function( File "/home/koen/.local/lib/python3.10/site-packages/gradio/blocks.py", line 1109, in call_function prediction = await anyio.to_thread.run_sync( File "/home/koen/.local/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "/home/koen/.local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "/home/koen/.local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run result = context.run(func, args) File "/home/koen/.local/lib/python3.10/site-packages/gradio/utils.py", line 706, in wrapper response = f(args, kwargs) File "/home/koen/audiocraft_plus/app.py", line 857, in predict_full load_model(model, custom_model, gen_type) File "/home/koen/audiocraft_plus/app.py", line 156, in load_model MODEL = AudioGen.get_pretrained(version) File "/home/koen/audiocraft_plus/audiocraft/models/audiogen.py", line 92, in get_pretrained lm = load_lm_model(name, device=device) File "/home/koen/audiocraft_plus/audiocraft/models/loaders.py", line 111, in load_lm_model model = builders.get_lm_model(cfg) File "/home/koen/audiocraft_plus/audiocraft/models/builders.py", line 97, in get_lm_model condition_provider = get_conditioner_provider(kwargs["dim"], cfg).to(cfg.device) File "/home/koen/audiocraft_plus/audiocraft/models/builders.py", line 137, in get_conditioner_provider conditioners[str(cond)] = T5Conditioner(output_dim=output_dim, device=device, model_args) File "/home/koen/audiocraft_plus/audiocraft/modules/conditioners.py", line 415, in init self.t5_tokenizer = T5Tokenizer.from_pretrained(name) File "/home/koen/.local/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1854, in from_pretrained return cls._from_pretrained( File "/home/koen/.local/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 2017, in _from_pretrained tokenizer = cls(*init_inputs, **init_kwargs) File "/home/koen/.local/lib/python3.10/site-packages/transformers/models/t5/tokenization_t5.py", line 194, in init self.sp_model = self.get_spm_processor() File "/home/koen/.local/lib/python3.10/site-packages/transformers/models/t5/tokenization_t5.py", line 200, in get_spm_processor model_pb2 = import_protobuf() File "/home/koen/.local/lib/python3.10/site-packages/transformers/convert_slow_tokenizer.py", line 40, in import_protobuf return sentencepiece_model_pb2 UnboundLocalError: local variable 'sentencepiece_model_pb2' referenced before assignment

after fresh install Ubuntu server 22.04.2 nvidia rtx 3070 ffmpeg + build-essential + python3-pip installed git clone https://github.com/GrandaddyShmax/audiocraft_plus cd audiocraft_plus pip install 'torch>=2.0' pip install -e .

linux> python3 app.py --listen 192.168.2.91

blackwitch commented 1 year ago

you should install protobuf. pip install protobuf.

initcold commented 1 year ago

awesome! Got it running. Nice features, love it!! thanks a lot. Now we can experiment ...

ashleykleynhans commented 1 year ago

Thanks @blackwitch . Seems that either protobuf should be added to the requirements.txt file, or the requirements.txt should lock in the transformers version because protobuf was not required by transformers 4.31.0, but is required by later versions of transformers, such as 4.33.3.