File size: 651 Bytes
4377c12
707e859
4377c12
707e859
4377c12
 
 
 
 
707e859
4377c12
 
 
 
707e859
4377c12
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)