import streamlit as st from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch # Define label dictionary (adjust based on your data and model) label_dict = { 0: "Yanlış Anlama Değil", 1: "Yanlış Anlama", # ... other labels (add more if needed) } # Load model and tokenizer model_name = "your_model_directory" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForSequenceClassification.from_pretrained(model_name) # Select device (GPU if available) device = torch.device("cuda" if torch.cuda.is_available() else "cpu") model.to(device) # User input text = st.text_input("Yanlış anlama olup olmadığını kontrol etmek istediğiniz metni girin:") # Prediction (if text is provided) if text: inputs = tokenizer(text, return_tensors='pt').to(device) outputs = model(**inputs) logits = outputs.logits predicted_class_id = torch.argmax(logits, dim=1).item() # Handle predicted class ID if predicted_class_id in label_dict: st.write("Tahmin edilen sonuç:", label_dict[predicted_class_id]) else: st.write("Tahmin edilen sonuç:", "Model tarafından bilinmeyen bir yanlış anlama türü")