Spaces:
Build error
Build error
update call of preprocess function
Browse files
app.py
CHANGED
|
@@ -100,24 +100,11 @@ async def predict(predictionFeatures: PredictionFeatures):
|
|
| 100 |
```
|
| 101 |
"""
|
| 102 |
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
"accept": "application/json",
|
| 109 |
-
"Content-Type": "application/json"
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
data_to_preprocessed = {
|
| 113 |
-
"tweet": predictionFeatures.Text
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
response = requests.post(url, headers=headers, json=data_to_preprocessed)
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
# Convert input into a DataFrame
|
| 120 |
-
list_text = [response.json()['text_clean']['0']]
|
| 121 |
|
| 122 |
# Load model from MLflow
|
| 123 |
logged_model = 'runs:/227d2f8e431d40d6b5231add3a00d048/hate_speech_detection'
|
|
@@ -142,7 +129,7 @@ async def predict(predictionFeatures: PredictionFeatures):
|
|
| 142 |
|
| 143 |
|
| 144 |
@app.post("/preprocess", tags=["Machine Learning"])
|
| 145 |
-
async def
|
| 146 |
"""
|
| 147 |
This method will preprocess a raw tweet.This intermediate method is used as the preprocessing cannot be simply included in the prediction model
|
| 148 |
|
|
|
|
| 100 |
```
|
| 101 |
"""
|
| 102 |
|
| 103 |
+
# First preprocess the text directly
|
| 104 |
+
preprocessed_result = await preprocess_text(predictionFeatures.Text)
|
| 105 |
+
|
| 106 |
+
# Use the preprocessed text for prediction
|
| 107 |
+
list_text = [preprocessed_result['text_clean']['0']]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
# Load model from MLflow
|
| 110 |
logged_model = 'runs:/227d2f8e431d40d6b5231add3a00d048/hate_speech_detection'
|
|
|
|
| 129 |
|
| 130 |
|
| 131 |
@app.post("/preprocess", tags=["Machine Learning"])
|
| 132 |
+
async def preprocess_text(preprocessingFeatures: PreprocessingFeatures):
|
| 133 |
"""
|
| 134 |
This method will preprocess a raw tweet.This intermediate method is used as the preprocessing cannot be simply included in the prediction model
|
| 135 |
|