Update fun_advaitbert.py
Browse files- fun_advaitbert.py +9 -0
fun_advaitbert.py
CHANGED
|
@@ -12,6 +12,7 @@ tf.get_logger().setLevel('ERROR')
|
|
| 12 |
from huggingface_hub import InferenceClient
|
| 13 |
import math
|
| 14 |
import gradio as gr
|
|
|
|
| 15 |
|
| 16 |
num_warmup_steps=1
|
| 17 |
num_train_steps=1
|
|
@@ -163,6 +164,8 @@ additional_inputs=[
|
|
| 163 |
|
| 164 |
def predict_CTH(txt):
|
| 165 |
print('Desc: ',txt)
|
|
|
|
|
|
|
| 166 |
if (txt!='') and len(txt)>=3 and (count_special_character(txt)):
|
| 167 |
valid_data = tf.data.Dataset.from_tensor_slices(([txt] , [1])) # 1 refers to 'entertainment' and 2 refers to 'sport'
|
| 168 |
valid_data = (valid_data.map(to_feature_map).batch(1))
|
|
@@ -201,8 +204,14 @@ def predict_CTH(txt):
|
|
| 201 |
|
| 202 |
try:
|
| 203 |
pred_duty=df_report_DUTY[df_report_DUTY['CTH']==str(pred_CTH)]['DUTY_RATE'].iloc[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
pred_desc=df_report[df_report['CTH Code']==str(pred_CTH)]['Concat Description'].iloc[0]
|
| 205 |
except:
|
|
|
|
| 206 |
pass
|
| 207 |
|
| 208 |
Var_CTH.append(pred_CTH)
|
|
|
|
| 12 |
from huggingface_hub import InferenceClient
|
| 13 |
import math
|
| 14 |
import gradio as gr
|
| 15 |
+
from datetime import datetime
|
| 16 |
|
| 17 |
num_warmup_steps=1
|
| 18 |
num_train_steps=1
|
|
|
|
| 164 |
|
| 165 |
def predict_CTH(txt):
|
| 166 |
print('Desc: ',txt)
|
| 167 |
+
now = datetime.now()
|
| 168 |
+
print("Time =", now)
|
| 169 |
if (txt!='') and len(txt)>=3 and (count_special_character(txt)):
|
| 170 |
valid_data = tf.data.Dataset.from_tensor_slices(([txt] , [1])) # 1 refers to 'entertainment' and 2 refers to 'sport'
|
| 171 |
valid_data = (valid_data.map(to_feature_map).batch(1))
|
|
|
|
| 204 |
|
| 205 |
try:
|
| 206 |
pred_duty=df_report_DUTY[df_report_DUTY['CTH']==str(pred_CTH)]['DUTY_RATE'].iloc[0]
|
| 207 |
+
except:
|
| 208 |
+
pred_duty=''
|
| 209 |
+
pass
|
| 210 |
+
|
| 211 |
+
try:
|
| 212 |
pred_desc=df_report[df_report['CTH Code']==str(pred_CTH)]['Concat Description'].iloc[0]
|
| 213 |
except:
|
| 214 |
+
pred_desc=''
|
| 215 |
pass
|
| 216 |
|
| 217 |
Var_CTH.append(pred_CTH)
|