Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ from PIL import Image
|
|
| 5 |
import scipy.io.wavfile
|
| 6 |
|
| 7 |
# Load the MusicGen model
|
| 8 |
-
musicgen = pipeline("text-to-audio", model="facebook/musicgen-small")
|
| 9 |
|
| 10 |
# Load the StreetCLIP model
|
| 11 |
model = CLIPModel.from_pretrained("geolocal/StreetCLIP")
|
|
@@ -32,18 +32,18 @@ def process_image(image, audio_path="musicgen_out.wav"):
|
|
| 32 |
country = labels[country_index]
|
| 33 |
|
| 34 |
# Generate music based on the country
|
| 35 |
-
music_description = f"Traditional music from {country}"
|
| 36 |
-
music = musicgen(music_description, forward_params={"do_sample": True})
|
| 37 |
|
| 38 |
# Save the generated music to the specified path
|
| 39 |
scipy.io.wavfile.write(audio_path, rate=music["sampling_rate"], data=music["audio"])
|
| 40 |
|
| 41 |
# Return the country and the path to the generated music
|
| 42 |
-
return country
|
| 43 |
|
| 44 |
# Define the Gradio interface
|
| 45 |
inputs = gr.Image(type="pil", label="Upload a photo (تحميل صورة)")
|
| 46 |
-
outputs = [gr.Textbox(label="Country (البلد)")
|
| 47 |
|
| 48 |
iface = gr.Interface(
|
| 49 |
fn=process_image,
|
|
|
|
| 5 |
import scipy.io.wavfile
|
| 6 |
|
| 7 |
# Load the MusicGen model
|
| 8 |
+
#musicgen = pipeline("text-to-audio", model="facebook/musicgen-small")
|
| 9 |
|
| 10 |
# Load the StreetCLIP model
|
| 11 |
model = CLIPModel.from_pretrained("geolocal/StreetCLIP")
|
|
|
|
| 32 |
country = labels[country_index]
|
| 33 |
|
| 34 |
# Generate music based on the country
|
| 35 |
+
#music_description = f"Traditional music from {country}"
|
| 36 |
+
#music = musicgen(music_description, forward_params={"do_sample": True})
|
| 37 |
|
| 38 |
# Save the generated music to the specified path
|
| 39 |
scipy.io.wavfile.write(audio_path, rate=music["sampling_rate"], data=music["audio"])
|
| 40 |
|
| 41 |
# Return the country and the path to the generated music
|
| 42 |
+
return country
|
| 43 |
|
| 44 |
# Define the Gradio interface
|
| 45 |
inputs = gr.Image(type="pil", label="Upload a photo (تحميل صورة)")
|
| 46 |
+
outputs = [gr.Textbox(label="Country (البلد)")]
|
| 47 |
|
| 48 |
iface = gr.Interface(
|
| 49 |
fn=process_image,
|