| import gradio as gr |
|
|
| |
| sea_creatures = { |
| "Sea Turtle / Morska kornjača": { |
| "description_en": "Sea turtles are ancient reptiles that have existed for over 100 million years.", |
| "description_sr": "Morske kornjače su drevni gmizavci koji postoje više od 100 miliona godina.", |
| "image": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Turtle_diving2.jpg/640px-Turtle_diving2.jpg" |
| }, |
| "Dolphin / Delfin": { |
| "description_en": "Dolphins are intelligent marine mammals known for their playful behavior.", |
| "description_sr": "Delfini su inteligentni morski sisari poznati po svom razigranom ponašanju.", |
| "image": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/49/Common_dolphin.jpg/640px-Common_dolphin.jpg" |
| }, |
| "Clownfish / Klovnovska riba": { |
| "description_en": "Clownfish are colorful fish that live in sea anemones.", |
| "description_sr": "Klovnovske ribe su šarene ribe koje žive u morskim anemonama.", |
| "image": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/Amphiprion_ocellaris_%28clown_anemonefish%29.jpg/640px-Amphiprion_ocellaris_%28clown_anemonefish%29.jpg" |
| }, |
| "Octopus / Hobotnica": { |
| "description_en": "Octopuses are highly intelligent sea creatures with eight arms.", |
| "description_sr": "Hobotnice su vrlo inteligentne morske životinje sa osam krakova.", |
| "image": "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Common_Octopus.jpg/640px-Common_Octopus.jpg" |
| }, |
| "Whale / Kit": { |
| "description_en": "Whales are the largest marine animals, known for their size and songs.", |
| "description_sr": "Kitovi su najveće morske životinje, poznati po svojoj veličini i pesmama.", |
| "image": "https://upload.wikimedia.org/wikipedia/commons/thumb/5/56/Humpback_Whale_underwater_shot.jpg/640px-Humpback_Whale_underwater_shot.jpg" |
| } |
| } |
|
|
| |
| def get_info(creature_name): |
| creature = sea_creatures[creature_name] |
| return creature["description_en"], creature["description_sr"], creature["image"] |
|
|
| |
| with gr.Blocks(title="Learn About Sea Creatures / Saznaj više o morskim životinjama") as demo: |
| gr.Markdown("### 🌊 Learn About Sea Creatures / Saznaj više o morskim životinjama") |
| gr.Markdown("Select a sea creature to learn more about it in English and Serbian. / Izaberi životinju da saznaš više na engleskom i srpskom jeziku.") |
|
|
| with gr.Row(): |
| creature_dropdown = gr.Dropdown(label="Choose / Izaberi morsku životinju", choices=list(sea_creatures.keys())) |
| submit_btn = gr.Button("Submit") |
| clear_btn = gr.Button("Clear") |
|
|
| with gr.Row(): |
| output_en = gr.Textbox(label="📘 English Description", interactive=False) |
| output_sr = gr.Textbox(label="📕 Opis na srpskom", interactive=False) |
|
|
| output_image = gr.Image(label="🖼️ Image / Slika", type="filepath") |
|
|
| def clear(): |
| return "", "", None |
|
|
| submit_btn.click(get_info, inputs=creature_dropdown, outputs=[output_en, output_sr, output_image]) |
| clear_btn.click(fn=clear, inputs=[], outputs=[output_en, output_sr, output_image]) |
|
|
| |
| demo.launch(share=True) |
|
|