Bils commited on
Commit
e33e34e
·
verified ·
1 Parent(s): 61ea6d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +66 -44
app.py CHANGED
@@ -65,57 +65,79 @@ def get_audioldm_from_caption(caption):
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
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)
 
65
  return None
66
 
67
  css = """
68
+ #header-container {
69
+ text-align: center;
70
+ margin: 20px 0;
71
+ }
72
+
73
+ #header-title {
74
+ font-size: 36px;
75
+ font-weight: bold;
76
+ margin-bottom: 10px;
77
+ }
78
+
79
+ #header-subtitle {
80
+ font-size: 18px;
81
+ margin-bottom: 20px;
82
+ color: #6c757d;
83
+ }
84
+
85
+ #main-container {
86
+ max-width: 900px;
87
  margin: 0 auto;
88
+ padding: 20px;
89
+ border-radius: 12px;
90
+ background-color: #f9f9f9;
91
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
92
+ }
93
+
94
+ button.primary-button {
95
+ background-color: #007bff;
96
+ color: white;
97
+ border: none;
98
+ padding: 10px 20px;
99
+ border-radius: 5px;
100
+ font-size: 16px;
101
+ cursor: pointer;
102
+ }
103
+
104
+ button.primary-button:hover {
105
+ background-color: #0056b3;
106
+ }
107
  """
108
 
109
  with gr.Blocks(css=css) as demo:
110
+ with gr.Column(elem_id="header-container"):
111
  gr.HTML("""
112
+ <div id="header-title">🎶 Image-to-Sound Generator</div>
113
+ <div id="header-subtitle">Transform your images into descriptive captions and immersive soundscapes.</div>
 
 
114
  """)
115
 
116
+ with gr.Box(elem_id="main-container"):
117
+ gr.Markdown("""
118
+ ### How It Works
119
+ 1. **Upload an Image**: Select an image to analyze.
120
+ 2. **Generate Description**: Get a detailed caption describing your image.
121
+ 3. **Generate Sound**: Create an audio representation based on the caption.
122
+ """)
123
+
124
+ image_upload = gr.File(label="Upload Image", type="binary")
125
+ generate_description_button = gr.Button("Generate Description", elem_classes="primary-button")
126
+ caption_display = gr.Textbox(label="Generated Caption", interactive=False, placeholder="Your image caption will appear here.")
127
+ generate_sound_button = gr.Button("Generate Sound", elem_classes="primary-button")
128
+ audio_output = gr.Audio(label="Generated Sound Effect", interactive=False)
129
+
130
+ with gr.Box():
131
+ gr.Markdown("""
132
+ ## About This App
133
+ 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.
134
+
135
+ ### Powered By
136
+ - [Hugging Face](https://huggingface.co)
137
+ - [Diffusion Models](https://huggingface.co/models)
138
+
139
+ For inquiries, contact us at [[email protected]](mailto:[email protected]).
140
+ """)
 
 
 
 
 
 
 
 
 
 
 
141
 
142
  def update_caption(image_file):
143
  description, _ = analyze_image_with_free_model(image_file)