import gradio as gr import torch from transformers import CLIPProcessor, CLIPModel from datetime import datetime import requests from PIL import Image import io print("🚀 Loading Uganda Tourism AI...") # Load AI Model model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32") processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32") # COMPREHENSIVE DATABASE OF ALL UGANDA TOURIST ATTRACTIONS WITH RICH DESCRIPTIONS UGANDA_SITES = { # LAKES "lake_victoria": { "name": "Lake Victoria", "type": "Lake", "description": "Lake Victoria is not merely a body of water; it is the very heartbeat of East Africa. As the world's second-largest freshwater lake and Africa's largest, this immense aquatic wonder spans approximately 68,800 square kilometers, touching Uganda, Kenya, and Tanzania. The lake serves as the primary source of the Nile River, the world's longest river, making it a geographical marvel of global significance. Its shores are dotted with vibrant fishing communities that have maintained traditional practices for generations, while its waters host over 500 species of fish, including the famed Nile perch that can grow to monumental sizes. Sunsets over Lake Victoria are legendary—fiery oranges and purples reflected in the gentle waves create a spectacle that leaves visitors spellbound. The lake's numerous islands, each with unique ecosystems and cultures, offer endless exploration opportunities. From the bustling ports of Entebbe to the tranquil Ssese Islands, Lake Victoria represents both the economic lifeblood and natural soul of the region.", "history": "First documented by British explorer John Hanning Speke in 1858 during his quest to discover the source of the Nile, Lake Victoria was named in honor of Queen Victoria. For centuries before European documentation, the lake had been central to the livelihoods and cultures of the surrounding communities, serving as a crucial trade route and source of sustenance. The lake's discovery solved one of geography's greatest mysteries—the source of the Nile—and cemented Uganda's place in world exploration history. Today, it remains vital for transportation, fishing, and hydroelectric power generation.", "location": "Southern Uganda, forming natural borders with Kenya and Tanzania", "activities": "Deep-sea fishing for Nile perch, Traditional dhow sailing excursions, Island-hopping adventures, Bird watching (over 200 species), Sunset photography tours, Lakeside camping under starry skies, Cultural visits to fishing villages, Kayaking through tranquil bays", "best_time": "Year-round destination; December-February offers calm waters and ideal conditions for water activities", "entry_fee": "Free access to public beaches; organized tours range from $20-$100 depending on duration and activities", "image_urls": [ "https://upload.wikimedia.org/wikipedia/commons/thumb/c/ce/Lake_Victoria_from_space.jpg/800px-Lake_Victoria_from_space.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Lake_Victoria_shoreline.jpg/800px-Lake_Victoria_shoreline.jpg" ], "recommendations": ["Ssese Islands Archipelago", "Lake Bunyonyi", "Ngamba Island Chimpanzee Sanctuary"] }, "lake_bunyonyi": { "name": "Lake Bunyonyi", "type": "Lake", "description": "Nestled like a precious jewel in Uganda's southwestern highlands, Lake Bunyonyi is often called 'Africa's Switzerland' for its breathtaking alpine-like beauty. This stunning terraced lake, believed to be Africa's second deepest at approximately 900 meters, features 29 picturesque islands scattered across its tranquil, mirror-like waters. The name 'Bunyonyi' translates to 'place of many little birds,' a fitting tribute to the abundant avian life that graces its shores with constant melody and color. The surrounding landscape of lush, rolling hills creates a mesmerizing panorama that changes with the shifting light—mornings bring ethereal mists that cling to the water, while evenings paint the sky in fiery hues. Remarkably, the lake is free of bilharzia and crocodiles, making it perfectly safe for swimming and water activities. Each island tells a unique story: Punishment Island speaks to historical cultural practices, Bushara Island showcases sustainable eco-tourism, and Bwama Island hosts educational initiatives. The local Bakiga and Batwa communities welcome visitors with genuine warmth, sharing stories passed through generations.", "history": "Formed approximately 10,000 years ago through volcanic activity and tectonic movements that created natural dams in the valleys. During colonial times, the lake served as a natural boundary between British and German territories in East Africa. The islands were historically used for various purposes including cultivation, habitation, and in some cases, served specific cultural functions. In recent decades, sustainable tourism initiatives have transformed the area while preserving its pristine beauty and cultural heritage, making it a model for community-based conservation.", "location": "Southwestern Uganda, approximately 7 km from Kabale Town in the Kigezi Highlands", "activities": "Traditional dugout canoe exploration, Bird watching expeditions (over 200 species), Guided island-hopping tours, Swimming in the safe, clear waters, Hiking the surrounding terraced hills, Cultural immersion with local communities, Photography workshops capturing the stunning scenery, Stargazing from lakeside accommodations", "best_time": "June-September (dry season) offers clear skies and optimal visibility; December-February also provides excellent conditions", "entry_fee": "Free access; traditional canoe rentals $10-$30; guided tours $25-$50 depending on duration", "image_urls": [ "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9c/Lake_Bunyonyi.jpg/800px-Lake_Bunyonyi.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Lake_Bunyonyi_landscape.jpg/800px-Lake_Bunyonyi_landscape.jpg" ], "recommendations": ["Bwindi Impenetrable Forest", "Lake Mutanda", "Kisoro Mountain Town"] }, "bwindi_forest": { "name": "Bwindi Impenetrable Forest", "type": "UNESCO World Heritage Site", "description": "Bwindi Impenetrable Forest is not just a national park; it is a living, breathing cathedral of biodiversity and one of Africa's most precious conservation treasures. This ancient rainforest, dating back over 25,000 years, covers 331 square kilometers of steep hills and deep valleys draped in thick, verdant vegetation that gives the forest its 'impenetrable' reputation. As a UNESCO World Heritage Site, Bwindi shelters approximately half of the world's remaining mountain gorilla population—about 400 of these magnificent creatures. The experience of gorilla tracking here is profoundly transformative: hiking through mist-shrouded forests, listening to the symphony of exotic birds and insects, and finally encountering a gorilla family in their natural habitat creates memories that last a lifetime. Beyond gorillas, the forest hosts 120 mammal species, 350 bird species (including 23 Albertine Rift endemics), 200 butterfly species, and countless plant species, some found nowhere else on Earth. The forest is also home to the indigenous Batwa pygmies, whose deep cultural connection to this ecosystem spans millennia.", "history": "Designated as a national park in 1991 and inscribed as a UNESCO World Heritage Site in 1994 for its exceptional biodiversity and critical role in mountain gorilla conservation. The forest has been inhabited by the Batwa pygmies for over 60,000 years, making them the original guardians of this ecosystem. During the 1990s, conservation efforts successfully balanced wildlife protection with community needs, creating a model for sustainable tourism that benefits both conservation and local populations. Today, Bwindi stands as a testament to what can be achieved when conservation, community, and tourism work in harmony.", "location": "Southwestern Uganda, bordering the Democratic Republic of Congo, spanning the districts of Kanungu, Kabale, and Kisoro", "activities": "Mountain gorilla tracking (the park's premier experience), Bird watching for Albertine Rift endemics, Guided nature walks through ancient forest trails, Cultural encounters with Batwa communities, Photography of unique flora and fauna, Primatology research opportunities, Community visits to understand conservation efforts, Canopy walks for aerial forest views", "best_time": "June-September and December-February (dry seasons) for easier trekking conditions; gorilla viewing possible year-round", "entry_fee": "Gorilla permit: $800 (foreign non-residents); park entry: $40/day; additional activity fees apply", "image_urls": [ "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7a/Bwindi_forest.jpg/800px-Bwindi_forest.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Mountain_gorilla_Bwindi.jpg/800px-Mountain_gorilla_Bwindi.jpg" ], "recommendations": ["Mgahinga Gorilla National Park", "Lake Bunyonyi", "Ruhija Sector for bird watching"] }, "murchison_falls": { "name": "Murchison Falls", "type": "Natural Wonder", "description": "Murchison Falls represents nature at its most raw and powerful—a spectacle that must be experienced to be truly understood. Here, the entire Victoria Nile, Africa's longest river, is forced through a narrow 7-meter gorge before plunging 43 meters into what locals call the 'Devil's Cauldron' below. The resulting explosion of water creates a thunderous roar that can be heard from miles away, while the constant mist generates permanent rainbows that dance in the sunlight. Located within Uganda's largest national park, the falls serve as the dramatic centerpiece of an ecosystem teeming with wildlife. The surrounding Murchison Falls National Park offers some of Africa's best game viewing, with elephants, giraffes, lions, and the rare shoebill stork among its residents. The falls' mist creates unique microclimates supporting specialized vegetation, while the river below hosts enormous Nile crocodiles and hippopotamus pods. A boat safari to the base of the falls provides a humbling perspective of nature's power, while hiking to the top offers breathtaking panoramic views.", "history": "Discovered by European explorers Samuel and Florence Baker in 1864 during their epic Nile expedition. They named the falls after Sir Roderick Murchison, then president of the Royal Geographical Society. The area gained cinematic fame as a filming location for the 1951 classic 'The African Queen' starring Humphrey Bogart and Katharine Hepburn. In the 1960s, the park suffered during political instability but has since undergone remarkable recovery through dedicated conservation efforts. Today, it stands as one of Uganda's premier wildlife destinations, attracting visitors from around the world to witness its unique combination of powerful waterfalls and abundant wildlife.", "location": "Murchison Falls National Park, Northwestern Uganda, approximately 300 km from Kampala", "activities": "Boat safari to the base of the falls for up-close views, Hiking to the top of the falls for panoramic perspectives, Game drives in the Nile Delta area (prime wildlife viewing), Bird watching expeditions focusing on the rare shoebill stork, Hot air balloon safaris at sunrise, Sport fishing for massive Nile perch, Nature walks in Rabongo Forest, Photography workshops capturing the falls and wildlife", "best_time": "December-February (dry season) for optimal wildlife viewing and waterfall flow; June-September also excellent", "entry_fee": "Foreign non-residents: $45/day park entry; boat safaris $30; guided activities additional", "image_urls": [ "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Murchison_Falls.jpg/800px-Murchison_Falls.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Murchison_Falls_National_Park_02.jpg/800px-Murchison_Falls_National_Park_02.jpg" ], "recommendations": ["Ziwa Rhino Sanctuary", "Budongo Forest Reserve", "Paraa Safari Lodge for luxury accommodation"] }, "queen_elizabeth_np": { "name": "Queen Elizabeth National Park", "type": "Biodiversity Hotspot", "description": "Queen Elizabeth National Park is Uganda's showcase of African biodiversity—a magnificent tapestry of ecosystems spanning 1,978 square kilometers within the Albertine Rift Valley. This park encompasses everything from open savanna and dense rainforest to sparkling crater lakes and sprawling wetlands, creating habitats for an astonishing array of wildlife. The park is globally famous for its unique tree-climbing lions of the Ishasha sector—a behavior rarely seen elsewhere in Africa. Massive herds of elephants roam the plains, while the 40-kilometer Kazinga Channel hosts Africa's highest concentration of hippos and some of the continent's largest Nile crocodiles. With over 600 bird species recorded, it's a birder's paradise, including the spectacular martial eagle and colorful African skimmer. The dramatic backdrop of the Rwenzori Mountains—the fabled 'Mountains of the Moon'—adds breathtaking scenery, while dozens of volcanic craters create a surreal landscape. From boat safaris teeming with wildlife to cultural encounters with local communities, Queen Elizabeth offers the complete African safari experience.", "history": "Founded in 1952 as Kazinga National Park and renamed in 1954 after a visit by Queen Elizabeth II of England. The park survived the turbulent 1970s-80s when Uganda's wildlife suffered dramatically, and has since undergone one of Africa's most successful conservation recoveries. Innovative community conservation programs have made local residents partners in protection, while sustainable tourism has created economic benefits. The park's diverse ecosystems have made it a living laboratory for scientists studying everything from lion behavior to climate change impacts, cementing its status as one of Africa's most important protected areas.", "location": "Western Uganda, spanning the districts of Kasese, Kamwenge, Rubirizi, and Rukungiri", "activities": "Game drives in different ecological sectors, Kazinga Channel boat cruise (Africa's premier wildlife waterway), Lion tracking experience in Ishasha, Chimpanzee tracking in Kyambura Gorge, Bird watching expeditions (over 600 species), Hot air balloon safaris at dawn, Cultural performances and community visits, Photography tours capturing diverse landscapes, Crater lake exploration", "best_time": "January-February and June-July (dry seasons) for optimal wildlife viewing; birding excellent year-round", "entry_fee": "Foreign non-residents: $50/day park entry; boat cruise $30; lion tracking $100; additional activity fees apply", "image_urls": [ "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Queen_Elizabeth_National_Park.jpg/800px-Queen_Elizabeth_National_Park.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Tree-climbing_lion_Queen_Elizabeth_NP.jpg/800px-Tree-climbing_lion_Queen_Elizabeth_NP.jpg" ], "recommendations": ["Kibale National Park for chimpanzees", "Maramagambo Forest for primates", "Katwe Salt Lake for cultural experience"] }, "rwenzori_mountains": { "name": "Rwenzori Mountains", "type": "UNESCO World Heritage Site", "description": "The Rwenzori Mountains, famously known as the 'Mountains of the Moon,' represent one of Africa's most spectacular and challenging mountain ranges. Unlike the volcanic peaks of Kilimanjaro and Kenya, the Rwenzoris are a block of ancient crystalline rock pushed upward, creating some of the continent's most dramatic alpine scenery. The range includes Africa's third-highest peak, Margherita Peak at 5,109 meters, permanently draped in glaciers and snow despite its equatorial location. What makes the Rwenzoris truly unique is their otherworldly vegetation: giant lobelias (some reaching 8 meters), enormous heathers, and 'everlasting flowers' create landscapes that feel more like science fiction than reality. The mountains feature five distinct vegetation zones climbed in rapid succession—from tropical rainforest to alpine meadows to glacial peaks. This UNESCO World Heritage Site is not just a climbing destination but a biodiversity hotspot hosting numerous endemic species found nowhere else on Earth. The local Bakonzo people consider the mountains sacred, adding cultural depth to the physical challenge.", "history": "First mentioned by Ptolemy in 150 AD as the 'Mountains of the Moon,' believed to be the source of the Nile River. The first European ascent was accomplished in 1906 by an Italian expedition led by the Duke of Abruzzi. The mountains have been inhabited by the Bakonzo people for centuries, who developed unique cultural practices adapted to the challenging environment. Designated a UNESCO World Heritage Site in 1994 for their outstanding natural beauty and biodiversity, the Rwenzoris offer some of Africa's most rewarding trekking experiences, combining physical challenge with breathtaking scenery and rich cultural encounters.", "location": "Western Uganda, bordering the Democratic Republic of Congo, approximately 30 km from Kasese Town", "activities": "Multi-day mountain climbing expeditions to Margherita Peak, Guided nature walks through unique vegetation zones, Bird watching for Rwenzori endemics, Cultural encounters with Bakonzo communities, Photography of surreal alpine landscapes, Alpine hiking through changing ecosystems, Glacier viewing and photography, Research opportunities in unique microclimates", "best_time": "December-March and June-August (driest periods) for climbing; shorter hikes possible year-round", "entry_fee": "Foreign non-residents: $35/day park entry; climbing packages $800-$1500 depending on duration and services", "image_urls": [ "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Rwenzori_mountains.jpg/800px-Rwenzori_mountains.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4/Rwenzori_Mountains_2.jpg/800px-Rwenzori_Mountains_2.jpg" ], "recommendations": ["Queen Elizabeth National Park", "Lake George for birding", "Kilembe Mines for historical interest"] }, "sipi_falls": { "name": "Sipi Falls", "type": "Waterfall System", "description": "Sipi Falls is not a single waterfall but a spectacular trilogy of cascades tumbling down the slopes of Mount Elgon, creating one of East Africa's most breathtaking highland landscapes. The highest fall plunges an impressive 100 meters, creating a mesmerizing curtain of water that catches the sunlight to form permanent rainbows. Named after the local 'sep' plant used traditionally for medicinal purposes, Sipi offers more than just visual splendor—it's the heart of Uganda's premier Arabica coffee growing region. The surrounding landscape features dramatic cliffs, lush green valleys, and panoramic views stretching to the Karamoja plains. The cool, fresh mountain air provides welcome relief from Uganda's lowland heat, while the welcoming Sabiny communities share their rich cultural heritage. From abseiling down the falls to hiking through coffee plantations, Sipi combines adventure, natural beauty, and cultural immersion in a uniquely rewarding package. The area's microclimate creates perfect conditions for some of Africa's finest coffee, which visitors can sample straight from the source.", "history": "The falls have been sacred to the indigenous Sabiny people for generations, featuring prominently in local creation myths and traditional ceremonies. European explorers first documented the falls in the late 19th century during expeditions to Mount Elgon. The area remained relatively untouched by tourism until the 1990s when community-based initiatives began developing sustainable tourism that benefits local residents. Today, Sipi serves as a model for how tourism can preserve natural beauty while providing economic opportunities, with many local families involved in guiding, accommodation, and cultural presentations.", "location": "Kapchorwa District, Eastern Uganda, on the slopes of Mount Elgon near the Kenyan border", "activities": "Waterfall hiking circuit visiting all three falls, Coffee plantation tours from bean to cup, Abseiling (rappelling) down the main falls, Rock climbing on volcanic cliffs, Mountain biking through scenic trails, Cultural visits to Sabiny villages, Photography workshops capturing landscapes, Guided nature walks to caves and viewpoints", "best_time": "December-March and June-August (dry seasons) for optimal hiking and waterfall viewing", "entry_fee": "Community conservation fee: $10 per person; activity fees $15-$50 depending on chosen activities", "image_urls": [ "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Sipi_Falls.jpg/800px-Sipi_Falls.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Sipi_Falls_2.jpg/800px-Sipi_Falls_2.jpg" ], "recommendations": ["Mount Elgon National Park", "Nyero Rock Paintings", "Kapchorwa Town for cultural immersion"] }, "ssese_islands": { "name": "Ssese Islands", "type": "Tropical Archipelago", "description": "The Ssese Islands are Uganda's hidden tropical paradise—an archipelago of 84 lush islands scattered across the northwestern corner of Lake Victoria. This island chain offers everything you'd expect from a tropical getaway: pristine white-sand beaches, crystal-clear turquoise waters, and lush rainforests teeming with wildlife, all without leaving Uganda. Each island has its own distinct character: Buggala Island buzzes with resorts and activities, Bukasa Island maintains traditional fishing village life, and countless smaller islands offer complete solitude. The islands are a biodiversity hotspot with unique bird species, rare butterflies, and abundant monkey populations. The Bassese people have developed unique cultural practices adapted to island life, including distinctive fishing techniques and spiritual traditions. Whether you seek adventure through water sports, relaxation on secluded beaches, or cultural immersion in island communities, the Ssese Islands deliver an unforgettable experience. Spectacular sunsets over Lake Victoria provide the perfect ending to each island day.", "history": "Inhabited for centuries by the Bassese people, who developed unique fishing and farming techniques perfectly adapted to island life. During the 19th century, the islands served as a refuge for people fleeing mainland conflicts, creating a unique cultural blend. Traditional spiritual practices continue alongside modern tourism, with sacred sites still respected by local communities. In recent decades, sustainable tourism development has created economic opportunities while preserving the islands' natural beauty and cultural heritage, making them a perfect destination for travelers seeking both relaxation and authentic experiences.", "location": "Lake Victoria, Kalangala District, Southern Uganda (approximately 4-hour ferry from Entebbe)", "activities": "Beach relaxation on pristine shores, Island-hopping between different islands, Sport fishing for Nile perch and tilapia, Bird watching for island endemics, Guided forest walks spotting monkeys, Cultural visits to traditional villages, Water sports including kayaking and paddleboarding, Photography of landscapes and wildlife", "best_time": "Year-round destination; December-February offers ideal beach weather; June-September also excellent", "entry_fee": "Free access to public areas; ferry transport $10-$20 depending on class; accommodation and tours additional", "image_urls": [ "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Ssese_Islands.jpg/800px-Ssese_Islands.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Ssese_Islands_beach.jpg/800px-Ssese_Islands_beach.jpg" ], "recommendations": ["Lake Victoria mainland beaches", "Kalangala Town for supplies", "Ngamba Island Chimpanzee Sanctuary"] }, "source_of_nile": { "name": "Source of the Nile", "type": "Historical Landmark", "description": "The Source of the Nile in Jinja represents one of geography's greatest discoveries and one of Africa's most significant historical sites. This is where Lake Victoria's waters begin their epic 6,650-kilometer journey to the Mediterranean Sea, making it the starting point of the world's longest river. The actual source is marked by beautiful gardens and a monument commemorating John Hanning Speke's discovery. Standing at this point, watching the river begin its northward flow with surprising power, connects visitors to centuries of exploration and human history. Beyond its historical significance, the area has become East Africa's adventure capital, offering world-class white-water rafting through thrilling rapids. Jinja itself boasts charming colonial architecture, vibrant markets, and a laid-back atmosphere that blends historical significance with modern adventure tourism. Whether you're interested in history, adventure sports, or simply witnessing one of nature's great beginnings, the Source of the Nile delivers a profoundly memorable experience.", "history": "Identified by British explorer John Hanning Speke in 1858, solving what had been one of geography's greatest mysteries for over two thousand years. Speke's discovery settled debates about the Nile's source that had engaged everyone from ancient Egyptian pharaohs to Roman emperors. Winston Churchill visited in 1907 and famously called Uganda the 'Pearl of Africa' after seeing this region. In recent decades, Jinja has transformed from a sleepy colonial town into East Africa's adventure tourism capital while preserving its historical significance. The area continues to attract historians, adventurers, and curious travelers from around the world.", "location": "Jinja, Eastern Uganda, approximately 80 km east of Kampala on the northern shores of Lake Victoria", "activities": "Boat trips to the exact source point, World-class white-water rafting (Grade 5 rapids), Kayaking lessons and expeditions, Bungee jumping over the Nile River, Sport fishing for Nile perch, Historical tours of Jinja's colonial architecture, Sunset cruises on the Nile, Photography of the river's inception", "best_time": "Year-round destination; water levels affect rafting conditions (best June-August and December-February)", "entry_fee": "Foreign non-residents: $10 site entry; rafting $125; bungee $115; other activities $20-$80", "image_urls": [ "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/Source_of_Nile.jpg/800px-Source_of_Nile.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Nile_source_monument.jpg/800px-Nile_source_monument.jpg" ], "recommendations": ["Bujagali Falls (now submerged but area still beautiful)", "Jinja Town for colonial architecture", "Mabira Forest for nature walks"] }, "mgahinga_gorilla": { "name": "Mgahinga Gorilla National Park", "type": "Volcanic Park", "description": "Mgahinga Gorilla National Park may be Uganda's smallest national park at just 33.7 square kilometers, but it packs immense beauty and significance into its compact area. This park protects the Ugandan slopes of the Virunga Volcanoes—three extinct volcanoes (Mount Muhabura, Mount Gahinga, and Mount Sabyinyo) that form a spectacular backdrop for wildlife viewing. Beyond its famous mountain gorillas, Mgahinga is home to the rare golden monkeys, beautiful primates with striking orange-gold coats that are endemic to this volcanic region. The park serves as a vital wildlife corridor between Uganda, Rwanda, and the Democratic Republic of Congo, allowing animals to move freely across international borders. Its ecosystems range from afro-montane forest to bamboo zones and alpine meadows, each hosting unique species. The park holds deep cultural significance for the local Batwa pygmies, the original inhabitants whose knowledge of the forest is integral to conservation efforts. Mgahinga offers intimate wildlife experiences in breathtaking volcanic scenery.", "history": "Established in 1991 primarily to protect the mountain gorillas that move between Uganda, Rwanda, and DRC. The park forms part of the larger Virunga Conservation Area, a transboundary initiative that recognizes wildlife doesn't respect political borders. The Batwa people, who had lived in these forests for millennia, were relocated during park creation but now participate in conservation through cultural tourism programs. Recent years have seen successful community-based conservation that balances wildlife protection with local needs, creating a model for sustainable tourism in sensitive border areas.", "location": "Kisoro District, Southwestern Uganda, bordering Rwanda and the Democratic Republic of Congo", "activities": "Mountain gorilla tracking in volcanic forests, Golden monkey tracking (unique to this region), Volcano climbing on three different peaks, Batwa cultural trail and experiences, Bird watching for Albertine Rift endemics, Guided nature walks through diverse ecosystems, Photography of volcanic landscapes and wildlife, Border crossing hikes between countries", "best_time": "June-September and December-February (dry seasons) for optimal trekking conditions", "entry_fee": "Gorilla permit: $700 (foreign non-residents); golden monkey tracking $100; park entry $40/day", "image_urls": [ "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Mgahinga_Gorilla_NP.jpg/800px-Mgahinga_Gorilla_NP.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7d/Virunga_volcanoes.jpg/800px-Virunga_volcanoes.jpg" ], "recommendations": ["Lake Mutanda for scenic beauty", "Bwindi Forest for additional gorilla tracking", "Kisoro Town for local culture"] } } def load_image_from_url(url): """Load image from URL with error handling""" try: response = requests.get(url, timeout=10) return Image.open(io.BytesIO(response.content)) except: return None def identify_uganda_site(image): """Identify specific Uganda tourist site from image""" if image is None: return "", "Ready for analysis...", [] # Get ALL site names for matching site_names = list(UGANDA_SITES.keys()) site_display_names = [UGANDA_SITES[site]["name"] for site in site_names] # Process image and ALL site names inputs = processor(text=site_display_names, images=image, return_tensors="pt", padding=True) # Get AI predictions with torch.no_grad(): outputs = model(**inputs) probs = outputs.logits_per_image.softmax(dim=1) # Get the specific site with highest confidence top_site_index = torch.argmax(probs[0]) identified_site = site_names[top_site_index] confidence = float(probs[0][top_site_index]) * 100 site_info = UGANDA_SITES[identified_site] # Load related images related_images = [] for img_url in site_info["image_urls"]: img = load_image_from_url(img_url) if img: related_images.append(img) # Create beautiful site report with emojis and styling analysis_report = f"""
Type: {site_info['type']} • Confidence: {confidence:.1f}%
{site_info['description']}
{site_info['history']}
{site_info['location']}
{site_info['best_time']}
{site_info['entry_fee']}
Based on your interest in {site_info['name']}, you might also love:
Uganda Explorer AI • Discovering the Pearl of Africa • {datetime.now().strftime('%B %d, %Y')}
Discover the beauty of Uganda through intelligent image recognition
Upload a photo from your travels and let AI identify the location
AI-Powered Recognition