Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -64,47 +64,59 @@ def get_audioldm_from_caption(caption):
|
|
| 64 |
print(f"Error generating audio from caption: {e}")
|
| 65 |
return None
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
1. **Upload an Image**: Select an image to analyze.
|
| 82 |
-
2. **Generate Description**: Get a detailed caption describing your image.
|
| 83 |
-
3. **Generate Sound**: Create an audio representation based on the caption.
|
| 84 |
-
""")
|
| 85 |
-
|
| 86 |
-
with gr.Row():
|
| 87 |
-
with gr.Column(scale=1):
|
| 88 |
-
image_upload = gr.File(label="Upload Image", type="binary")
|
| 89 |
-
generate_description_button = gr.Button("Generate Description", variant="primary")
|
| 90 |
-
with gr.Column(scale=2):
|
| 91 |
-
caption_display = gr.Textbox(label="Generated Caption", interactive=False, placeholder="Your image caption will appear here.")
|
| 92 |
-
generate_sound_button = gr.Button("Generate Sound", variant="primary")
|
| 93 |
-
with gr.Column(scale=1):
|
| 94 |
-
audio_output = gr.Audio(label="Generated Sound Effect", interactive=False)
|
| 95 |
-
|
| 96 |
-
with gr.Row():
|
| 97 |
-
gr.Markdown("""
|
| 98 |
-
## About This App
|
| 99 |
-
This application uses advanced machine learning models to transform images into text captions and generate matching sound effects. It's a unique blend of visual and auditory creativity, powered by state-of-the-art AI technology.
|
| 100 |
-
|
| 101 |
-
### Powered By
|
| 102 |
-
- [Hugging Face](https://huggingface.co)
|
| 103 |
-
- [Diffusion Models](https://huggingface.co/models)
|
| 104 |
-
|
| 105 |
-
For inquiries, contact us at [contact@bilsimaging.com](mailto:contact@bilsimaging.com).
|
| 106 |
""")
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
def update_caption(image_file):
|
| 109 |
description, _ = analyze_image_with_free_model(image_file)
|
| 110 |
return description
|
|
@@ -127,4 +139,4 @@ with gr.Blocks() as demo:
|
|
| 127 |
outputs=audio_output
|
| 128 |
)
|
| 129 |
|
| 130 |
-
demo.launch(debug=True, share=True)
|
|
|
|
| 64 |
print(f"Error generating audio from caption: {e}")
|
| 65 |
return None
|
| 66 |
|
| 67 |
+
css = """
|
| 68 |
+
#col-container{
|
| 69 |
+
margin: 0 auto;
|
| 70 |
+
max-width: 800px;
|
| 71 |
+
}
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
with gr.Blocks(css=css) as demo:
|
| 75 |
+
with gr.Column(elem_id="col-container"):
|
| 76 |
+
gr.HTML("""
|
| 77 |
+
<h1 style="text-align: center;">🎶 Generate Sound Effects from Image</h1>
|
| 78 |
+
<p style="text-align: center;">
|
| 79 |
+
⚡ Powered by <a href="https://bilsimaging.com" target="_blank">Bilsimaging</a>
|
| 80 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
""")
|
| 82 |
|
| 83 |
+
gr.Markdown("""
|
| 84 |
+
Welcome to this unique sound effect generator! This tool allows you to upload an image and generate a
|
| 85 |
+
descriptive caption and a corresponding sound effect, all using free, open-source models on Hugging Face.
|
| 86 |
+
|
| 87 |
+
**💡 How it works:**
|
| 88 |
+
1. **Upload an image**: Choose an image that you'd like to analyze.
|
| 89 |
+
2. **Generate Description**: Click on 'Generate Description' to get a textual description of your uploaded image.
|
| 90 |
+
3. **Generate Sound Effect**: Based on the image description, click on 'Generate Sound Effect' to create a
|
| 91 |
+
sound effect that matches the image context.
|
| 92 |
+
|
| 93 |
+
Enjoy the journey from visual to auditory sensation with just a few clicks!
|
| 94 |
+
""")
|
| 95 |
+
|
| 96 |
+
image_upload = gr.File(label="Upload Image", type="binary")
|
| 97 |
+
generate_description_button = gr.Button("Generate Description")
|
| 98 |
+
caption_display = gr.Textbox(label="Image Description", interactive=False)
|
| 99 |
+
generate_sound_button = gr.Button("Generate Sound Effect")
|
| 100 |
+
audio_output = gr.Audio(label="Generated Sound Effect")
|
| 101 |
+
|
| 102 |
+
gr.Markdown("""
|
| 103 |
+
## 👥 How You Can Contribute
|
| 104 |
+
We welcome contributions and suggestions for improvements. Your feedback is invaluable
|
| 105 |
+
to the continuous enhancement of this application.
|
| 106 |
+
|
| 107 |
+
For support, questions, or to contribute, please contact us at
|
| 108 |
+
[contact@bilsimaging.com](mailto:contact@bilsimaging.com).
|
| 109 |
+
|
| 110 |
+
Support our work and get involved by donating through
|
| 111 |
+
[Ko-fi](https://ko-fi.com/bilsimaging). - Bilel Aroua
|
| 112 |
+
""")
|
| 113 |
+
|
| 114 |
+
gr.Markdown("""
|
| 115 |
+
## 📢 Stay Connected
|
| 116 |
+
This app is a testament to the creative possibilities that emerge when technology meets art.
|
| 117 |
+
Enjoy exploring the auditory landscape of your images!
|
| 118 |
+
""")
|
| 119 |
+
|
| 120 |
def update_caption(image_file):
|
| 121 |
description, _ = analyze_image_with_free_model(image_file)
|
| 122 |
return description
|
|
|
|
| 139 |
outputs=audio_output
|
| 140 |
)
|
| 141 |
|
| 142 |
+
demo.launch(debug=True, share=True)
|