teticio / audio-diffusion

Apply diffusion models using the new Hugging Face diffusers package to synthesize music instead of images.
GNU General Public License v3.0
707 stars 69 forks source link

NameError: name 'transformers' is not defined upon running model via Gradio #29

Closed cparks1 closed 1 year ago

cparks1 commented 1 year ago

I'm currently using the colab at https://colab.research.google.com/github/teticio/audio-diffusion/blob/master/notebooks/gradio_app.ipynb

Steps to reproduce:

  1. Run the first cell

    try:
    # are we running on Google Colab?
    import google.colab
    !git clone -q https://github.com/teticio/audio-diffusion.git
    %cd audio-diffusion
    %pip install -q -r requirements.txt
    except:
    pass

    NOTE: Saw this error at the end of running the first cell, not sure if it is related: ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. ipython 7.9.0 requires jedi>=0.10, which is not installed.

  2. Run the second cell

    import os
    import sys
    sys.path.insert(0, os.path.dirname(os.path.abspath("")))
  3. Launch the app

  4. Press Submit from the web ui, with any of the models. In this example, I used the teticio/audio-diffusion-instrumental-hiphop-256 model in this case.

  5. Web UI errors out, colab provides this traceback:

    Traceback (most recent call last):
    File "/usr/local/lib/python3.8/dist-packages/gradio/routes.py", line 374, in run_predict
    output = await app.get_blocks().process_api(
    File "/usr/local/lib/python3.8/dist-packages/gradio/blocks.py", line 1017, in process_api
    result = await self.call_function(
    File "/usr/local/lib/python3.8/dist-packages/gradio/blocks.py", line 835, in call_function
    prediction = await anyio.to_thread.run_sync(
    File "/usr/local/lib/python3.8/dist-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
    File "/usr/local/lib/python3.8/dist-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
    File "/usr/local/lib/python3.8/dist-packages/anyio/_backends/_asyncio.py", line 857, in run
    item = self.queue.get()
    File "/content/audio-diffusion/app.py", line 9, in generate_spectrogram_audio_and_loop
    audio_diffusion = AudioDiffusion(model_id=model_id)
    File "/content/audio-diffusion/audiodiffusion/__init__.py", line 30, in __init__
    self.pipe = AudioDiffusionPipeline.from_pretrained(self.model_id)
    File "/usr/local/lib/python3.8/dist-packages/diffusers/pipelines/pipeline_utils.py", line 828, in from_pretrained
    transformers_version = version.parse(version.parse(transformers.__version__).base_version)
    NameError: name 'transformers' is not defined
teticio commented 1 year ago

I was not able to reproduce this. I just ran the notebook on colab and pressed submit and it worked fine... Can you try again?

cparks1 commented 1 year ago

Seems to work fine now.