Spaces:
Runtime error
Runtime error
fix code
Browse files
app.py
CHANGED
@@ -14,8 +14,8 @@ from transformers import TFAutoModel, AutoTokenizer
|
|
14 |
from sklearn.model_selection import train_test_split
|
15 |
|
16 |
# load the tokenizer and transformer model
|
17 |
-
tokenizer = AutoTokenizer.from_pretrained("
|
18 |
-
transformer_model = TFAutoModel.from_pretrained("
|
19 |
max_seq_length = 32
|
20 |
|
21 |
def create_model():
|
@@ -86,6 +86,7 @@ def predict(text):
|
|
86 |
test_padded_sequences = pad_sequences(new_input_ids, maxlen=max_seq_length,padding='post',truncating='post',value=1) #post pre
|
87 |
print(test_padded_sequences.shape)
|
88 |
predicted_labels = model.predict(test_padded_sequences)
|
|
|
89 |
|
90 |
for i in range(len(test_texts)):
|
91 |
print(test_texts[i])
|
@@ -112,7 +113,18 @@ def predict(text):
|
|
112 |
print(f'hour : {hour_label}')
|
113 |
print(f'minute : {minute_label}')
|
114 |
print('----')
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
iface = gr.Interface(
|
118 |
fn=predict,
|
|
|
14 |
from sklearn.model_selection import train_test_split
|
15 |
|
16 |
# load the tokenizer and transformer model
|
17 |
+
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-base",max_length=60) #xlm-roberta-base bert-base-multilingual-cased
|
18 |
+
transformer_model = TFAutoModel.from_pretrained("xlm-roberta-base") #philschmid/tiny-bert-sst2-distilled
|
19 |
max_seq_length = 32
|
20 |
|
21 |
def create_model():
|
|
|
86 |
test_padded_sequences = pad_sequences(new_input_ids, maxlen=max_seq_length,padding='post',truncating='post',value=1) #post pre
|
87 |
print(test_padded_sequences.shape)
|
88 |
predicted_labels = model.predict(test_padded_sequences)
|
89 |
+
output = []
|
90 |
|
91 |
for i in range(len(test_texts)):
|
92 |
print(test_texts[i])
|
|
|
113 |
print(f'hour : {hour_label}')
|
114 |
print(f'minute : {minute_label}')
|
115 |
print('----')
|
116 |
+
tmp = {
|
117 |
+
'valid' : valid,
|
118 |
+
'is_scene' : is_scene,
|
119 |
+
'has_num' : has_num,
|
120 |
+
'turn_on_off' : turn,
|
121 |
+
'device' : 'ΰΉΰΈ',
|
122 |
+
'env' : env_label,
|
123 |
+
'hour' : hour,
|
124 |
+
'minute' : minute,
|
125 |
+
}
|
126 |
+
output.append(tmp)
|
127 |
+
return output
|
128 |
|
129 |
iface = gr.Interface(
|
130 |
fn=predict,
|