Check / app.py
Alfasign's picture
Update app.py
4377c12
raw
history blame
651 Bytes
from transformers import AutoModelForSequenceClassification, AutoTokenizer, TextClassificationPipeline
MODEL_PATH = "results/checkpoint-6000/" # Ändern Sie dies entsprechend
def load_model():
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_PATH)
pipeline = TextClassificationPipeline(model=model, tokenizer=tokenizer)
return pipeline
def classify_text(text):
pipeline = load_model()
result = pipeline(text)
return result
if __name__ == "__main__":
text = input("Geben Sie einen Text ein: ")
result = classify_text(text)
print(result)