Spaces:
Running
Running
arxivgpt kim
commited on
Commit
โข
d3cb1f3
1
Parent(s):
f273c5c
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,21 @@ import json
|
|
4 |
import re
|
5 |
from moviepy.editor import VideoFileClip
|
6 |
from moviepy.audio.AudioClip import AudioClip
|
|
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
def extract_audio(video_in):
|
9 |
input_video = video_in
|
10 |
output_audio = 'audio.wav'
|
@@ -136,24 +150,47 @@ css="""
|
|
136 |
}
|
137 |
"""
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
]
|
143 |
|
144 |
-
with gr.Blocks() as
|
145 |
with gr.Column():
|
146 |
-
gr.Markdown("### Image
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
submit_btn.click(
|
153 |
fn=infer,
|
154 |
inputs=[image_in, chosen_model],
|
155 |
-
outputs=audio_o
|
156 |
)
|
157 |
|
158 |
-
|
159 |
-
demo.launch(examples=image_examples, debug=True)
|
|
|
4 |
import re
|
5 |
from moviepy.editor import VideoFileClip
|
6 |
from moviepy.audio.AudioClip import AudioClip
|
7 |
+
import requests
|
8 |
|
9 |
+
def search_pexels_images(query):
|
10 |
+
API_KEY = '5woz23MGx1QrSY0WHFb0BRi29JvbXPu97Hg0xnklYgHUI8G0w23FKH62' # Pexels API ํค๋ฅผ ์ฌ๊ธฐ์ ์
๋ ฅํ์ธ์.
|
11 |
+
url = f"https://api.pexels.com/v1/search?query={query}&per_page=5" # ๊ฒ์ ๊ฒฐ๊ณผ 5๊ฐ๋ง ๊ฐ์ ธ์ต๋๋ค.
|
12 |
+
|
13 |
+
headers = {
|
14 |
+
"Authorization": API_KEY
|
15 |
+
}
|
16 |
+
response = requests.get(url, headers=headers)
|
17 |
+
data = response.json()
|
18 |
+
|
19 |
+
images_urls = [photo['src']['medium'] for photo in data['photos']]
|
20 |
+
return images_urls
|
21 |
+
|
22 |
def extract_audio(video_in):
|
23 |
input_video = video_in
|
24 |
output_audio = 'audio.wav'
|
|
|
150 |
}
|
151 |
"""
|
152 |
|
153 |
+
def show_search_results(query):
|
154 |
+
images_urls = search_pexels_images(query)
|
155 |
+
return images_urls
|
|
|
156 |
|
157 |
+
with gr.Blocks() as app:
|
158 |
with gr.Column():
|
159 |
+
gr.Markdown("### Image SFX Generator with Pexels Image Search")
|
160 |
+
search_query = gr.Textbox(label="์ฌ์ง ๊ฒ์")
|
161 |
+
search_btn = gr.Button("๊ฒ์")
|
162 |
+
images_output = gr.Gallery(label="๊ฒ์ ๊ฒฐ๊ณผ ์ด๋ฏธ์ง")
|
163 |
+
|
164 |
+
search_btn.click(
|
165 |
+
fn=show_search_results,
|
166 |
+
inputs=search_query,
|
167 |
+
outputs=images_output
|
168 |
+
)
|
169 |
+
app.launch(debug=True)
|
170 |
+
|
171 |
+
with gr.Blocks(css=css) as demo:
|
172 |
+
with gr.Column(elem_id="col-container"):
|
173 |
+
gr.HTML("""
|
174 |
+
<h2 style="text-align: center;">
|
175 |
+
Image to SFX
|
176 |
+
</h2>
|
177 |
+
<p style="text-align: center;">
|
178 |
+
Compare MAGNet, AudioLDM2 and AudioGen sound effects generation from image caption.
|
179 |
+
</p>
|
180 |
+
""")
|
181 |
+
|
182 |
+
with gr.Column():
|
183 |
+
image_in = gr.Image(sources=["upload"], type="filepath", label="Image input", value="oiseau.png")
|
184 |
+
with gr.Row():
|
185 |
+
chosen_model = gr.Radio(label="Choose a model", choices=["MAGNet", "AudioLDM-2", "AudioGen"], value="AudioLDM-2")
|
186 |
+
submit_btn = gr.Button("Submit")
|
187 |
+
with gr.Column():
|
188 |
+
audio_o = gr.Audio(label="Audio output")
|
189 |
+
|
190 |
submit_btn.click(
|
191 |
fn=infer,
|
192 |
inputs=[image_in, chosen_model],
|
193 |
+
outputs=[audio_o]
|
194 |
)
|
195 |
|
196 |
+
demo.queue(max_size=10).launch(debug=True)
|
|