miracle01 commited on
Commit
6dfa460
1 Parent(s): b775df4

Upload 4 files

Browse files
Files changed (4) hide show
  1. Oxford-102_Flower_dataset_labels.txt +102 -0
  2. README.md +5 -6
  3. app.py +63 -0
  4. requirements.txt +0 -0
Oxford-102_Flower_dataset_labels.txt ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pink primrose
2
+ hard-leaved pocket orchid
3
+ canterbury bells
4
+ sweet pea
5
+ english marigold
6
+ tiger lily
7
+ moon orchid
8
+ bird of paradise
9
+ monkshood
10
+ globe thistle
11
+ snapdragon
12
+ colt's foot
13
+ king protea
14
+ spear thistle
15
+ yellow iris
16
+ globe-flower
17
+ purple coneflower
18
+ peruvian lily
19
+ balloon flower
20
+ giant white arum lily
21
+ fire lily
22
+ pincushion flower
23
+ fritillary
24
+ red ginger
25
+ grape hyacinth
26
+ corn poppy
27
+ prince of wales feathers
28
+ stemless gentian
29
+ artichoke
30
+ sweet william
31
+ carnation
32
+ garden phlox
33
+ love in the mist
34
+ mexican aster
35
+ alpine sea holly
36
+ ruby-lipped cattleya
37
+ cape flower
38
+ great masterwort
39
+ siam tulip
40
+ lenten rose
41
+ barbeton daisy
42
+ daffodil
43
+ sword lily
44
+ poinsettia
45
+ bolero deep blue
46
+ wallflower
47
+ marigold
48
+ buttercup
49
+ oxeye daisy
50
+ common dandelion
51
+ petunia
52
+ wild pansy
53
+ primula
54
+ sunflower
55
+ pelargonium
56
+ bishop of llandaff
57
+ gaura
58
+ geranium
59
+ orange dahlia
60
+ pink-yellow dahlia
61
+ cautleya spicata
62
+ japanese anemone
63
+ black-eyed susan
64
+ silverbush
65
+ californian poppy
66
+ osteospermum
67
+ spring crocus
68
+ bearded iris
69
+ windflower
70
+ tree poppy
71
+ gazania
72
+ azalea
73
+ water lily
74
+ rose
75
+ thorn apple
76
+ morning glory
77
+ passion flower
78
+ lotus
79
+ toad lily
80
+ anthurium
81
+ frangipani
82
+ clematis
83
+ hibiscus
84
+ columbine
85
+ desert-rose
86
+ tree mallow
87
+ magnolia
88
+ cyclamen
89
+ watercress
90
+ canna lily
91
+ hippeastrum
92
+ bee balm
93
+ ball moss
94
+ foxglove
95
+ bougainvillea
96
+ camellia
97
+ mallow
98
+ mexican petunia
99
+ bromelia
100
+ blanket flower
101
+ trumpet creeper
102
+ blackberry lily
README.md CHANGED
@@ -1,13 +1,12 @@
1
  ---
2
- title: Flower Classification Fcahpt Hnd2 Tolulope
3
- emoji:
4
- colorFrom: indigo
5
- colorTo: indigo
6
  sdk: streamlit
7
- sdk_version: 1.33.0
8
  app_file: app.py
9
  pinned: false
10
- license: mit
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Oxford 102 Flower Classification
3
+ emoji: 😻
4
+ colorFrom: red
5
+ colorTo: pink
6
  sdk: streamlit
7
+ sdk_version: 1.25.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # All imports
2
+ import streamlit as st
3
+ import tensorflow as tf
4
+ from PIL import Image
5
+ import io
6
+ import numpy as np
7
+
8
+ def load_image():
9
+ uploaded_file = st.file_uploader(label='Pick an image to test')
10
+ if uploaded_file is not None:
11
+ image_data = uploaded_file.getvalue()
12
+ st.image(image_data)
13
+ img = Image.open(io.BytesIO(image_data))
14
+ img = img.resize((224,224))
15
+ return img
16
+ else:
17
+ return None
18
+
19
+ def load_model():
20
+ model_name = 'Model/model.h5'
21
+ model = tf.keras.models.load_model(model_name)
22
+ return model
23
+
24
+ def load_labels():
25
+ with open('Oxford-102_Flower_dataset_labels.txt', 'r') as file:
26
+ data = file.read().splitlines()
27
+ return data
28
+
29
+ def predict(model, labels, img):
30
+ img_array = tf.keras.preprocessing.image.img_to_array(img)
31
+ img_array = tf.expand_dims(img_array, 0) # Create a batch
32
+
33
+ prediction = model.predict(img_array)
34
+ predicted_class = np.argmax(prediction[0], axis=-1)
35
+
36
+ flower = labels[predicted_class]
37
+ closeness = np.round(prediction[0][predicted_class] * 100, 2)
38
+
39
+ return flower, closeness
40
+
41
+ def main():
42
+ st.title('Flower Classification Using Deep Learning ')
43
+ st.markdown('### NAME:')
44
+ st.write('TOLULOPE')
45
+ st.markdown('### CLASS:')
46
+ st.write('HND2')
47
+ st.markdown('### LEVEL:')
48
+ st.write('400L')
49
+ st.markdown('---')
50
+ st.write("This is a demo of an image classification model trained on the Oxford Flower Dataset. The Oxford Flower Dataset, consisting of 102 flower categories. 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.. . To test the model, upload an image of a flower and click the 'Run on image' button.")
51
+ st.markdown('---')
52
+ model = load_model()
53
+ labels = load_labels()
54
+ image = load_image()
55
+ result = st.button('Run on image')
56
+ if result and image is not None:
57
+ st.markdown('**_Calculating results..._**')
58
+ flower, closeness = predict(model, labels, image)
59
+ st.markdown(f'<h4 style="color:blue;">Flower Type: <span style="color:black;">{flower}</span></h4>', unsafe_allow_html=True)
60
+ st.markdown(f'<h4 style="color:green;">Closeness: <span style="color:black;">{closeness}%</span></h4>', unsafe_allow_html=True)
61
+
62
+ if __name__ == '__main__':
63
+ main()
requirements.txt ADDED
Binary file (4.57 kB). View file