-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
58 lines (54 loc) · 1.16 KB
/
app.py
File metadata and controls
58 lines (54 loc) · 1.16 KB
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
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.models import load_model
import streamlit as st
import numpy as np
st.header('Image Classification Model')
model = load_model(r'C:\Users\user\Downloads\image classification\Image_classify.keras')
data_cat = ['apple',
'banana',
'beetroot',
'bell pepper',
'cabbage',
'capsicum',
'carrot',
'cauliflower',
'chilli pepper',
'corn',
'cucumber',
'eggplant',
'garlic',
'ginger',
'grapes',
'jalepeno',
'kiwi',
'lemon',
'lettuce',
'mango',
'onion',
'orange',
'paprika',
'pear',
'peas',
'pineapple',
'pomegranate',
'potato',
'raddish',
'soy beans',
'spinach',
'sweetcorn',
'sweetpotato',
'tomato',
'turnip',
'watermelon']
img_height = 180
img_width = 180
image =st.text_input('Enter Image name','Apple.jpg')
image_load = tf.keras.utils.load_img(image, target_size=(img_height,img_width))
img_arr = tf.keras.utils.array_to_img(image_load)
img_bat=tf.expand_dims(img_arr,0)
predict = model.predict(img_bat)
score = tf.nn.softmax(predict)
st.image(image, width=200)
st.write('Veg/Fruit in image is ' + data_cat[np.argmax(score)])
st.write('With accuracy of ' + str(np.max(score)*100))