carmel26 commited on
Commit
8a2fc94
·
1 Parent(s): 3688bf7

adding new files 29Dec2023

Browse files
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import joblib
5
+ from collections import Counter
6
+
7
+ model = joblib.load('random_forest_model.joblib')
8
+ scaler = joblib.load('scaler.joblib')
9
+
10
+ def preprocess_uploaded_file(uploaded_df, scaler, num_scans=15):
11
+ uploaded_df.columns = ['wavelengths'] + [f'SCAN{i}' for i in range(1, uploaded_df.shape[1])]
12
+ template_data = {'wavelengths': uploaded_df['wavelengths']}
13
+ for i in range(1, num_scans + 1):
14
+ template_data[f'SCAN{i}'] = 0
15
+ template_df = pd.DataFrame(template_data)
16
+ for column in uploaded_df.columns:
17
+ if column in template_df.columns:
18
+ template_df[column] = uploaded_df[column]
19
+ template_df_cleaned = template_df.dropna(axis=1)
20
+ preprocessed_df = scaler.transform(template_df_cleaned)
21
+ return preprocessed_df
22
+
23
+ st.image('logo.png', caption=None, width=None, use_column_width=None, clamp=False, channels="RGB", output_format="auto")
24
+
25
+ st.markdown("<h3 style='text-align: center; color: grey;'>Hyperspectral Based System For Identification Of Common Bean Genotypes Resistant To Foliar Diseases</h2>", unsafe_allow_html=True)
26
+
27
+ uploaded_file = st.file_uploader('Choose a CSV file', type='csv')
28
+
29
+ if uploaded_file is not None:
30
+ input_df = pd.read_csv(uploaded_file)
31
+ preprocessed_input = preprocess_uploaded_file(input_df, scaler)
32
+ predictions = model.predict(preprocessed_input)
33
+ most_common_class = Counter(predictions).most_common(1)[0][0]
34
+ if most_common_class == 'Resistant':
35
+ st.write('The Plant is resistant to foliar diseases.')
36
+ elif most_common_class == 'Medium':
37
+ st.write('The Plant shows medium resistance to foliar diseases.')
38
+ elif most_common_class == 'Susceptible':
39
+ st.write('The Plant is susceptible to foliar diseases.')
logo.png ADDED
random_forest_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e28ef74a5127efd34b6ff199c22f671f5ab383f0de48073acc22bd4fd138beae
3
+ size 6313940
random_forest_modelNew.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8ce1e9d3eea3d534d360f8ffe5cbf3d64b7cf21baaf51346408434f1f27825b
3
+ size 6319361
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ scikit-learn==1.2.2
2
+ joblib==1.3.2
3
+ collections
4
+ pandas==2.0.3
5
+ numpy==1.24.4
scaler.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33f96aeef4a3ab565b7953d920314a792938db492ad334d6754ba329db663c57
3
+ size 1420
scalerNew.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b68e4413be2a55d2a39c553958359cb7ca97d19fc853f369258e28c69017c52
3
+ size 1495