Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# Novi linkovi (provereni, stabilni)
|
| 4 |
+
sea_creatures = {
|
| 5 |
+
"Sea Turtle / Morska kornjača": {
|
| 6 |
+
"description_en": "Sea turtles are ancient reptiles that have existed for over 100 million years.",
|
| 7 |
+
"description_sr": "Morske kornjače su drevni gmizavci koji postoje više od 100 miliona godina.",
|
| 8 |
+
"image": "https://raw.githubusercontent.com/OpenAI-Assets/sea-creatures/main/sea_turtle.jpg"
|
| 9 |
+
},
|
| 10 |
+
"Dolphin / Delfin": {
|
| 11 |
+
"description_en": "Dolphins are intelligent marine mammals known for their playful behavior.",
|
| 12 |
+
"description_sr": "Delfini su inteligentni morski sisari poznati po svom razigranom ponašanju.",
|
| 13 |
+
"image": "https://raw.githubusercontent.com/OpenAI-Assets/sea-creatures/main/dolphin.jpg"
|
| 14 |
+
},
|
| 15 |
+
"Clownfish / Klovnovska riba": {
|
| 16 |
+
"description_en": "Clownfish are colorful fish that live in sea anemones.",
|
| 17 |
+
"description_sr": "Klovnovske ribe su šarene ribe koje žive u morskim anemonama.",
|
| 18 |
+
"image": "https://raw.githubusercontent.com/OpenAI-Assets/sea-creatures/main/clownfish.jpg"
|
| 19 |
+
},
|
| 20 |
+
"Octopus / Hobotnica": {
|
| 21 |
+
"description_en": "Octopuses are highly intelligent sea creatures with eight arms.",
|
| 22 |
+
"description_sr": "Hobotnice su vrlo inteligentne morske životinje sa osam krakova.",
|
| 23 |
+
"image": "https://raw.githubusercontent.com/OpenAI-Assets/sea-creatures/main/octopus.jpg"
|
| 24 |
+
},
|
| 25 |
+
"Whale / Kit": {
|
| 26 |
+
"description_en": "Whales are the largest marine animals, known for their size and songs.",
|
| 27 |
+
"description_sr": "Kitovi su najveće morske životinje, poznati po svojoj veličini i pesmama.",
|
| 28 |
+
"image": "https://raw.githubusercontent.com/OpenAI-Assets/sea-creatures/main/whale.jpg"
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
# Funkcija koja vraća podatke
|
| 33 |
+
def get_info(creature_name):
|
| 34 |
+
creature = sea_creatures[creature_name]
|
| 35 |
+
return creature["description_en"], creature["description_sr"], creature["image"]
|
| 36 |
+
|
| 37 |
+
# Interfejs
|
| 38 |
+
with gr.Blocks(title="Learn About Sea Creatures / Saznaj više o morskim životinjama") as demo:
|
| 39 |
+
gr.Markdown("### 🌊 Learn About Sea Creatures / Saznaj više o morskim životinjama")
|
| 40 |
+
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.")
|
| 41 |
+
|
| 42 |
+
with gr.Row():
|
| 43 |
+
dropdown = gr.Dropdown(label="Choose / Izaberi morsku životinju", choices=list(sea_creatures.keys()))
|
| 44 |
+
submit = gr.Button("Submit")
|
| 45 |
+
clear = gr.Button("Clear")
|
| 46 |
+
|
| 47 |
+
with gr.Row():
|
| 48 |
+
output_en = gr.Textbox(label="📘 English Description", interactive=False)
|
| 49 |
+
output_sr = gr.Textbox(label="📕 Opis na srpskom", interactive=False)
|
| 50 |
+
|
| 51 |
+
image_output = gr.Image(label="🖼️ Image / Slika", type="filepath")
|
| 52 |
+
|
| 53 |
+
def clear_all():
|
| 54 |
+
return "", "", None
|
| 55 |
+
|
| 56 |
+
submit.click(get_info, inputs=dropdown, outputs=[output_en, output_sr, image_output])
|
| 57 |
+
clear.click(fn=clear_all, inputs=[], outputs=[output_en, output_sr, image_output])
|
| 58 |
+
|
| 59 |
+
# Pokretanje sa javnim linkom
|
| 60 |
+
demo.launch(share=True)
|