Upload 8 files
Browse files- Flask_5G/app.py +60 -0
- Flask_5G/label_encoder.pkl +3 -0
- Flask_5G/model.pkl +3 -0
- Flask_5G/modellr.pkl +3 -0
- Flask_5G/modelrff.pkl +3 -0
- Flask_5G/scaler.pkl +3 -0
- Flask_5G/static/images/download.jpg +0 -0
- Flask_5G/templates/home.html +145 -0
Flask_5G/app.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# pip install flask
|
| 2 |
+
|
| 3 |
+
from flask import Flask,render_template,request
|
| 4 |
+
import tensorflow as tf
|
| 5 |
+
import pickle
|
| 6 |
+
import pandas as pd
|
| 7 |
+
import numpy as np
|
| 8 |
+
from sklearn.ensemble import RandomForestRegressor
|
| 9 |
+
from sklearn.preprocessing import MinMaxScaler
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
# If you need to inverse transform, you can use scaler.inverse_transform(scaled_data)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# loading the label encoder
|
| 17 |
+
#le=pickle.load(open('label_encoder.pkl','rb'))
|
| 18 |
+
|
| 19 |
+
# loading my mlr model
|
| 20 |
+
model=pickle.load(open('modelrff.pkl','rb'))
|
| 21 |
+
|
| 22 |
+
#loading Scaler
|
| 23 |
+
scalar=pickle.load(open('scaler.pkl','rb'))
|
| 24 |
+
|
| 25 |
+
# Flask is used for creating your application
|
| 26 |
+
# render template is use for rendering the html page
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
app= Flask(__name__) # your application
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
@app.route('/') # default route
|
| 33 |
+
def home():
|
| 34 |
+
return render_template('home.html') # rendering if your home page.
|
| 35 |
+
|
| 36 |
+
@app.route('/pred',methods=['POST']) # prediction route
|
| 37 |
+
def predict1():
|
| 38 |
+
'''
|
| 39 |
+
For rendering results on HTML
|
| 40 |
+
'''
|
| 41 |
+
|
| 42 |
+
rd = request.form["Signal_Strength"]
|
| 43 |
+
ad= request.form["Latency"]
|
| 44 |
+
ms = request.form["Required_Bandwidth"]
|
| 45 |
+
s = request.form["type"]
|
| 46 |
+
p = request.form["Allocated_Bandwidth"]
|
| 47 |
+
t = np.array([[float(rd),float(ad),float(ms),float(s),float(p)] ])
|
| 48 |
+
x=scalar.transform(t)
|
| 49 |
+
output =model.predict(x)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
return render_template("home.html", result = "The predicted Resource_Allocation is "+str(np.round(output[0])))
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
# running your application
|
| 57 |
+
if __name__ == "__main__":
|
| 58 |
+
app.run()
|
| 59 |
+
|
| 60 |
+
#http://localhost:5000/ or localhost:5000
|
Flask_5G/label_encoder.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bfdb45e3c1c63f7ed34e5f99c50cbb955cbd53e56fd70fb93aa759f69ff88f08
|
| 3 |
+
size 417
|
Flask_5G/model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3462352bcd7f816421bc9289d1d15b57ac48bdbfbc6b4759c27fd93eb0ff415a
|
| 3 |
+
size 346957
|
Flask_5G/modellr.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d526080f306256810b6a392c95c75b0a5afdb93e740194a6178070364c0b0a20
|
| 3 |
+
size 660
|
Flask_5G/modelrff.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c16c1b6b194d92e86b62a0921eda4c22764938f3db81bf79504a008ed4f76e68
|
| 3 |
+
size 349901
|
Flask_5G/scaler.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:60fb700bd382eabf7cce28fdb282aa71ea859f0aae1bc6d0f9f11f13c29e8b57
|
| 3 |
+
size 858
|
Flask_5G/static/images/download.jpg
ADDED
|
Flask_5G/templates/home.html
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
+
<style>
|
| 8 |
+
|
| 9 |
+
body {
|
| 10 |
+
position: relative;
|
| 11 |
+
font-family: Arial, sans-serif;
|
| 12 |
+
margin: 0;
|
| 13 |
+
padding: 0;
|
| 14 |
+
display: flex;
|
| 15 |
+
flex-direction: column;
|
| 16 |
+
justify-content: center;
|
| 17 |
+
align-items: center;
|
| 18 |
+
height: 100vh;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
body::before {
|
| 22 |
+
content: "";
|
| 23 |
+
position: fixed;
|
| 24 |
+
top: 0;
|
| 25 |
+
left: 0;
|
| 26 |
+
width: 100%;
|
| 27 |
+
height: 100%;
|
| 28 |
+
background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.5)), url('../static/images/download.jpg');
|
| 29 |
+
|
| 30 |
+
background-repeat: no-repeat;
|
| 31 |
+
background-attachment: fixed;
|
| 32 |
+
background-size: cover;
|
| 33 |
+
z-index: -1;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.heading-row {
|
| 37 |
+
display: flex;
|
| 38 |
+
justify-content: center;
|
| 39 |
+
align-items: center;
|
| 40 |
+
flex-direction: column;
|
| 41 |
+
padding-top: 20px;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
h1 {
|
| 45 |
+
color: white;
|
| 46 |
+
text-align: center;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.form-row {
|
| 50 |
+
display: flex;
|
| 51 |
+
justify-content: center;
|
| 52 |
+
align-items: center;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
form {
|
| 56 |
+
background-color: rgba(255, 255, 255, 0.1);
|
| 57 |
+
padding: 20px;
|
| 58 |
+
border-radius: 10px;
|
| 59 |
+
width: 300px;
|
| 60 |
+
text-align: center;
|
| 61 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.9); /* Add shadow effect */
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
label {
|
| 65 |
+
display: block;
|
| 66 |
+
margin-top: 10px;
|
| 67 |
+
font-size: 20px;
|
| 68 |
+
color: white;
|
| 69 |
+
font-weight: bold;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
select,
|
| 73 |
+
input {
|
| 74 |
+
width: 100%;
|
| 75 |
+
padding: 8px;
|
| 76 |
+
margin: 5px 0;
|
| 77 |
+
box-sizing: border-box;
|
| 78 |
+
background-color: rgb(178, 178, 224);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
input[type="text"]{
|
| 82 |
+
background-color: rgb(178, 178, 224);
|
| 83 |
+
color: rgb(0, 0, 0);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
input[type="submit"] {
|
| 87 |
+
background-color: #4caf50;
|
| 88 |
+
color: white;
|
| 89 |
+
cursor: pointer;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
input[type="submit"]:hover {
|
| 93 |
+
background-color: #45a049;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.result {
|
| 97 |
+
margin-top: 20px;
|
| 98 |
+
color: white;
|
| 99 |
+
}
|
| 100 |
+
</style>
|
| 101 |
+
</head>
|
| 102 |
+
|
| 103 |
+
<body>
|
| 104 |
+
<div class="heading-row">
|
| 105 |
+
<h1>AI-Driven Optimization Of 5G Resource Allocation For Network Efficiency</h1>
|
| 106 |
+
</div>
|
| 107 |
+
|
| 108 |
+
<div class="form-row">
|
| 109 |
+
<form action="/pred" method="POST">
|
| 110 |
+
<label for="type">Application Type:</label>
|
| 111 |
+
<select name="type">
|
| 112 |
+
<option value="2">File_Download</option>
|
| 113 |
+
<option value="0">Background_Download</option>
|
| 114 |
+
<option value="1">Emergency_Service</option>
|
| 115 |
+
<option value="3">Online_Gaming</option>
|
| 116 |
+
<option value="4">Streaming</option>
|
| 117 |
+
<option value="5">Video_Call</option>
|
| 118 |
+
<option value="6">Video_Streaming</option>
|
| 119 |
+
<option value="7">VoIP_Call</option>
|
| 120 |
+
<option value="8">Voice_Call</option>
|
| 121 |
+
<option value="9">Web_Browsing</option>
|
| 122 |
+
</select>
|
| 123 |
+
|
| 124 |
+
<label for="Signal_Strength">Signal Strength:</label>
|
| 125 |
+
<input type="text" name="Signal_Strength">
|
| 126 |
+
|
| 127 |
+
<label for="Latency">Latency:</label>
|
| 128 |
+
<input type="text" name="Latency">
|
| 129 |
+
|
| 130 |
+
<label for="Required_Bandwidth">Required Bandwidth:</label>
|
| 131 |
+
<input type="text" name="Required_Bandwidth">
|
| 132 |
+
|
| 133 |
+
<label for="Allocated_Bandwidth">Allocated Bandwidth:</label>
|
| 134 |
+
<input type="text" name="Allocated_Bandwidth">
|
| 135 |
+
|
| 136 |
+
<input type="submit">
|
| 137 |
+
|
| 138 |
+
<div class="result">
|
| 139 |
+
{{result}}
|
| 140 |
+
</div>
|
| 141 |
+
</form>
|
| 142 |
+
</div>
|
| 143 |
+
</body>
|
| 144 |
+
|
| 145 |
+
</html>
|