Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -323,16 +323,17 @@ if (should_train_model=='1'): #train model
|
|
323 |
|
324 |
if response.status_code == 200:
|
325 |
data = response.json() # Convert response to JSON
|
326 |
-
print(data)
|
327 |
else:
|
328 |
print(f"Error: {response.status_code}")
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
|
|
336 |
|
337 |
#Define the label mappings (this must match the mapping used during training)
|
338 |
label_mapping = model.config.label_mapping
|
|
|
323 |
|
324 |
if response.status_code == 200:
|
325 |
data = response.json() # Convert response to JSON
|
326 |
+
print("print data from API: ", data)
|
327 |
else:
|
328 |
print(f"Error: {response.status_code}")
|
329 |
+
|
330 |
+
else:
|
331 |
+
print('Load Pre-trained')
|
332 |
+
model_save_path = f"./{model_save_path}_model"
|
333 |
+
tokenizer_save_path = f"./{model_save_path}_tokenizer"
|
334 |
+
# RobertaTokenizer.from_pretrained(model_save_path)
|
335 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_save_path).to('cpu')
|
336 |
+
tokenizer = AutoTokenizer.from_pretrained(tokenizer_save_path)
|
337 |
|
338 |
#Define the label mappings (this must match the mapping used during training)
|
339 |
label_mapping = model.config.label_mapping
|