fix:service some bug

This commit is contained in:
ext-ensky-jeremy.jj.he
2025-08-13 09:40:25 +08:00
parent ae2ba0893a
commit 7ba2ec7612

View File

@@ -1,6 +1,6 @@
import bentoml
import joblib
import re
my_image = bentoml.images.Image(python_version="3.10") \
.python_packages("scikit-learn", "numpy")
@@ -20,6 +20,7 @@ class NewsClassifierService:
def classify(self,text: str) -> dict:
categories = ['Competition News','financial news','Medical news','sports news']
cleaned_text = text.strip().replace("\n", "")
cleaned_text = re.sub(r'[\x00-\x1F]', '', cleaned_text)
token_text =self.model_vectorizer.transform([cleaned_text])
prediction = self.model_logistic.predict(token_text)
print(f"Prediction: {prediction}")