kanneboinakumar commited on
Commit
85d0fb4
·
verified ·
1 Parent(s): ca8ae13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -17
app.py CHANGED
@@ -1,5 +1,4 @@
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
@@ -15,6 +14,7 @@ def set_background(image_file):
15
  .stApp {{
16
  background-image: url(data:image/png;base64,{encoded_string});
17
  background-size: cover;
 
18
  }}
19
  </style>
20
  """,
@@ -27,10 +27,10 @@ set_background('path_to_your_image.png')
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)
@@ -42,10 +42,11 @@ class ANN_Model(nn.Module):
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
  col1, col2, col3 = st.columns(3)
50
 
51
  with col1:
@@ -57,7 +58,7 @@ with col1:
57
 
58
  with col2:
59
  AptitudeTestScore = st.number_input("Aptitude Test Score", min_value=0, max_value=100, step=1)
60
- SoftSkillsRating = st.number_input("Soft Skills Rating", min_value=0, max_value=5)
61
  ExtracurricularActivities = st.selectbox("Extracurricular Activities", ["Yes", "No"])
62
  ExtracurricularActivities = 1 if ExtracurricularActivities == "Yes" else 0
63
 
@@ -67,18 +68,20 @@ with col3:
67
  SSC_Marks = st.number_input("SSC Marks", min_value=0, max_value=100, step=1)
68
  HSC_Marks = st.number_input("HSC Marks", min_value=0, max_value=100, step=1)
69
 
70
-
71
  # Predict Button
72
  if st.button("Predict Placement"):
73
  # Prepare input for model
74
- input_data = [cgpa, internships, projects, certifications, AptitudeTestScore, SoftSkillsRating,
75
- ExtracurricularActivities, PlacementTraining, SSC_Marks, HSC_Marks]
76
- # Example: Making a prediction
 
 
 
77
  with torch.no_grad():
78
- output = model(torch.tensor(input_data)).numpy()
79
  if output >= 0.5:
80
  st.markdown(
81
- f"""
82
  <div style='background-color: #d4edda; padding: 10px; border-radius: 5px;'>
83
  <h4 style='color: #155724;'>🎉 Congratulations! You are likely to get placed.</h4>
84
  </div>
@@ -87,7 +90,10 @@ if st.button("Predict Placement"):
87
  )
88
  else:
89
  st.markdown(
90
- f"""
91
- <div style='background-color: #f8d7da;
92
- ::contentReference[oaicite:2]{index=2} """
93
-
 
 
 
 
1
  import streamlit as st
 
2
  import torch
3
  import torch.nn as nn
4
  import torch.nn.functional as F
 
14
  .stApp {{
15
  background-image: url(data:image/png;base64,{encoded_string});
16
  background-size: cover;
17
+ background-attachment: fixed;
18
  }}
19
  </style>
20
  """,
 
27
  # Custom title with blue color
28
  st.markdown("<h1 style='color: blue;'>Placement Analysis</h1>", unsafe_allow_html=True)
29
 
30
+ # Define the ANN model architecture
31
  class ANN_Model(nn.Module):
32
  def __init__(self, input_cols=10, hidden1=20, hidden2=20, output=1):
33
+ super(ANN_Model, self).__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)
 
42
  return x
43
 
44
  # Load the model
45
+ model = ANN_Model()
46
+ model.load_state_dict(torch.load("ANN_model.pth"))
47
+ model.eval()
48
 
49
+ # Create three columns for input fields
50
  col1, col2, col3 = st.columns(3)
51
 
52
  with col1:
 
58
 
59
  with col2:
60
  AptitudeTestScore = st.number_input("Aptitude Test Score", min_value=0, max_value=100, step=1)
61
+ SoftSkillsRating = st.number_input("Soft Skills Rating", min_value=0, max_value=5, step=1)
62
  ExtracurricularActivities = st.selectbox("Extracurricular Activities", ["Yes", "No"])
63
  ExtracurricularActivities = 1 if ExtracurricularActivities == "Yes" else 0
64
 
 
68
  SSC_Marks = st.number_input("SSC Marks", min_value=0, max_value=100, step=1)
69
  HSC_Marks = st.number_input("HSC Marks", min_value=0, max_value=100, step=1)
70
 
 
71
  # Predict Button
72
  if st.button("Predict Placement"):
73
  # Prepare input for model
74
+ input_data = torch.tensor([[
75
+ cgpa, internships, projects, certifications, AptitudeTestScore, SoftSkillsRating,
76
+ ExtracurricularActivities, PlacementTraining, SSC_Marks, HSC_Marks
77
+ ]], dtype=torch.float32)
78
+
79
+ # Make a prediction
80
  with torch.no_grad():
81
+ output = model(input_data).item()
82
  if output >= 0.5:
83
  st.markdown(
84
+ """
85
  <div style='background-color: #d4edda; padding: 10px; border-radius: 5px;'>
86
  <h4 style='color: #155724;'>🎉 Congratulations! You are likely to get placed.</h4>
87
  </div>
 
90
  )
91
  else:
92
  st.markdown(
93
+ """
94
+ <div style='background-color: #f8d7da; padding: 10px; border-radius: 5px;'>
95
+ <h4 style='color: #721c24;'>⚠️ You might need to improve your profile for better chances.</h4>
96
+ </div>
97
+ """,
98
+ unsafe_allow_html=True
99
+ )