rohithjoseph commited on
Commit
7e04194
·
1 Parent(s): 1ac28a7

Upload 5 files

Browse files
Files changed (6) hide show
  1. .gitattributes +3 -0
  2. DP.keras +3 -0
  3. LS.keras +3 -0
  4. PP.pkl +3 -0
  5. RN.keras +3 -0
  6. Stream.py +79 -0
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ DP.keras filter=lfs diff=lfs merge=lfs -text
37
+ LS.keras filter=lfs diff=lfs merge=lfs -text
38
+ RN.keras filter=lfs diff=lfs merge=lfs -text
DP.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:effe5efada6ccfaab2dc6ce3e189954b9c9b3abbaf86b2bdbe1f11d18d3684f0
3
+ size 10735120
LS.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:705ae60751f9f288daf9486f5b3535e437fd7aabb96c5b79f908e7f5e68c9b02
3
+ size 4194296
PP.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d490b9361db03dbd503b6a1424976d05a9865eefe505327b2ad342b989737eba
3
+ size 2264
RN.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56f772e386a259788dabcb7189fbe4327b3a31924fd0104e9d52c1c626101262
3
+ size 1548448
Stream.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ from PIL import Image
4
+ from tensorflow.keras.models import load_model
5
+ from tensorflow.keras.datasets import imdb
6
+ from tensorflow.keras.preprocessing.sequence import pad_sequences
7
+ import pickle
8
+
9
+ # Load word index for Sentiment Classification
10
+ word_to_index = imdb.get_word_index()
11
+
12
+ # Function to perform sentiment classification
13
+ def sentiment_classification(new_review_text, model):
14
+ max_review_length = 500
15
+ new_review_tokens = [word_to_index.get(word, 0) for word in new_review_text.split()]
16
+ new_review_tokens = pad_sequences([new_review_tokens], maxlen=max_review_length)
17
+ prediction = model.predict(new_review_tokens)
18
+ if type(prediction) == list:
19
+ prediction = prediction[0]
20
+ return "Positive" if prediction > 0.5 else "Negative"
21
+
22
+ # Function to perform tumor detection
23
+ def tumor_detection(img, model):
24
+ img = Image.open(img)
25
+ img=img.resize((128,128))
26
+ img=np.array(img)
27
+ input_img = np.expand_dims(img, axis=0)
28
+ res = model.predict(input_img)
29
+ return "Tumor Detected" if res else "No Tumor"
30
+
31
+ # Streamlit App
32
+ st.title("ALL MODELS")
33
+
34
+ # Choose between tasks
35
+ task = st.radio("Select Task", ("Sentiment Classification", "Tumor Detection"))
36
+
37
+ if task == "Sentiment Classification":
38
+ # Input box for new review
39
+ new_review_text = st.text_area("Enter a New Review:", value="")
40
+ if st.button("Submit") and not new_review_text.strip():
41
+ st.warning("Please enter a review.")
42
+
43
+ if new_review_text.strip():
44
+ st.subheader("Choose Model for Sentiment Classification")
45
+ model_option = st.selectbox("Select Model", ("Perceptron", "Backpropagation", "DNN", "RNN", "LSTM"))
46
+
47
+ # Load models dynamically based on the selected option
48
+ if model_option == "Perceptron":
49
+ with open('PP.pkl', 'rb') as file:
50
+ model = pickle.load(file)
51
+ elif model_option == "Backpropagation":
52
+ with open('BP.pkl', 'rb') as file:
53
+ model = pickle.load(file)
54
+ elif model_option == "DNN":
55
+ model = load_model('DP.keras')
56
+ elif model_option == "RNN":
57
+ model = load_model('RN.keras')
58
+ elif model_option == "LSTM":
59
+ model = load_model('LS.keras')
60
+
61
+ if st.button("Classify Sentiment"):
62
+ result = sentiment_classification(new_review_text, model)
63
+ st.subheader("Sentiment Classification Result")
64
+ st.write(f"**{result}**")
65
+
66
+ elif task == "Tumor Detection":
67
+ st.subheader("Tumor Detection")
68
+ uploaded_file = st.file_uploader("Choose a tumor image...", type=["jpg", "jpeg", "png"])
69
+
70
+ if uploaded_file is not None:
71
+ # Load the tumor detection model
72
+ model = load_model("D:\STUDY\S3\DEEP LEARNING\comb\cnn.pkl")
73
+ st.image(uploaded_file, caption="Uploaded Image.", use_column_width=False, width=200)
74
+ st.write("")
75
+
76
+ if st.button("Detect Tumor"):
77
+ result = tumor_detection(uploaded_file, model)
78
+ st.subheader("Tumor Detection Result")
79
+ st.write(f"**{result}**")