Bhargavitippareddy commited on
Commit
05788f1
·
verified ·
1 Parent(s): 02c85ab

Upload 4 files

Browse files
Files changed (4) hide show
  1. app (3).py +67 -0
  2. model (1).h5 +3 -0
  3. requirements (6).txt +5 -0
  4. streamlit_config.toml.txt +7 -0
app (3).py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import PIL.Image as Image
3
+ import tensorflow as tf
4
+ import streamlit as st
5
+ from streamlit_extras.add_vertical_space import add_vertical_space
6
+ from warnings import filterwarnings
7
+ filterwarnings('ignore')
8
+
9
+ def streamlit_config():
10
+ st.set_page_config(page_title='Classification', layout='centered')
11
+
12
+ base64_image = """
13
+ <style>
14
+ body, .stApp {
15
+ background-color: #006400 !important;
16
+ }
17
+ [data-testid="stHeader"] {
18
+ background: rgba(0,0,0,0) !important;
19
+ }
20
+ .bottom-right {
21
+ position: fixed;
22
+ bottom: 10px;
23
+ right: 10px;
24
+ background-color: rgba(0, 0, 0, 0.7);
25
+ padding: 10px;
26
+ border-radius: 10px;
27
+ color: white;
28
+ font-size: 16px;
29
+ }
30
+ </style>
31
+ """
32
+ st.markdown(base64_image, unsafe_allow_html=True)
33
+
34
+ st.markdown(f'<h1 style="text-align: center; color: white;">Potato Disease Finder </h1>', unsafe_allow_html=True)
35
+ add_vertical_space(4)
36
+
37
+ # Show "by Varun Tiwari" at the start page
38
+ st.markdown('<div class="bottom-right">by Varun Tiwari</div>', unsafe_allow_html=True)
39
+
40
+ streamlit_config()
41
+
42
+ def prediction(image_path, class_names=['Potato___Early_blight', 'Potato___Late_blight', 'Potato___healthy']):
43
+ img = Image.open(image_path)
44
+ img_resized = img.resize((256, 256))
45
+ img_array = tf.keras.preprocessing.image.img_to_array(img_resized)
46
+ img_array = np.expand_dims(img_array, axis=0)
47
+
48
+ model = tf.keras.models.load_model('model.h5')
49
+ prediction = model.predict(img_array)
50
+ predicted_class = class_names[np.argmax(prediction)]
51
+ confidence = round(np.max(prediction) * 100, 2)
52
+
53
+ st.markdown(
54
+ f'<div class="bottom-right">Predicted Class: {predicted_class}<br>Confidence: {confidence}%</div>',
55
+ unsafe_allow_html=True
56
+ )
57
+ st.image(img.resize((400, 300)))
58
+
59
+ col1, col2, col3 = st.columns([0.1, 0.9, 0.1])
60
+ with col2:
61
+ input_image = st.file_uploader(label='Upload the Image', type=['jpg', 'jpeg', 'png'])
62
+
63
+ if input_image is not None:
64
+ col1, col2, col3 = st.columns([0.2, 0.8, 0.2])
65
+ with col2:
66
+ prediction(input_image)
67
+
model (1).h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8e69552fb43cb1ac43301ca71b19f20e7f7ff4fe2ff13ef308feaf93b2fb45ff
3
+ size 2286592
requirements (6).txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ numpy
2
+ pillow
3
+ tensorflow
4
+ streamlit
5
+ streamlit_extras
streamlit_config.toml.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ [theme]
2
+ base="light"
3
+ primaryColor="#FF4B4B"
4
+ backgroundColor="#DFFFD6"
5
+ secondaryBackgroundColor="#B8E986"
6
+ textColor="#0E1117"
7
+ font="sans serif"