llepogam commited on
Commit
9b6bc2c
·
1 Parent(s): 06a6509

updated call of preprocessing method

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -101,20 +101,20 @@ async def predict(predictionFeatures: PredictionFeatures):
101
  ```
102
  """
103
 
104
- # First preprocess the text directly
105
- url = "https://llepogam-hate-speech-detection-api.hf.space/preprocess"
106
- headers = {
107
- "accept": "application/json",
108
- "Content-Type": "application/json"
109
- }
110
 
111
- data = {
112
- "tweet": predictionFeatures.Text
113
- }
 
 
 
 
 
114
 
115
- response = requests.post(url, headers=headers, json=data)
116
 
117
- list_text = [response.json()['text_clean']['0']]
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'