File size: 1,262 Bytes
b0184b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import streamlit as st
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

# Başlık ve açıklama
st.title("Fast Detect GPT")
st.write("Bu uygulama, metnin yapay zeka tarafından üretilip üretilmediğini tespit eder.")

# Model ve tokenizer yükleme
@st.cache_resource
def load_model():
    model_name = "baoguangsheng/fast-detect-gpt"  # fast-detect-gpt modelinin Hugging Face modeli
    tokenizer = AutoTokenizer.from_pretrained(model_name)
    model = AutoModelForSequenceClassification.from_pretrained(model_name)
    return tokenizer, model

tokenizer, model = load_model()

# Kullanıcıdan metin alımı
text = st.text_area("Metni girin:", placeholder="Metni buraya yazın...")

if st.button("Tahmin Et"):
    if not text.strip():
        st.warning("Lütfen bir metin girin!")
    else:
        # Model tahmini
        inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
        outputs = model(**inputs)
        logits = outputs.logits
        prediction = torch.argmax(logits, dim=-1).item()

        # Tahmin sonucu
        if prediction == 1:
            st.success("Sonuç: Yapay Zeka Tarafından Üretildi")
        else:
            st.info("Sonuç: İnsan Tarafından Yazıldı")