File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change 2
2
from typing import Any , Dict , Iterable , List
3
3
from urllib .parse import urlparse
4
4
5
+ import numpy as np
5
6
import pandas as pd
6
7
import ray
7
8
import torch
@@ -62,8 +63,6 @@ def predict_with_proba(
62
63
"""
63
64
preprocessor = predictor .get_preprocessor ()
64
65
z = predictor .predict (data = df )["predictions" ]
65
- import numpy as np
66
-
67
66
y_prob = torch .tensor (np .stack (z )).softmax (dim = 1 ).numpy ()
68
67
results = []
69
68
for i , prob in enumerate (y_prob ):
@@ -130,7 +129,7 @@ def predict(
130
129
131
130
# Predict
132
131
sample_df = pd .DataFrame ([{"title" : title , "description" : description , "tag" : "other" }])
133
- results = predict_with_proba (df = sample_df , predictor = predictor , index_to_class = preprocessor . index_to_class )
132
+ results = predict_with_proba (df = sample_df , predictor = predictor )
134
133
logger .info (json .dumps (results , cls = NumpyEncoder , indent = 2 ))
135
134
return results
136
135
You can’t perform that action at this time.
0 commit comments