kanneboinakumar commited on
Commit
f3306ac
·
verified ·
1 Parent(s): 178b029

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +86 -51
app.py CHANGED
@@ -1,51 +1,86 @@
1
- import streamlit as st
2
- import numpy as np
3
- import torch
4
- import torch.nn as nn
5
- import torch.nn.functional as F
6
-
7
- st.title("Placement Analysis")
8
- # Define the same model architecture
9
- class ANN_Model(nn.Module):
10
- def __init__(self, input_cols=10, hidden1=20, hidden2=20, output=1):
11
- super().__init__()
12
- self.f_connected1 = nn.Linear(input_cols, hidden1)
13
- self.f_connected2 = nn.Linear(hidden1, hidden2)
14
- self.out = nn.Linear(hidden2, output)
15
-
16
- def forward(self, x):
17
- x = F.relu(self.f_connected1(x))
18
- x = F.relu(self.f_connected2(x))
19
- x = torch.sigmoid(self.out(x)) # Sigmoid for binary classification
20
- return x
21
-
22
- # Load the model
23
- model = ANN_Model() # Initialize the model
24
- model.load_state_dict(torch.load("ANN_model.pth")) # Load saved weights
25
- model.eval() # Set to evaluation mode
26
-
27
- cgpa = st.number_input("Enter your CGPA", min_value=0.0, max_value=10.0, step=0.01)
28
- internships = st.number_input("Number of Internships", min_value=0, max_value=10, step=1)
29
- projects = st.number_input("Number of Projects", min_value=0, max_value=20, step=1)
30
- certifications = st.selectbox("Do you have certifications?", ["Yes", "No"])
31
- certifications = 1 if certifications =="Yes" else 0
32
- AptitudeTestScore = st.number_input("Aptitude Test Score", min_value=0, max_value=100, step=1)
33
- SoftSkillsRating = st.number_input("Soft Skills Rating",min_value=0,max_value=5)
34
- ExtracurricularActivities = st.selectbox("Extracurricular Activities",["Yes","No"])
35
- ExtracurricularActivities = 1 if ExtracurricularActivities=="Yes" else 0
36
- PlacementTraining = st.selectbox("Placement Training",["Yes","No"])
37
- PlacementTraining = 1 if PlacementTraining=="Yes" else 0
38
- SSC_Marks = st.number_input("SSC Marks", min_value=0, max_value=100, step=1)
39
- HSC_Marks = st.number_input("HSC Marks", min_value=0, max_value=100, step=1)
40
- # Predict Button
41
- if st.button("Predict Placement"):
42
- # Prepare input for model
43
- input_data = [cgpa, internships, projects,certifications,AptitudeTestScore,SoftSkillsRating,
44
- ExtracurricularActivities,PlacementTraining,SSC_Marks,HSC_Marks ]
45
- # # Example: Making a prediction
46
- with torch.no_grad():
47
- output = model(torch.tensor(input_data)).numpy()
48
- if output >= 0.5:
49
- st.success("🎉 Congratulations! You are likely to get placed.")
50
- else:
51
- st.error("⚠️ You might need to improve your profile for better chances.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import torch
4
+ import torch.nn as nn
5
+ import torch.nn.functional as F
6
+ import base64
7
+
8
+ # Function to set background image
9
+ def set_background(image_file):
10
+ with open(image_file, "rb") as image:
11
+ encoded_string = base64.b64encode(image.read()).decode()
12
+ st.markdown(
13
+ f"""
14
+ <style>
15
+ .stApp {{
16
+ background-image: url(data:image/png;base64,{encoded_string});
17
+ background-size: cover;
18
+ }}
19
+ </style>
20
+ """,
21
+ unsafe_allow_html=True
22
+ )
23
+
24
+ # Set the background image
25
+ set_background('path_to_your_image.png')
26
+
27
+ # Custom title with blue color
28
+ st.markdown("<h1 style='color: blue;'>Placement Analysis</h1>", unsafe_allow_html=True)
29
+
30
+ # Define the same model architecture
31
+ class ANN_Model(nn.Module):
32
+ def __init__(self, input_cols=10, hidden1=20, hidden2=20, output=1):
33
+ super().__init__()
34
+ self.f_connected1 = nn.Linear(input_cols, hidden1)
35
+ self.f_connected2 = nn.Linear(hidden1, hidden2)
36
+ self.out = nn.Linear(hidden2, output)
37
+
38
+ def forward(self, x):
39
+ x = F.relu(self.f_connected1(x))
40
+ x = F.relu(self.f_connected2(x))
41
+ x = torch.sigmoid(self.out(x)) # Sigmoid for binary classification
42
+ return x
43
+
44
+ # Load the model
45
+ model = ANN_Model() # Initialize the model
46
+ model.load_state_dict(torch.load("ANN_model.pth")) # Load saved weights
47
+ model.eval() # Set to evaluation mode
48
+
49
+ # User inputs
50
+ cgpa = st.number_input("Enter your CGPA", min_value=0.0, max_value=10.0, step=0.01)
51
+ internships = st.number_input("Number of Internships", min_value=0, max_value=10, step=1)
52
+ projects = st.number_input("Number of Projects", min_value=0, max_value=20, step=1)
53
+ certifications = st.selectbox("Do you have certifications?", ["Yes", "No"])
54
+ certifications = 1 if certifications == "Yes" else 0
55
+ AptitudeTestScore = st.number_input("Aptitude Test Score", min_value=0, max_value=100, step=1)
56
+ SoftSkillsRating = st.number_input("Soft Skills Rating", min_value=0, max_value=5)
57
+ ExtracurricularActivities = st.selectbox("Extracurricular Activities", ["Yes", "No"])
58
+ ExtracurricularActivities = 1 if ExtracurricularActivities == "Yes" else 0
59
+ PlacementTraining = st.selectbox("Placement Training", ["Yes", "No"])
60
+ PlacementTraining = 1 if PlacementTraining == "Yes" else 0
61
+ SSC_Marks = st.number_input("SSC Marks", min_value=0, max_value=100, step=1)
62
+ HSC_Marks = st.number_input("HSC Marks", min_value=0, max_value=100, step=1)
63
+
64
+ # Predict Button
65
+ if st.button("Predict Placement"):
66
+ # Prepare input for model
67
+ input_data = [cgpa, internships, projects, certifications, AptitudeTestScore, SoftSkillsRating,
68
+ ExtracurricularActivities, PlacementTraining, SSC_Marks, HSC_Marks]
69
+ # Example: Making a prediction
70
+ with torch.no_grad():
71
+ output = model(torch.tensor(input_data)).numpy()
72
+ if output >= 0.5:
73
+ st.markdown(
74
+ """
75
+ <div style='background-color: #d4edda; padding: 10px; border-radius: 5px;'>
76
+ <h4 style='color: #155724;'>🎉 Congratulations! You are likely to get placed.</h4>
77
+ </div>
78
+ """,
79
+ unsafe_allow_html=True
80
+ )
81
+ else:
82
+ st.markdown(
83
+ """
84
+ <div style='background-color: #f8d7da;
85
+ ::contentReference[oaicite:2]{index=2}
86
+