JHao2830 commited on
Commit
47efa97
·
1 Parent(s): 446779a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -90,7 +90,7 @@ class SingleDataset(Dataset):
90
  return features, label
91
 
92
 
93
- def test(model_path, var_path, csv_path, pos):
94
 
95
  attrib_feature = ['Current', 'Voltage', 'Environment_Temperature', 'Cell_Temperature', 'SOC']
96
  attrib_label = ['SOH']
@@ -105,16 +105,24 @@ def test(model_path, var_path, csv_path, pos):
105
  batch_size = 1
106
  C_rated = 1.1
107
 
108
- model_path = model_path.name
109
- var_path = var_path.name
110
- csv_path = csv_path.name
 
 
 
 
 
 
 
111
 
112
  with open(var_path, 'rb') as f:
113
  min_val, max_val = pickle.load(f)
114
 
115
 
116
-
117
  test_data = pd.read_csv(csv_path)
 
118
  test_data['SOH'] = test_data['cycle capacity'] / test_data['cycle capacity'].values[0]
119
  # C_val = val_data[attrib_label].values[0]
120
  # scaler_val = train_dataset.scaler
@@ -171,12 +179,12 @@ def test(model_path, var_path, csv_path, pos):
171
 
172
  return results
173
 
 
174
  #
175
  inputs = [
176
- File(label="上传预训练模型"),
177
- File(label="上传参数文件"),
178
  File(label="上传CSV测试数据"),
179
- Number(label="选择循环次数(1~4004)")
180
  ]
181
 
182
  outputs = [
 
90
  return features, label
91
 
92
 
93
+ def test(use_default, csv_path, pos):
94
 
95
  attrib_feature = ['Current', 'Voltage', 'Environment_Temperature', 'Cell_Temperature', 'SOC']
96
  attrib_label = ['SOH']
 
105
  batch_size = 1
106
  C_rated = 1.1
107
 
108
+ base = './测试用例/'
109
+ model_path = base + 'model.pt'
110
+ var_path = base + 'variables.pkl'
111
+ if use_default:
112
+ csv_path = base + 'Test_Data_0.5_3C.csv'
113
+ else:
114
+ csv_path = csv_path.name
115
+ # model_path = model_path.name
116
+ # var_path = var_path.name
117
+ # csv_path = csv_path.name
118
 
119
  with open(var_path, 'rb') as f:
120
  min_val, max_val = pickle.load(f)
121
 
122
 
123
+ global max_cycle_index
124
  test_data = pd.read_csv(csv_path)
125
+ max_cycle_index = test_data['Cycle_Index'].max()
126
  test_data['SOH'] = test_data['cycle capacity'] / test_data['cycle capacity'].values[0]
127
  # C_val = val_data[attrib_label].values[0]
128
  # scaler_val = train_dataset.scaler
 
179
 
180
  return results
181
 
182
+ default_checkbox = Checkbox(label="使用默认文件", default=False)
183
  #
184
  inputs = [
185
+ default_checkbox,
 
186
  File(label="上传CSV测试数据"),
187
+ Number(label='选择循环次数(1~'+str(max_cycle_index)+')')
188
  ]
189
 
190
  outputs = [