Spaces:
Runtime error
Runtime error
add notebook for gradio app
Browse files- README.md +1 -1
- app.py +22 -21
- notebooks/gradio_app.ipynb +123 -0
- notebooks/test_model.ipynb +1 -1
- streamlit_app.py +2 -2
README.md
CHANGED
|
@@ -9,7 +9,7 @@ app_file: app.py
|
|
| 9 |
pinned: false
|
| 10 |
license: gpl-3.0
|
| 11 |
---
|
| 12 |
-
# audio-diffusion [](https://colab.research.google.com/github/teticio/audio-diffusion/blob/master/notebooks/
|
| 13 |
|
| 14 |
### Apply [Denoising Diffusion Probabilistic Models](https://arxiv.org/abs/2006.11239) using the new Hugging Face [diffusers](https://github.com/huggingface/diffusers) package to synthesize music instead of images.
|
| 15 |
|
|
|
|
| 9 |
pinned: false
|
| 10 |
license: gpl-3.0
|
| 11 |
---
|
| 12 |
+
# audio-diffusion [](https://colab.research.google.com/github/teticio/audio-diffusion/blob/master/notebooks/gradio_app.ipynb)
|
| 13 |
|
| 14 |
### Apply [Denoising Diffusion Probabilistic Models](https://arxiv.org/abs/2006.11239) using the new Hugging Face [diffusers](https://github.com/huggingface/diffusers) package to synthesize music instead of images.
|
| 15 |
|
app.py
CHANGED
|
@@ -15,30 +15,31 @@ def generate_spectrogram_audio_and_loop(model_id):
|
|
| 15 |
return image, (sample_rate, audio), (sample_rate, loop)
|
| 16 |
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
if __name__ == "__main__":
|
| 19 |
parser = argparse.ArgumentParser()
|
| 20 |
parser.add_argument("--port", type=int)
|
| 21 |
parser.add_argument("--server", type=int)
|
| 22 |
args = parser.parse_args()
|
| 23 |
-
|
| 24 |
-
demo = gr.Interface(
|
| 25 |
-
fn=generate_spectrogram_audio_and_loop,
|
| 26 |
-
title="Audio Diffusion",
|
| 27 |
-
description="Generate audio using Huggingface diffusers.\
|
| 28 |
-
This takes about 20 minutes without a GPU, so why not make yourself a cup of tea in the meantime?",
|
| 29 |
-
inputs=[
|
| 30 |
-
gr.Dropdown(label="Model",
|
| 31 |
-
choices=[
|
| 32 |
-
"teticio/audio-diffusion-256",
|
| 33 |
-
"teticio/audio-diffusion-breaks-256"
|
| 34 |
-
],
|
| 35 |
-
value="teticio/audio-diffusion-256")
|
| 36 |
-
],
|
| 37 |
-
outputs=[
|
| 38 |
-
gr.Image(label="Mel spectrogram", image_mode="L"),
|
| 39 |
-
gr.Audio(label="Audio"),
|
| 40 |
-
gr.Audio(label="Loop"),
|
| 41 |
-
],
|
| 42 |
-
allow_flagging="never"
|
| 43 |
-
)
|
| 44 |
demo.launch(server_name=args.server or "0.0.0.0", server_port=args.port)
|
|
|
|
|
|
|
|
|
| 15 |
return image, (sample_rate, audio), (sample_rate, loop)
|
| 16 |
|
| 17 |
|
| 18 |
+
demo = gr.Interface(fn=generate_spectrogram_audio_and_loop,
|
| 19 |
+
title="Audio Diffusion",
|
| 20 |
+
description="Generate audio using Huggingface diffusers.\
|
| 21 |
+
This takes about 20 minutes without a GPU, so why not make yourself a \
|
| 22 |
+
cup of tea in the meantime?",
|
| 23 |
+
inputs=[
|
| 24 |
+
gr.Dropdown(label="Model",
|
| 25 |
+
choices=[
|
| 26 |
+
"teticio/audio-diffusion-256",
|
| 27 |
+
"teticio/audio-diffusion-breaks-256"
|
| 28 |
+
],
|
| 29 |
+
value="teticio/audio-diffusion-256")
|
| 30 |
+
],
|
| 31 |
+
outputs=[
|
| 32 |
+
gr.Image(label="Mel spectrogram", image_mode="L"),
|
| 33 |
+
gr.Audio(label="Audio"),
|
| 34 |
+
gr.Audio(label="Loop"),
|
| 35 |
+
],
|
| 36 |
+
allow_flagging="never")
|
| 37 |
+
|
| 38 |
if __name__ == "__main__":
|
| 39 |
parser = argparse.ArgumentParser()
|
| 40 |
parser.add_argument("--port", type=int)
|
| 41 |
parser.add_argument("--server", type=int)
|
| 42 |
args = par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 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"id": "a489aa44",
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"source": [
|
| 8 |
+
"<a href=\"https://colab.research.google.com/github/teticio/audio-diffusion/blob/master/notebooks/gradio_app.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
| 9 |
+
]
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"cell_type": "code",
|
| 13 |
+
"execution_count": 1,
|
| 14 |
+
"id": "9502ffa7",
|
| 15 |
+
"metadata": {},
|
| 16 |
+
"outputs": [],
|
| 17 |
+
"source": [
|
| 18 |
+
"try:\n",
|
| 19 |
+
" # are we running on Google Colab?\n",
|
| 20 |
+
" import google.colab\n",
|
| 21 |
+
" !git clone -q https://github.com/teticio/audio-diffusion.git\n",
|
| 22 |
+
" %cd audio-diffusion\n",
|
| 23 |
+
" !pip install -q -r requirements.txt\n",
|
| 24 |
+
"except:\n",
|
| 25 |
+
" pass"
|
| 26 |
+
]
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"cell_type": "code",
|
| 30 |
+
"execution_count": 2,
|
| 31 |
+
"id": "8f8b6e43",
|
| 32 |
+
"metadata": {},
|
| 33 |
+
"outputs": [],
|
| 34 |
+
"source": [
|
| 35 |
+
"import os\n",
|
| 36 |
+
"import sys\n",
|
| 37 |
+
"sys.path.insert(0, os.path.dirname(os.path.abspath(\"\")))"
|
| 38 |
+
]
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"cell_type": "code",
|
| 42 |
+
"execution_count": 3,
|
| 43 |
+
"id": "2d948967",
|
| 44 |
+
"metadata": {
|
| 45 |
+
"scrolled": false
|
| 46 |
+
},
|
| 47 |
+
"outputs": [
|
| 48 |
+
{
|
| 49 |
+
"name": "stdout",
|
| 50 |
+
"output_type": "stream",
|
| 51 |
+
"text": [
|
| 52 |
+
"Running on local URL: http://127.0.0.1:7861/\n",
|
| 53 |
+
"Running on public URL: https://24053.gradio.app\n",
|
| 54 |
+
"\n",
|
| 55 |
+
"This share link expires in 72 hours. For free permanent hosting, check out Spaces: https://huggingface.co/spaces\n"
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"data": {
|
| 60 |
+
"text/html": [
|
| 61 |
+
"<div><iframe src=\"https://24053.gradio.app\" width=\"900\" height=\"500\" allow=\"autoplay; camera; microphone;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
| 62 |
+
],
|
| 63 |
+
"text/plain": [
|
| 64 |
+
"<IPython.core.display.HTML object>"
|
| 65 |
+
]
|
| 66 |
+
},
|
| 67 |
+
"metadata": {},
|
| 68 |
+
"output_type": "display_data"
|
| 69 |
+
}
|
| 70 |
+
],
|
| 71 |
+
"source": [
|
| 72 |
+
"import app"
|
| 73 |
+
]
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"cell_type": "code",
|
| 77 |
+
"execution_count": null,
|
| 78 |
+
"id": "46f03607",
|
| 79 |
+
"metadata": {},
|
| 80 |
+
"outputs": [],
|
| 81 |
+
"source": []
|
| 82 |
+
}
|
| 83 |
+
],
|
| 84 |
+
"metadata": {
|
| 85 |
+
"accelerator": "GPU",
|
| 86 |
+
"colab": {
|
| 87 |
+
"provenance": []
|
| 88 |
+
},
|
| 89 |
+
"gpuClass": "standard",
|
| 90 |
+
"kernelspec": {
|
| 91 |
+
"display_name": "huggingface",
|
| 92 |
+
"language": "python",
|
| 93 |
+
"name": "huggingface"
|
| 94 |
+
},
|
| 95 |
+
"language_info": {
|
| 96 |
+
"codemirror_mode": {
|
| 97 |
+
"name": "ipython",
|
| 98 |
+
"version": 3
|
| 99 |
+
},
|
| 100 |
+
"file_extension": ".py",
|
| 101 |
+
"mimetype": "text/x-python",
|
| 102 |
+
"name": "python",
|
| 103 |
+
"nbconvert_exporter": "python",
|
| 104 |
+
"pygments_lexer": "ipython3",
|
| 105 |
+
"version": "3.10.4"
|
| 106 |
+
},
|
| 107 |
+
"toc": {
|
| 108 |
+
"base_numbering": 1,
|
| 109 |
+
"nav_menu": {},
|
| 110 |
+
"number_sections": true,
|
| 111 |
+
"sideBar": true,
|
| 112 |
+
"skip_h1_title": false,
|
| 113 |
+
"title_cell": "Table of Contents",
|
| 114 |
+
"title_sidebar": "Contents",
|
| 115 |
+
"toc_cell": false,
|
| 116 |
+
"toc_position": {},
|
| 117 |
+
"toc_section_display": true,
|
| 118 |
+
"toc_window_display": false
|
| 119 |
+
}
|
| 120 |
+
},
|
| 121 |
+
"nbformat": 4,
|
| 122 |
+
"nbformat_minor": 5
|
| 123 |
+
}
|
notebooks/test_model.ipynb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "markdown",
|
| 5 |
-
"id": "
|
| 6 |
"metadata": {},
|
| 7 |
"source": [
|
| 8 |
"<a href=\"https://colab.research.google.com/github/teticio/audio-diffusion/blob/master/notebooks/test_model.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "markdown",
|
| 5 |
+
"id": "62c5865f",
|
| 6 |
"metadata": {},
|
| 7 |
"source": [
|
| 8 |
"<a href=\"https://colab.research.google.com/github/teticio/audio-diffusion/blob/master/notebooks/test_model.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
streamlit_app.py
CHANGED
|
@@ -9,8 +9,8 @@ from audiodiffusion import AudioDiffusion
|
|
| 9 |
if __name__ == "__main__":
|
| 10 |
st.header("Audio Diffusion")
|
| 11 |
st.markdown("Generate audio using Huggingface diffusers.\
|
| 12 |
-
This takes about 20 minutes without a GPU, so why not make yourself a
|
| 13 |
-
|
| 14 |
|
| 15 |
model_id = st.selectbox(
|
| 16 |
"Model",
|
|
|
|
| 9 |
if __name__ == "__main__":
|
| 10 |
st.header("Audio Diffusion")
|
| 11 |
st.markdown("Generate audio using Huggingface diffusers.\
|
| 12 |
+
This takes about 20 minutes without a GPU, so why not make yourself a \
|
| 13 |
+
cup of tea in the meantime?")
|
| 14 |
|
| 15 |
model_id = st.selectbox(
|
| 16 |
"Model",
|