Donlapark commited on
Commit
8476da5
·
verified ·
1 Parent(s): 23d1cab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -5,7 +5,7 @@ import numpy as np
5
  # Load the model and unique brand values
6
  model = joblib.load('model.joblib')
7
  unique_values = joblib.load('unique_values.joblib')
8
- brand_values = list(unique_values['Brand'])
9
 
10
  # Define the prediction function
11
  def predict(brand, screen_size, resolution_width, resolution_height):
@@ -14,8 +14,13 @@ def predict(brand, screen_size, resolution_width, resolution_height):
14
  resolution_width = int(resolution_width)
15
  resolution_height = int(resolution_height)
16
 
17
- # Prepare the input array for prediction
18
- input_data = np.array([[brand, screen_size, resolution_width, resolution_height]])
 
 
 
 
 
19
 
20
  # Perform the prediction
21
  prediction = model.predict(input_data)
 
5
  # Load the model and unique brand values
6
  model = joblib.load('model.joblib')
7
  unique_values = joblib.load('unique_values.joblib')
8
+ brand_values = list(unique_values['Brand']) # Gradio's dropdown only accpets a list
9
 
10
  # Define the prediction function
11
  def predict(brand, screen_size, resolution_width, resolution_height):
 
14
  resolution_width = int(resolution_width)
15
  resolution_height = int(resolution_height)
16
 
17
+ # Create a DataFrame with the input data
18
+ input_data = pd.DataFrame({
19
+ 'Brand': [brand],
20
+ 'Screen Size': [screen_size],
21
+ 'Resolution (Width)': [resolution_width],
22
+ 'Resolution (Height)': [resolution_height]
23
+ })
24
 
25
  # Perform the prediction
26
  prediction = model.predict(input_data)