Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
import numpy as np
|
5 |
from models.neural_network.inference import load_model_and_preprocessor
|
6 |
|
7 |
-
|
8 |
# Load the pre-trained model and preprocessor
|
9 |
nn_model, nn_preprocessor = load_model_and_preprocessor('nn_model.keras', 'nn_preprocessor.pkl')
|
10 |
|
11 |
# Load the unique aircraft data and airport distances
|
12 |
aircraft_data = pd.read_csv('aircraft_data.csv').drop_duplicates(subset='model')
|
13 |
-
|
14 |
|
|
|
|
|
15 |
|
16 |
|
17 |
def predict_fuel_burn(model_name, origin, destination, seats, distance):
|
|
|
1 |
+
import sys
|
2 |
+
import os
|
3 |
+
|
4 |
+
# Add the path to the project directory where the 'models' folder is located
|
5 |
+
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
6 |
+
|
7 |
+
# Now you can import the model as usual
|
8 |
+
from models.neural_network.inference import load_model_and_preprocessor
|
9 |
|
10 |
import gradio as gr
|
11 |
import pandas as pd
|
12 |
import numpy as np
|
13 |
from models.neural_network.inference import load_model_and_preprocessor
|
14 |
|
|
|
15 |
# Load the pre-trained model and preprocessor
|
16 |
nn_model, nn_preprocessor = load_model_and_preprocessor('nn_model.keras', 'nn_preprocessor.pkl')
|
17 |
|
18 |
# Load the unique aircraft data and airport distances
|
19 |
aircraft_data = pd.read_csv('aircraft_data.csv').drop_duplicates(subset='model')
|
20 |
+
aircraft_dict = aircraft_data.set_index('model').to_dict(orient='index')
|
21 |
|
22 |
+
airport_data = pd.read_csv('airport_distances.csv')
|
23 |
+
airport_dict = airport_data.set_index(['Origin_Airport', 'Destination_Airport']).to_dict(orient='index')
|
24 |
|
25 |
|
26 |
def predict_fuel_burn(model_name, origin, destination, seats, distance):
|