| |
| import gradio as gr |
| import random |
|
|
| |
| |
| |
|
|
| |
| content = { |
| "en": { |
| "title": "🌊 Team Marine Explorer 🐠", |
| "description": "Collaborative project about ocean life conservation", |
| |
| }, |
| "hr": { |
| "title": "🌊 Timski Morski Istraživač 🐠", |
| "description": "Zajednički projekt o očuvanju morskog života", |
| |
| } |
| } |
|
|
| |
| creatures = { |
| "Clownfish": { |
| "image": "https://upload.wikimedia.org/wikipedia/commons/f/f6/Clown_fish_in_the_Andaman_Coral_Reef.jpg", |
| "size": {"en": "10-18cm", "hr": "10-18cm"}, |
| "habitat": {"en": "Coral reefs", "hr": "Koraljni grebeni"}, |
| "diet": {"en": "Omnivore", "hr": "Svejed"}, |
| "status": {"en": "Least Concern", "hr": "Najmanje zabrinjavajuće"}, |
| "fact": { |
| "en": "All clownfish are born male, some turn female", |
| "hr": "Svi clownfish se rode muški, neki postanu ženski" |
| } |
| }, |
| "Sea Turtle": { |
| "image": "https://upload.wikimedia.org/wikipedia/commons/0/00/Chelonia_mydas_is_going_for_the_air_edit.jpg", |
| "size": {"en": "0.6-2m", "hr": "0.6-2m"}, |
| "habitat": {"en": "Tropical oceans", "hr": "Tropski oceani"}, |
| "diet": {"en": "Omnivore", "hr": "Svejed"}, |
| "status": {"en": "Vulnerable", "hr": "Ranjivo"}, |
| "fact": { |
| "en": "Can live up to 100 years", |
| "hr": "Mogu živjeti do 100 godina" |
| } |
| }, |
| "Blue Whale": { |
| "image": "https://upload.wikimedia.org/wikipedia/commons/1/1c/Anim1754_-_Flickr_-_NOAA_Photo_Library.jpg", |
| "size": {"en": "25-30m", "hr": "25-30m"}, |
| "habitat": {"en": "All oceans", "hr": "Svi oceani"}, |
| "diet": {"en": "Carnivore (krill)", "hr": "Mesožder (krill)"}, |
| "status": {"en": "Endangered", "hr": "Ugroženo"}, |
| "fact": { |
| "en": "Heart is size of a small car", |
| "hr": "Srce veličine malog automobila" |
| } |
| }, |
| "Dolphin": { |
| "image": "https://upload.wikimedia.org/wikipedia/commons/1/10/Tursiops_truncatus_01.jpg", |
| "size": {"en": "2-4m", "hr": "2-4m"}, |
| "habitat": {"en": "All oceans", "hr": "Svi oceani"}, |
| "diet": {"en": "Carnivore", "hr": "Mesožder"}, |
| "status": {"en": "Least Concern", "hr": "Najmanje zabrinjavajuće"}, |
| "fact": { |
| "en": "Uses echolocation to find prey", |
| "hr": "Koristi eholokaciju za pronalaženje plijena" |
| } |
| }, |
| "Great White Shark": { |
| "image": "https://upload.wikimedia.org/wikipedia/commons/5/56/White_shark.jpg", |
| "size": {"en": "4-6m", "hr": "4-6m"}, |
| "habitat": {"en": "Coastal waters", "hr": "Obalne vode"}, |
| "diet": {"en": "Carnivore", "hr": "Mesožder"}, |
| "status": {"en": "Vulnerable", "hr": "Ranjivo"}, |
| "fact": { |
| "en": "Can detect one drop of blood in 100L of water", |
| "hr": "Može detektirati kap krvi u 100L vode" |
| } |
| }, |
| |
| } |
|
|
| |
| tips = { |
| "en": [ |
| |
| ], |
| "hr": [ |
| |
| ] |
| } |
|
|
| |
| projects = { |
| "en": [ |
| |
| ], |
| "hr": [ |
| |
| ] |
| } |
|
|
| |
| |
| |
|
|
| def get_creature_info(creature_name, lang): |
| creature = creatures[creature_name] |
| return ( |
| creature["image"], |
| f"{content[lang]['size_label']} {creature['size'][lang]}", |
| f"{content[lang]['habitat_label']} {creature['habitat'][lang]}", |
| f"{content[lang]['diet_label']} {creature['diet'][lang]}", |
| f"{content[lang]['status_label']} {creature['status'][lang]}", |
| f"{content[lang]['fact_label']} {creature['fact'][lang]}" |
| ) |
|
|
| def check_quiz(answer1, answer2, answer3, lang): |
| |
|
|
| def get_random_tip(lang): |
| |
|
|
| def get_random_project(lang): |
| |
|
|
| def add_note(name, note, existing_notes): |
| |
|
|
| |
| |
| |
|
|
| with gr.Blocks(title="Team Marine Explorer", theme=gr.themes.Soft()) as demo: |
| |
| |
| |
| |
|
|
| demo.launch() |