Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import torch | |
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| import base64 | |
| st.markdown( | |
| """ | |
| <style> | |
| /* Set background image for the entire app */ | |
| .stApp { | |
| background: url('https://www.mrscindore.org/images/placements.jpg') no-repeat center center fixed; | |
| background-size: cover; | |
| } | |
| /* Style for the title */ | |
| .stApp h1 { | |
| background-color: rgba(0, 0, 128, 0.7); | |
| color: #ffffff; /* White */ | |
| padding: 10px; | |
| border-radius: 5px; | |
| font-size: 2.5em; | |
| text-align: center; | |
| } | |
| /* Style for input text area */ | |
| .stTextArea textarea { | |
| background-color: rgba(255, 255, 255, 0.8); | |
| color: #000000; /* Black */ | |
| font-size: 1.2em; | |
| } | |
| /* Style for the button */ | |
| .stButton>button { | |
| background-color: #4CAF50; /* Green */ | |
| color: white; | |
| font-size: 1.2em; | |
| border-radius: 10px; | |
| padding: 10px 24px; | |
| border: none; | |
| } | |
| /* Center the button */ | |
| .stButton { | |
| display: flex; | |
| justify-content: center; | |
| } | |
| /* Style for the output container */ | |
| .output-container { | |
| background-color: lightpink; | |
| color: black; | |
| font-size: 1.5em; | |
| padding: 15px; | |
| border-radius: 10px; | |
| margin-top: 20px; | |
| box-shadow: 0 4px 8px rgba(0,0,0,0.1); | |
| width: 200%; | |
| margin-left: auto; | |
| margin-right: auto; | |
| text-align: center; | |
| } | |
| </style> | |
| """, | |
| unsafe_allow_html=True | |
| ) | |
| st.title("Placement Analysis") | |
| # Define the ANN model architecture | |
| class ANN_Model(nn.Module): | |
| def __init__(self, input_cols=10, hidden1=20, hidden2=20, output=1): | |
| super(ANN_Model, self).__init__() | |
| self.f_connected1 = nn.Linear(input_cols, hidden1) | |
| self.f_connected2 = nn.Linear(hidden1, hidden2) | |
| self.out = nn.Linear(hidden2, output) | |
| def forward(self, x): | |
| x = F.relu(self.f_connected1(x)) | |
| x = F.relu(self.f_connected2(x)) | |
| x = torch.sigmoid(self.out(x)) | |
| return x | |
| # Load the model | |
| model = ANN_Model() | |
| model.load_state_dict(torch.load("ANN_model.pth")) | |
| model.eval() | |
| # Create three columns for input fields | |
| col1, col2, col3 = st.columns(3) | |
| with col1: | |
| SoftSkillsRating = st.number_input("Soft Skills Rating (0 to 5)", min_value=0, max_value=5, step=1) | |
| cgpa = st.number_input("Enter your CGPA (1 to 10)", min_value=0.0, max_value=10.0, step=0.01) | |
| internships = st.number_input("Number of Internships", min_value=0, max_value=10, step=1) | |
| with col2: | |
| AptitudeTestScore = st.number_input("Aptitude Test Score(%)", min_value=0, max_value=100, step=1) | |
| SSC_Marks = st.number_input("SSC Marks (%)", min_value=0, max_value=100, step=1) | |
| HSC_Marks = st.number_input("HSC Marks(%)", min_value=0, max_value=100, step=1) | |
| with col3: | |
| PlacementTraining = st.selectbox("Placement Training", ["Yes", "No"]) | |
| PlacementTraining = 1 if PlacementTraining == "Yes" else 0 | |
| certifications = st.selectbox("Do you have certifications?", ["Yes", "No"]) | |
| certifications = 1 if certifications == "Yes" else 0 | |
| ExtracurricularActivities = st.selectbox("Extracurricular Activities", ["Yes", "No"]) | |
| ExtracurricularActivities = 1 if ExtracurricularActivities == "Yes" else 0 | |
| projects = st.number_input("Number of Projects", min_value=0, max_value=20, step=1) | |
| # Predict Button | |
| if st.button("Predict Placement"): | |
| # Prepare input for model | |
| input_data = torch.tensor([[ | |
| cgpa, internships, projects, certifications, AptitudeTestScore, SoftSkillsRating, | |
| ExtracurricularActivities, PlacementTraining, SSC_Marks, HSC_Marks | |
| ]], dtype=torch.float32) | |
| # Make a prediction | |
| with torch.no_grad(): | |
| output = model(input_data).item() | |
| if output >= 0.5: | |
| st.markdown( | |
| """ | |
| <div style='background-color: #d4edda; padding: 10px; border-radius: 5px;'> | |
| <h4 style='color: #155724;'>🎉 Congratulations! You are likely to get placed.</h4> | |
| </div> | |
| """, | |
| unsafe_allow_html=True | |
| ) | |
| else: | |
| st.markdown( | |
| """ | |
| <div style='background-color: #f8d7da; padding: 10px; border-radius: 5px;'> | |
| <h4 style='color: #721c24;'>⚠️ You might need to improve your profile for better chances.</h4> | |
| </div> | |
| """, | |
| unsafe_allow_html=True | |
| ) | |