Spaces:
Build error
Build error
updated call of preprocessing method
Browse files
app.py
CHANGED
|
@@ -101,20 +101,20 @@ async def predict(predictionFeatures: PredictionFeatures):
|
|
| 101 |
```
|
| 102 |
"""
|
| 103 |
|
| 104 |
-
#
|
| 105 |
-
|
| 106 |
-
headers = {
|
| 107 |
-
"accept": "application/json",
|
| 108 |
-
"Content-Type": "application/json"
|
| 109 |
-
}
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
-
response = requests.post(url, headers=headers, json=data)
|
| 116 |
|
| 117 |
-
list_text = [
|
| 118 |
|
| 119 |
# Load model from MLflow
|
| 120 |
logged_model = 'runs:/227d2f8e431d40d6b5231add3a00d048/hate_speech_detection'
|
|
|
|
| 101 |
```
|
| 102 |
"""
|
| 103 |
|
| 104 |
+
# Copy the preprocess method to avoid issue
|
| 105 |
+
list_text_for_preprocessing = [predictionFeatures.Text]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
# Load model from MLflow
|
| 108 |
+
logged_model = 'runs:/89b183556cf34460858d94125f8df98d/text_preprocessor'
|
| 109 |
+
loaded_model = mlflow.pyfunc.load_model(logged_model)
|
| 110 |
+
|
| 111 |
+
df = pd.DataFrame(list_text_for_preprocessing,columns=['tweet'])
|
| 112 |
+
|
| 113 |
+
# Perform prediction
|
| 114 |
+
preprocessed_result = loaded_model.predict(pd.DataFrame(df))
|
| 115 |
|
|
|
|
| 116 |
|
| 117 |
+
list_text = [preprocessed_result['text_clean']['0']]
|
| 118 |
|
| 119 |
# Load model from MLflow
|
| 120 |
logged_model = 'runs:/227d2f8e431d40d6b5231add3a00d048/hate_speech_detection'
|