File size: 25,564 Bytes
6dfa460
 
 
 
 
5e45fd4
238aede
6dfa460
17387e0
5f1e7dd
9072a14
48621de
 
17387e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6cb2c78
9339755
 
6cb2c78
 
9339755
 
 
 
5e45fd4
17387e0
5e45fd4
17387e0
9ff832a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cafedef
1fdf5c6
cafedef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17387e0
 
 
 
 
 
 
 
 
1fdf5c6
 
7909ae4
b6693fd
 
 
 
7909ae4
1fdf5c6
 
9ff832a
17387e0
7909ae4
aabb8e7
7909ae4
 
 
9ff832a
8bc41a1
46efae6
17387e0
9072a14
 
17387e0
 
 
9072a14
 
 
17387e0
9072a14
17387e0
 
 
 
 
 
 
 
 
 
 
 
3a1d83f
 
17387e0
 
48621de
 
46efae6
 
17387e0
 
 
 
 
9072a14
17387e0
48621de
9ff832a
3a1d83f
 
7909ae4
f5b941d
9ff832a
bad3133
48621de
 
46efae6
9072a14
5e45fd4
48621de
 
 
 
 
 
 
9ff832a
48621de
 
9ff832a
48621de
9072a14
82bf531
9072a14
82bf531
 
9072a14
 
 
 
 
 
 
 
82bf531
 
 
6dfa460
9072a14
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
import streamlit as st
import tensorflow as tf
from PIL import Image
import io
import numpy as np
from streamlit_option_menu import option_menu
import base64

#add botanical names and usefulness


useful = "Ornamental plant with colorful foliage and unique inflorescence"

# Function to add a background image
def add_bg_from_local(image_path):
    with open(image_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read())
    st.markdown(
        f"""
        <style>
        .stApp {{
            background-image: url("data:image/{"png"};base64,{encoded_string.decode()}");
            background-size: cover;
            background-repeat: no-repeat;
            background-attachment: fixed;
        }}
        </style>
        """,
        unsafe_allow_html=True
    )

# Add background image
add_bg_from_local('flower_bg.jpg')

def load_image():
    uploaded_file = st.file_uploader(label='Pick an image to test')
    if uploaded_file is not None:
        image_data = uploaded_file.getvalue()
        st.image(image_data)
        img = Image.open(io.BytesIO(image_data))
        img = img.convert("RGB")  # Convert image to RGB mode
        img = img.resize((224, 224))
        return img
    else:
        return None

def load_model():
    model_name = 'Model/model.h5'
    model = tf.keras.models.load_model(model_name)
    return model

def load_labels():
    with open('Oxford-102_Flower_dataset_labels.txt', 'r') as file:
        data = file.read().splitlines()
    return data

# Define a dictionary mapping each flower's common name to its botanical name

def predict(model, labels, img):
    french_names = {
        "pink primrose": "Primevère rose",
        "hard-leaved pocket orchid": "Orchidée à feuilles dures",
        "canterbury bells": "Clochettes de Canterbury",
        "sweet pea": "Pois de senteur",
        "english marigold": "Souci officinal",
        "tiger lily": "Lis tigré",
        "moon orchid": "Orchidée de lune",
        "bird of paradise": "Oiseau de paradis",
        "monkshood": "Aconit",
        "globe thistle": "Chardon boule",
        "snapdragon": "Muflier",
        "colt's foot": "Tussilage",
        "king protea": "Protéa roi",
        "spear thistle": "Chardon lancéolé",
        "yellow iris": "Iris jaune",
        "globe-flower": "Trolle",
        "purple coneflower": "Échinacée pourpre",
        "peruvian lily": "Lys des Incas",
        "balloon flower": "Platycodon",
        "giant white arum lily": "Arum géant blanc",
        "fire lily": "Lis de feu",
        "pincushion flower": "Scabieuse",
        "fritillary": "Fritillaire",
        "red ginger": "Gingembre rouge",
        "grape hyacinth": "Muscari",
        "corn poppy": "Coquelicot",
        "prince of wales feathers": "Amarante queue-de-renard",
        "stemless gentian": "Gentiane acaule",
        "artichoke": "Artichaut",
        "sweet william": "Œillet de poète",
        "carnation": "Œillet",
        "garden phlox": "Phlox de jardin",
        "love in the mist": "Nigelle de Damas",
        "mexican aster": "Cosmos",
        "alpine sea holly": "Chardon bleu des Alpes",
        "ruby-lipped cattleya": "Cattleya à lèvres rubis",
        "cape flower": "Fleur du Cap",
        "great masterwort": "Grande astrance",
        "siam tulip": "Tulipe de Siam",
        "lenten rose": "Rose de carême",
        "barbeton daisy": "Gerbera",
        "daffodil": "Jonquille",
        "sword lily": "Glaïeul",
        "poinsettia": "Poinsettia",
        "bolero deep blue": "Lisianthus bleu profond",
        "wallflower": "Giroflée",
        "marigold": "Tagète",
        "buttercup": "Renoncule",
        "oxeye daisy": "Marguerite",
        "common dandelion": "Pissenlit",
        "petunia": "Pétunia",
        "wild pansy": "Pensée sauvage",
        "primula": "Primevère",
        "sunflower": "Tournesol",
        "pelargonium": "Pélargonium",
        "bishop of llandaff": "Dahlia Bishop of Llandaff",
        "gaura": "Gaura",
        "geranium": "Géranium",
        "orange dahlia": "Dahlia orange",
        "pink-yellow dahlia": "Dahlia rose-jaune",
        "cautleya spicata": "Cautleya spicata",
        "japanese anemone": "Anémone du Japon",
        "black-eyed susan": "Rudbeckie",
        "silverbush": "Convolvulus argenté",
        "californian poppy": "Pavot de Californie",
        "osteospermum": "Ostéospermum",
        "spring crocus": "Crocus de printemps",
        "bearded iris": "Iris barbu",
        "windflower": "Anémone sylvie",
        "tree poppy": "Pavot en arbre",
        "gazania": "Gazanie",
        "azalea": "Azalée",
        "water lily": "Nénuphar",
        "rose": "Rose",
        "thorn apple": "Datura",
        "morning glory": "Liseron",
        "passion flower": "Passiflore",
        "lotus": "Lotus",
        "toad lily": "Tricyrtis",
        "anthurium": "Anthurium",
        "frangipani": "Frangipanier",
        "clematis": "Clématite",
        "hibiscus": "Hibiscus",
        "columbine": "Ancolie",
        "desert-rose": "Rose du désert",
        "tree mallow": "Lavatère",
        "magnolia": "Magnolia",
        "cyclamen": "Cyclamen",
        "watercress": "Cresson",
        "canna lily": "Canna",
        "hippeastrum": "Hippeastrum",
        "bee balm": "Monarde",
        "ball moss": "Tillandsia",
        "foxglove": "Digitale",
        "bougainvillea": "Bougainvillée",
        "camellia": "Camélia",
        "mallow": "Mauve",
        "mexican petunia": "Pétunia mexicain",
        "bromelia": "Bromélia",
        "blanket flower": "Gaillarde",
        "trumpet creeper": "Bignone",
        "blackberry lily": "Belamcanda chinensis"
    }

    botanical_names = {
        "pink primrose": "Primula polyantha",
        "hard-leaved pocket orchid": "Calypso bulbosa",
        "canterbury bells": "Campanula medium",
        "sweet pea": "Lathyrus odoratus",
        "english marigold": "Calendula officinalis",
        "tiger lily": "Lilium lancifolium",
        "moon orchid": "Phalaenopsis amabilis",
        "bird of paradise": "Strelitzia reginae",
        "monkshood": "Aconitum napellus",
        "globe thistle": "Echinops ritro",
        "snapdragon": "Antirrhinum majus",
        "colt's foot": "Tussilago farfara",
        "king protea": "Protea cynaroides",
        "spear thistle": "Cirsium vulgare",
        "yellow iris": "Iris pseudacorus",
        "globe-flower": "Trollius europaeus",
        "purple coneflower": "Echinacea purpurea",
        "peruvian lily": "Alstroemeria aurea",
        "balloon flower": "Platycodon grandiflorus",
        "giant white arum lily": "Zantedeschia aethiopica",
        "fire lily": "Lilium bulbiferum",
        "pincushion flower": "Scabiosa atropurpurea",
        "fritillary": "Fritillaria imperialis",
        "red ginger": "Alpinia purpurata",
        "grape hyacinth": "Muscari",
        "corn poppy": "Papaver rhoeas",
        "prince of wales feathers": "Amaranthus caudatus",
        "stemless gentian": "Gentiana acaulis",
        "artichoke": "Cynara cardunculus",
        "sweet william": "Dianthus barbatus",
        "carnation": "Dianthus caryophyllus",
        "garden phlox": "Phlox paniculata",
        "love in the mist": "Nigella damascena",
        "mexican aster": "Cosmos bipinnatus",
        "alpine sea holly": "Eryngium alpinum",
        "ruby-lipped cattleya": "Cattleya labiata",
        "cape flower": "Mesembryanthemum crystallinum",
        "great masterwort": "Astrantia major",
        "siam tulip": "Curcuma alismatifolia",
        "lenten rose": "Helleborus orientalis",
        "barbeton daisy": "Gerbera jamesonii",
        "daffodil": "Narcissus",
        "sword lily": "Gladiolus",
        "poinsettia": "Euphorbia pulcherrima",
        "bolero deep blue": "Eustoma grandiflorum",
        "wallflower": "Erysimum",
        "marigold": "Tagetes",
        "buttercup": "Ranunculus",
        "oxeye daisy": "Leucanthemum vulgare",
        "common dandelion": "Taraxacum officinale",
        "petunia": "Petunia",
        "wild pansy": "Viola tricolor",
        "primula": "Primula",
        "sunflower": "Helianthus",
        "pelargonium": "Pelargonium",
        "bishop of llandaff": "Dahlia",
        "gaura": "Gaura",
        "geranium": "Geranium",
        "orange dahlia": "Dahlia",
        "pink-yellow dahlia": "Dahlia",
        "cautleya spicata": "Cautleya spicata",
        "japanese anemone": "Anemone hupehensis",
        "black-eyed susan": "Rudbeckia hirta",
        "silverbush": "Convolvulus cneorum",
        "californian poppy": "Eschscholzia californica",
        "osteospermum": "Osteospermum",
        "spring crocus": "Crocus vernus",
        "bearded iris": "Iris germanica",
        "windflower": "Anemone nemorosa",
        "tree poppy": "Dendromecon rigida",
        "gazania": "Gazania",
        "azalea": "Rhododendron",
        "water lily": "Nymphaea",
        "rose": "Rosa",
        "thorn apple": "Datura",
        "morning glory": "Ipomoea",
        "passion flower": "Passiflora",
        "lotus": "Nelumbo nucifera",
        "toad lily": "Tricyrtis hirta",
        "anthurium": "Anthurium",
        "frangipani": "Plumeria",
        "clematis": "Clematis",
        "hibiscus": "Hibiscus",
        "columbine": "Aquilegia",
        "desert-rose": "Adenium obesum",
        "tree mallow": "Malva arborea",
        "magnolia": "Magnolia",
        "cyclamen": "Cyclamen",
        "watercress": "Nasturtium officinale",
        "canna lily": "Canna",
        "hippeastrum": "Hippeastrum",
        "bee balm": "Monarda",
        "ball moss": "Tillandsia recurvata",
        "foxglove": "Digitalis purpurea",
        "bougainvillea": "Bougainvillea",
        "camellia": "Camellia",
        "mallow": "Malva",
        "mexican petunia": "Ruellia brittoniana",
        "bromelia": "Bromelia",
        "blanket flower": "Gaillardia",
        "trumpet creeper": "Campsis radicans",
        "blackberry lily": "Belamcanda chinensis",
    # Add the botanical names for the rest of the flowers
    # You can use online resources to find the botanical names for each flower
    }

    # Define a dictionary mapping each flower's common name to its usefulness or importance
    usefulness = {
        "pink primrose": "Used in herbal medicine for its anti-inflammatory properties",
        "hard-leaved pocket orchid": "Rare and endangered species, protected by conservation efforts",
        "canterbury bells": "Ornamental garden plant, attracts bees and butterflies",
        "sweet pea": "Popular ornamental plant known for its fragrance and colorful flowers",
        "english marigold": "Used in traditional medicine and culinary applications",
        "tiger lily": "Ornamental garden plant, symbolizing wealth and prosperity in some cultures",
        "moon orchid": "Highly valued ornamental plant, often used in floral arrangements",
        "bird of paradise": "Distinctive and exotic ornamental plant, symbolizing freedom and beauty",
        "monkshood": "Highly toxic plant used in traditional medicine with extreme caution",
        "globe thistle": "Ornamental garden plant, attracts pollinators such as bees and butterflies",
        "snapdragon": "Popular garden plant with colorful flowers, often used in floral arrangements",
        "colt's foot": "Used in traditional medicine for its expectorant properties",
        "king protea": "National flower of South Africa, symbolizing diversity and courage",
        "spear thistle": "Prickly plant with ornamental value and historical significance",
        "yellow iris": "Ornamental water plant, attracts pollinators such as bees and butterflies",
        "globe-flower": "Ornamental garden plant, symbolizing happiness and good fortune",
        "purple coneflower": "Medicinal plant used to boost the immune system and treat colds",
        "peruvian lily": "Ornamental garden plant with colorful flowers, often used in floral arrangements",
        "balloon flower": "Ornamental garden plant, symbolizing unchanging love and devotion",
        "giant white arum lily": "Ornamental garden plant, often used in bridal bouquets",
        "fire lily": "Ornamental garden plant, symbolizing passion and desire",
        "pincushion flower": "Ornamental garden plant, attracts pollinators such as bees and butterflies",
        "fritillary": "Ornamental garden plant, known for its unique bell-shaped flowers",
        "red ginger": "Ornamental garden plant, prized for its vibrant red inflorescence",
        "grape hyacinth": "Ornamental garden plant, symbolizing rebirth and renewal",
        "corn poppy": "Symbolic flower of remembrance, often found in fields and meadows",
        "prince of wales feathers": "Ornamental garden plant, known for its striking red inflorescence",
        "stemless gentian": "Medicinal plant used to treat digestive disorders",
        "artichoke": "Edible plant cultivated for its edible flower buds",
        "sweet william": "Ornamental garden plant with fragrant flowers, symbolizing gallantry",
        "carnation": "Popular cut flower with various symbolic meanings, often used in bouquets",
        "garden phlox": "Ornamental garden plant, attracts pollinators such as bees and butterflies",
        "love in the mist": "Ornamental garden plant with delicate flowers, symbolizing affection",
        "mexican aster": "Ornamental garden plant with colorful flowers, attracts pollinators",
        "alpine sea holly": "Ornamental garden plant, known for its distinctive blue flowers",
        "ruby-lipped cattleya": "Highly prized orchid species, often used in corsages",
        "cape flower": "Ornamental garden plant, symbolizing resilience and endurance",
        "great masterwort": "Medicinal plant used to treat various ailments",
        "siam tulip": "Ornamental garden plant, symbolizing prosperity and abundance",
        "lenten rose": "Ornamental garden plant, prized for its early blooming flowers",
        "barbeton daisy": "Ornamental garden plant with colorful flowers, attracts pollinators",
        "daffodil": "Symbolic flower of renewal and hope, often associated with spring",
        "sword lily": "Ornamental garden plant with striking sword-shaped leaves",
        "poinsettia": "Popular ornamental plant, often used as a decorative plant during the holidays",
        "bolero deep blue": "Ornamental garden plant with deep blue flowers, symbolizing tranquility",
        "wallflower": "Ornamental garden plant, known for its fragrant flowers",
        "marigold": "Used in traditional medicine and culinary applications, often planted to repel pests",
        "buttercup": "Ornamental garden plant with bright yellow flowers",
        "oxeye daisy": "Ornamental garden plant with daisy-like flowers, symbolizing innocence",
        "common dandelion": "Edible plant with various medicinal properties",
        "petunia": "Popular garden plant with colorful flowers, symbolizing playfulness",
        "wild pansy": "Medicinal plant used to treat respiratory ailments",
        "primula": "Ornamental garden plant, known for its early spring blooms",
        "sunflower": "Symbolic flower of happiness and vitality, cultivated for its edible seeds",
        "pelargonium": "Ornamental garden plant, known for its fragrant leaves and flowers",
        "bishop of llandaff": "Ornamental garden plant with deep red flowers",
        "gaura": "Ornamental garden plant with delicate flowers, attracts pollinators",
        "geranium": "Popular garden plant with colorful flowers and fragrant leaves",
        "orange dahlia": "Ornamental garden plant with vibrant orange flowers",
        "pink-yellow dahlia": "Ornamental garden plant with pink and yellow bicolor flowers",
        "cautleya spicata": "Ornamental garden plant, known for its showy flowers",
        "japanese anemone": "Ornamental garden plant with delicate flowers, symbolizing protection",
        "black-eyed susan": "Ornamental garden plant with yellow flowers and dark centers",
        "silverbush": "Ornamental garden plant with silvery foliage",
        "californian poppy": "Ornamental garden plant with bright orange flowers",
        "osteospermum": "Ornamental garden plant with colorful daisy-like flowers",
        "spring crocus": "Ornamental garden plant with early spring blooms",
        "bearded iris": "Ornamental garden plant with showy flowers, often used in landscaping",
        "windflower": "Ornamental garden plant with delicate flowers, symbolizing anticipation",
        "tree poppy": "Ornamental garden plant with bright yellow flowers",
        "gazania": "Ornamental garden plant with colorful flowers, drought tolerant",
        "azalea": "Ornamental garden plant with vibrant flowers, symbolizing passion",
        "water lily": "Ornamental water plant, symbolizing purity and enlightenment",
        "rose": "Symbolic flower of love and romance, cultivated for its beauty and fragrance",
        "thorn apple": "Historically used in herbal medicine, highly toxic if ingested",
        "morning glory": "Ornamental garden plant with colorful flowers, symbolizing affection",
        "passion flower": "Symbolic flower of Christ's passion, often used in religious art",
        "lotus": "Symbolic flower of purity and enlightenment in various cultures",
        "toad lily": "Ornamental garden plant with unique spotted flowers",
        "anthurium": "Ornamental plant with distinctive heart-shaped flowers, symbolizing hospitality and abundance",
        "frangipani": "Ornamental garden plant with fragrant flowers, often used in tropical landscaping",
        "clematis": "Ornamental garden plant with colorful flowers, symbolizing mental beauty",
        "hibiscus": "Edible plant with medicinal properties, popular ornamental garden plant",
        "columbine": "Ornamental garden plant with unique spurred flowers, symbolizing love and fidelity",
        "desert-rose": "Ornamental garden plant with succulent foliage and colorful flowers",
        "tree mallow": "Ornamental garden plant with large colorful flowers",
        "magnolia": "Ornamental garden plant with large fragrant flowers, symbolizing nobility and perseverance",
        "cyclamen": "Ornamental garden plant with unique twisted flowers, symbolizing resignation and farewell",
        "watercress": "Edible aquatic plant, rich in vitamins and minerals",
        "canna lily": "Ornamental garden plant with colorful flowers and edible rhizomes",
        "hippeastrum": "Ornamental garden plant with large showy flowers, symbolizing pride and beauty",
        "bee balm": "Medicinal plant with aromatic leaves and flowers, attracts pollinators",
        "ball moss": "Epiphytic plant that grows on trees, contributes to ecosystem biodiversity",
        "foxglove": "Medicinal plant used to treat heart conditions, highly toxic if ingested",
        "bougainvillea": "Ornamental vine with vibrant flowers, drought tolerant",
        "camellia": "Ornamental garden plant with evergreen leaves and showy flowers",
        "mallow": "Edible and medicinal plant with soothing properties",
        "mexican petunia": "Ornamental garden plant with colorful flowers, attracts butterflies",
        "bromelia": "Ornamental plant with colorful foliage and unique inflorescence",
        "blanket flower": "Ornamental garden plant with daisy-like flowers, drought tolerant",
        "trumpet creeper": "Ornamental vine with trumpet-shaped flowers, attracts hummingbirds",
        "blackberry lily": "Ornamental garden plant with iris-like flowers and blackberry-like fruits"
        # Add the usefulness or importance for the rest of the flowers
    }
    
    img_array = tf.keras.preprocessing.image.img_to_array(img)
    img_array = tf.expand_dims(img_array, 0)  # Create a batch

    prediction = model.predict(img_array)
    predicted_class = np.argmax(prediction[0], axis=-1)

    flower = labels[predicted_class]
    closeness = np.round(prediction[0][predicted_class] * 100, 2)

    get_flower = flower

    # Debug: Print the predicted flower name
    #print(f"Predicted Flower: {flower}")
    #print(f"Predicted Flower: {get_flower}")
    
    print(botanical_names[get_flower])

    botanical_name = botanical_names.get(get_flower, "Unknown")
    flower_usefulness = usefulness.get(get_flower, "Unknown")
    french_name = french_names.get(get_flower, "Unknown")
    
    # Debug: Print the botanical name and usefulness
    
    print(f"Botanical Name: {botanical_name}")
    print(f"Usefulness: {flower_usefulness}")

    return flower, closeness, botanical_name, flower_usefulness, french_name


def main():
    with st.sidebar:
        selected = option_menu(
            menu_title="Main Menu",
            options=["Home", "About", "Local Classifier", "Extensive Classifier", "Project Details"],
            icons=["house", "info-circle", "camera", "search", "clipboard-list"],
            menu_icon="cast",
            default_index=0,
        )

    if selected == "Home":
        st.markdown("""
            <h1 style="color:white">Home</h1>
            <p style="color:white">Click the link below to visit the main application page:</p>
            <a style="color:white" href="https://tolu-flower-classifier.vercel.app/" target="_blank">Go to Main Application</a>
        """, unsafe_allow_html=True)

    elif selected == "About":
        st.markdown('<h1 style="color:white">About</h1>')
        st.markdown("""
            <h4 style="color:white"> NAME:</br> <b> TOLULOPE</b></h4>
            <h4 style="color:white"> CLASS:</br> <b>HND2</b></h4>
            <h4 style="color:white"> LEVEL:</br> <b>400L</b></h4>
            <h4 style="color:white"> SCHOOL:</br> <b>FEDERAL COLLEGE OF ANIMAL HEALTH AND PRODUCTION TECHNOLOGY.</b></h4>
            <h4 style="color:white"> SUPERVISOR:</br> <b></b></h4>
        """, unsafe_allow_html=True)

    elif selected == "Extensive Classifier":
        st.markdown('<h1 style="color:white;">Extensive Classifier</h1>', unsafe_allow_html=True)
        st.markdown('<h4 style="color:white;">This is a demo of an image classification model trained on the Oxford Flower Dataset.</h4>', unsafe_allow_html=True)
        st.markdown('<h4 style="color:white;">To test the model, upload an image of a flower and click the Run on image button.</h4>', unsafe_allow_html=True)
        
        model = load_model()
        labels = load_labels()
        image = load_image()
        result = st.button('Run on image')
        
        if result and image is not None:
            st.markdown('**_Calculating extensive results..._**')
            flower, closeness, botanical_name, flower_usefulness, french_name = predict(model, labels, image)
            st.markdown(f'<h5 style="color:white;">Flower Type: <span style="color:orange;">{flower}</span></h4>', unsafe_allow_html=True)
            st.markdown(f'<h5 style="color:white;">Closeness: <span style="color:orange;">{closeness}%</span></h4>', unsafe_allow_html=True)
            st.markdown(f'<h5 style="color:white;">Botanical Name: <span style="color:orange;">{botanical_name}</span></h4>', unsafe_allow_html=True)
            st.markdown(f'<h5 style="color:white;">Usefulness/Description: <span style="color:orange;">{flower_usefulness}</span></h4>', unsafe_allow_html=True)
            st.markdown(f'<h5 style="color:white;">French Name: <span style="color:orange;">{french_name}</span></h4>', unsafe_allow_html=True)

    elif selected == "Local Classifier":
        st.markdown('<h1 style="color:white;">Local Classifier</h1>', unsafe_allow_html=True)
        st.markdown('<h4 style="color:white;">This section contains a local classifier details and options.</h4>', unsafe_allow_html=True)
        # Add your extensive classifier code here

        model = load_model()
        labels = load_labels()
        image = load_image()
        result = st.button('Run on image')
        
        if result and image is not None:
            st.markdown('**_Calculating local results..._**')
            flower, closeness, botanical_name, flower_usefulness, french_name = predict(model, labels, image)
            st.markdown(f'<h5 style="color:white;">Flower Type: <span style="color:orange;">{flower}</span></h4>', unsafe_allow_html=True)
            st.markdown(f'<h5 style="color:white;">Closeness: <span style="color:orange;">{closeness}%</span></h4>', unsafe_allow_html=True)
            st.markdown(f'<h5 style="color:white;">French Name: <span style="color:orange;">{french_name}</span></h4>', unsafe_allow_html=True)

    elif selected == "Project Details":
        st.markdown('<h1 style="color:white;">Project Details</h1>', unsafe_allow_html=True)
        st.markdown("""
            <p style="color:white;">
            <h4 style="color:white">
            This project is about classifying flowers using deep learning. 
            The Oxford Flower Dataset, consisting of 102 flower categories, 
            is used for training the model. The images have large scale, 
            pose, and light variations. In addition, there are categories 
            that have large variations within the category and several very 
            similar categories. The dataset is visualized using isomap with 
            shape and colour features. Link to the dataset is available 
            @ https://www.kaggle.com/datasets/yousefmohamed20/oxford-102-flower-dataset.
            </h4>
            </p>
        """, unsafe_allow_html=True)

if __name__ == '__main__':
    main()