“ddthang86” commited on
Commit
1e85d54
·
1 Parent(s): 3dfe731

create app

Browse files
Files changed (4) hide show
  1. README.md +4 -4
  2. app.py +43 -0
  3. requirements.txt +5 -0
  4. soils.h5 +3 -0
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: Soils Class
3
- emoji: 🐨
4
- colorFrom: red
5
- colorTo: purple
6
  sdk: streamlit
7
  sdk_version: 1.25.0
8
  app_file: app.py
 
1
  ---
2
+ title: Soil Classification
3
+ emoji: 🌍
4
+ colorFrom: blue
5
+ colorTo: red
6
  sdk: streamlit
7
  sdk_version: 1.25.0
8
  app_file: app.py
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Library imports
2
+ import numpy as np
3
+ import streamlit as st
4
+ import cv2
5
+ from keras.models import load_model
6
+
7
+
8
+ #Loading the Model
9
+ model = load_model('soils.h5')
10
+
11
+ #Name of Classes
12
+ CLASS_NAMES = ['Acrisols', 'Fluvisols', 'Ferrasols']
13
+
14
+ #Setting Title of App
15
+ st.title("Soils classification")
16
+ st.markdown("Upload an image of the soil")
17
+
18
+ #Uploading the soil image
19
+ soil_image = st.file_uploader("Choose an image...", type="jpg")
20
+ submit = st.button('Predict')
21
+ #On predict button click
22
+ if submit:
23
+
24
+
25
+ if soil_image is not None:
26
+
27
+ # Convert the file to an opencv image.
28
+ file_bytes = np.asarray(bytearray(soil_image.read()), dtype=np.uint8)
29
+ opencv_image = cv2.imdecode(file_bytes, 1)
30
+
31
+
32
+
33
+ # Displaying the image
34
+ st.image(opencv_image, channels="BGR")
35
+ st.write(opencv_image.shape)
36
+ #Resizing the image
37
+ opencv_image = cv2.resize(opencv_image, (256,256))
38
+ #Convert image to 4 Dimension
39
+ opencv_image.shape = (1,256,256,3)
40
+ #Make Prediction
41
+ Y_pred = model.predict(opencv_image)
42
+ result = CLASS_NAMES[np.argmax(Y_pred)]
43
+ st.title(str("This is "+result.split('-')[0]+ " leaf with " + result.split('-')[1]))
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit
2
+ Keras
3
+ numpy
4
+ opencv_python
5
+ tensorflow
soils.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba09daa7f91cebd8eac6a202f71939e174b304150fe8daa8f2eb0e9861f049e6
3
+ size 2822224