Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ model = CLIPModel.from_pretrained("geolocal/StreetCLIP")
|
|
13 |
processor = CLIPProcessor.from_pretrained("geolocal/StreetCLIP")
|
14 |
|
15 |
labels = ['Albania', 'Andorra', 'Argentina', 'Australia', 'Austria', 'Bangladesh', 'Belgium', 'Bermuda', 'Bhutan', 'Bolivia', 'Botswana', 'Brazil', 'Bulgaria', 'Cambodia', 'Canada', 'Chile', 'China', 'Colombia', 'Croatia', 'Czech Republic', 'Denmark', 'Dominican Republic', 'Egypt', 'Ecuador', 'Estonia', 'Finland', 'France', 'Germany', 'Ghana', 'Greece', 'Greenland', 'Guam', 'Guatemala', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Ireland', 'Israel', 'Italy', 'Japan', 'Jordan', 'Kenya', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lesotho', 'Lithuania', 'Luxembourg', 'Macedonia', 'Madagascar', 'Malaysia', 'Malta', 'Mexico', 'Monaco', 'Mongolia', 'Montenegro', 'Netherlands', 'New Zealand', 'Nigeria', 'Norway', 'Pakistan', 'Palestine', 'Peru', 'Philippines', 'Poland', 'Portugal', 'Puerto Rico', 'Romania', 'Russia', 'Rwanda','Saudi Arabia', 'Senegal', 'Serbia', 'Singapore', 'Slovakia', 'Slovenia', 'South Africa', 'South Korea', 'Spain', 'Sri Lanka', 'Swaziland', 'Sweden', 'Switzerland', 'Syria','Taiwan', 'Thailand', 'Tunisia', 'Turkey', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'Uruguay']
|
16 |
-
|
17 |
def process_image(image, audio_path="musicgen_out.wav"):
|
18 |
# Ensure the image is in the correct format
|
19 |
if isinstance(image, str):
|
@@ -31,7 +31,8 @@ def process_image(image, audio_path="musicgen_out.wav"):
|
|
31 |
# Get the country with the highest probability
|
32 |
country_index = probs.argmax(dim=1).item()
|
33 |
country = labels[country_index]
|
34 |
-
|
|
|
35 |
# Generate music based on the country
|
36 |
music_description = f"Traditional music from {country}"
|
37 |
#music = musicgen(music_description, forward_params={"do_sample": True})
|
@@ -46,7 +47,7 @@ def process_image(image, audio_path="musicgen_out.wav"):
|
|
46 |
# Save the generated music to the specified path
|
47 |
sampling_rate = musicgen.config.audio_encoder.sampling_rate
|
48 |
scipy.io.wavfile.write("musicgen_out.wav", rate=sampling_rate, data=audio_values[0, 0].numpy())
|
49 |
-
|
50 |
# Return the country and the path to the generated music
|
51 |
return country, audio_path
|
52 |
|
|
|
13 |
processor = CLIPProcessor.from_pretrained("geolocal/StreetCLIP")
|
14 |
|
15 |
labels = ['Albania', 'Andorra', 'Argentina', 'Australia', 'Austria', 'Bangladesh', 'Belgium', 'Bermuda', 'Bhutan', 'Bolivia', 'Botswana', 'Brazil', 'Bulgaria', 'Cambodia', 'Canada', 'Chile', 'China', 'Colombia', 'Croatia', 'Czech Republic', 'Denmark', 'Dominican Republic', 'Egypt', 'Ecuador', 'Estonia', 'Finland', 'France', 'Germany', 'Ghana', 'Greece', 'Greenland', 'Guam', 'Guatemala', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Ireland', 'Israel', 'Italy', 'Japan', 'Jordan', 'Kenya', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lesotho', 'Lithuania', 'Luxembourg', 'Macedonia', 'Madagascar', 'Malaysia', 'Malta', 'Mexico', 'Monaco', 'Mongolia', 'Montenegro', 'Netherlands', 'New Zealand', 'Nigeria', 'Norway', 'Pakistan', 'Palestine', 'Peru', 'Philippines', 'Poland', 'Portugal', 'Puerto Rico', 'Romania', 'Russia', 'Rwanda','Saudi Arabia', 'Senegal', 'Serbia', 'Singapore', 'Slovakia', 'Slovenia', 'South Africa', 'South Korea', 'Spain', 'Sri Lanka', 'Swaziland', 'Sweden', 'Switzerland', 'Syria','Taiwan', 'Thailand', 'Tunisia', 'Turkey', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'Uruguay']
|
16 |
+
labelsAr = ['ألبانيا', 'أندورا', 'الأرجنتين', 'أستراليا', 'النمسا', 'بنغلاديش', 'بلجيكا', 'برمودا', 'بوتان', 'بوليفيا', 'بوتسوانا', 'البرازيل', 'بلغاريا', 'كمبوديا', 'كندا', 'تشيلي', 'الصين', 'كولومبيا', 'كرواتيا', 'جمهورية التشيك', 'الدنمارك', 'جمهورية الدومينيكان', 'مصر', 'الإكوادور', 'إستونيا', 'فنلندا', 'فرنسا', 'ألمانيا', 'غانا', 'اليونان', 'جرينلاند', 'غوام', 'غواتيمالا', 'المجر', 'آيسلندا', 'الهند', 'إندونيسيا', 'أيرلندا', 'إسرائيل', 'إيطاليا', 'اليابان', 'الأردن', 'كينيا', 'قيرغيزستان', 'لاوس', 'لاتفيا', 'ليسوتو', 'ليتوانيا', 'لوكسمبورغ', 'مقدونيا', 'مدغشقر', 'ماليزيا', 'مالطا', 'المكسيك', 'موناكو', 'منغوليا', 'الجبل الأسود', 'هولندا', 'نيوزيلندا', 'نيجيريا', 'النرويج', 'باكستان', 'فلسطين', 'بيرو', 'الفلبين', 'بولندا', 'البرتغال', 'بورتوريكو', 'رومانيا', 'روسيا', 'رواندا', 'المملكة العربية السعودية', 'السنغال', 'صربيا', 'سنغافورة', 'سلوفاكيا', 'سلوفينيا', 'جنوب أفريقيا', 'كوريا الجنوبية', 'إسبانيا', 'سريلانكا', 'سوازيلاند', 'السويد', 'سويسرا', 'سوريا', 'تايوان', 'تايلاند', 'تونس', 'تركيا', 'أوغندا', 'أوكرانيا', 'الإمارات العربية المتحدة', 'المملكة المتحدة', 'الولايات المتحدة', 'أوروغواي']
|
17 |
def process_image(image, audio_path="musicgen_out.wav"):
|
18 |
# Ensure the image is in the correct format
|
19 |
if isinstance(image, str):
|
|
|
31 |
# Get the country with the highest probability
|
32 |
country_index = probs.argmax(dim=1).item()
|
33 |
country = labels[country_index]
|
34 |
+
countryAr = labelsAr[country_index]
|
35 |
+
|
36 |
# Generate music based on the country
|
37 |
music_description = f"Traditional music from {country}"
|
38 |
#music = musicgen(music_description, forward_params={"do_sample": True})
|
|
|
47 |
# Save the generated music to the specified path
|
48 |
sampling_rate = musicgen.config.audio_encoder.sampling_rate
|
49 |
scipy.io.wavfile.write("musicgen_out.wav", rate=sampling_rate, data=audio_values[0, 0].numpy())
|
50 |
+
country = country + " - " + countryAr
|
51 |
# Return the country and the path to the generated music
|
52 |
return country, audio_path
|
53 |
|