| 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://raw.githubusercontent.com/OpenAI-Assets/sea-creatures/main/sea_turtle.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://raw.githubusercontent.com/OpenAI-Assets/sea-creatures/main/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://raw.githubusercontent.com/OpenAI-Assets/sea-creatures/main/clownfish.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://raw.githubusercontent.com/OpenAI-Assets/sea-creatures/main/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://raw.githubusercontent.com/OpenAI-Assets/sea-creatures/main/whale.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(): |
| dropdown = gr.Dropdown(label="Choose / Izaberi morsku životinju", choices=list(sea_creatures.keys())) |
| submit = gr.Button("Submit") |
| clear = 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) |
|
|
| image_output = gr.Image(label="🖼️ Image / Slika", type="filepath") |
|
|
| def clear_all(): |
| return "", "", None |
|
|
| submit.click(get_info, inputs=dropdown, outputs=[output_en, output_sr, image_output]) |
| clear.click(fn=clear_all, inputs=[], outputs=[output_en, output_sr, image_output]) |
|
|
| |
| demo.launch(share=True) |
|
|