Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,17 @@
|
|
1 |
-
import
|
2 |
import joblib
|
3 |
import numpy as np
|
4 |
-
import
|
|
|
|
|
5 |
|
6 |
-
# Get the current
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Load the trained model from the same directory
|
10 |
model_path = os.path.join(current_dir, "trained_model.joblib")
|
@@ -45,10 +52,13 @@ input_labels = ["CSC101_total", "CSC201_total", "CSC203_total", "CSC205_total",
|
|
45 |
"CNE304_total", "CSC301_total", "CNE302_total", "CSC309_total", "CSC302_total",
|
46 |
"CSC303_total", "CNE308_total"]
|
47 |
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
-
# Create the Gradio app
|
52 |
app = gr.Interface(fn=predict_department, inputs=inputs, outputs=output, title="Department Predictor")
|
53 |
|
54 |
# Launch the app
|
|
|
1 |
+
import os
|
2 |
import joblib
|
3 |
import numpy as np
|
4 |
+
import gradio as gr
|
5 |
+
from pathlib import Path
|
6 |
+
import sys
|
7 |
|
8 |
+
# Get the current directory of the script or fallback to the current working directory
|
9 |
+
if hasattr(sys, 'frozen'):
|
10 |
+
current_dir = Path(sys.executable).parent
|
11 |
+
elif '__file__' in globals():
|
12 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
13 |
+
else:
|
14 |
+
current_dir = Path().absolute()
|
15 |
|
16 |
# Load the trained model from the same directory
|
17 |
model_path = os.path.join(current_dir, "trained_model.joblib")
|
|
|
52 |
"CNE304_total", "CSC301_total", "CNE302_total", "CSC309_total", "CSC302_total",
|
53 |
"CSC303_total", "CNE308_total"]
|
54 |
|
55 |
+
# Create a list of number inputs corresponding to the input labels
|
56 |
+
inputs = [gr.Number(label=label) for label in input_labels]
|
57 |
+
|
58 |
+
# Define the output as a text box that will show the predicted department
|
59 |
+
output = gr.Textbox(label="Predicted Department")
|
60 |
|
61 |
+
# Create the Gradio app interface
|
62 |
app = gr.Interface(fn=predict_department, inputs=inputs, outputs=output, title="Department Predictor")
|
63 |
|
64 |
# Launch the app
|