Faisal-Data commited on
Commit
f8cf759
·
verified ·
1 Parent(s): 14a7eda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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, audio_path
43
 
44
  # Define the Gradio interface
45
  inputs = gr.Image(type="pil", label="Upload a photo (تحميل صورة)")
46
- outputs = [gr.Textbox(label="Country (البلد)"), gr.Audio(label="Generated Music (الموسيقى المولدة)")]
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,