hen8001 commited on
Commit
7aa22f2
·
verified ·
1 Parent(s): dc5b7fa

Delete cotton_app.py

Browse files
Files changed (1) hide show
  1. cotton_app.py +0 -39
cotton_app.py DELETED
@@ -1,39 +0,0 @@
1
- import tensorflow as tf
2
- model = tf.keras.models.load_model('cotton_crop.h5')
3
- import streamlit as st
4
- st.write("""
5
- # Cotton crop identification
6
- """
7
- )
8
- #st.write("This is a simple image classification web app to predict rock-paper-scissor hand sign")
9
- file = st.file_uploader("Please upload an image file", type=["jpg", "png"])
10
-
11
- import cv2
12
- from PIL import Image, ImageOps
13
- import numpy as np
14
- def import_and_predict(image_data, model):
15
-
16
- size = (300,300)
17
- image = ImageOps.fit(image_data, size, Image.ANTIALIAS)
18
- image = np.asarray(image)
19
- img = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
20
- img_resize = (cv2.resize(img, dsize=(300, 300), interpolation=cv2.INTER_CUBIC))/255.
21
-
22
- img_reshape = img_resize[np.newaxis,...]
23
-
24
- prediction = model.predict(img_reshape)
25
-
26
- return prediction
27
- if file is None:
28
- st.text("Please upload an image file")
29
- else:
30
- image = Image.open(file)
31
- st.image(image, use_column_width=True)
32
- prediction = import_and_predict(image, model)
33
-
34
- # if np.argmax(prediction) == 0:
35
- if prediction[0][0]==1.0:
36
- st.write("Cotton crop")
37
- else:
38
- st.write("Not a cotton crop")
39
- st.write(prediction)