Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import torch
|
| 3 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 4 |
+
|
| 5 |
+
# Başlık ve açıklama
|
| 6 |
+
st.title("Fast Detect GPT")
|
| 7 |
+
st.write("Bu uygulama, metnin yapay zeka tarafından üretilip üretilmediğini tespit eder.")
|
| 8 |
+
|
| 9 |
+
# Model ve tokenizer yükleme
|
| 10 |
+
@st.cache_resource
|
| 11 |
+
def load_model():
|
| 12 |
+
model_name = "baoguangsheng/fast-detect-gpt" # fast-detect-gpt modelinin Hugging Face modeli
|
| 13 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 14 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 15 |
+
return tokenizer, model
|
| 16 |
+
|
| 17 |
+
tokenizer, model = load_model()
|
| 18 |
+
|
| 19 |
+
# Kullanıcıdan metin alımı
|
| 20 |
+
text = st.text_area("Metni girin:", placeholder="Metni buraya yazın...")
|
| 21 |
+
|
| 22 |
+
if st.button("Tahmin Et"):
|
| 23 |
+
if not text.strip():
|
| 24 |
+
st.warning("Lütfen bir metin girin!")
|
| 25 |
+
else:
|
| 26 |
+
# Model tahmini
|
| 27 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
| 28 |
+
outputs = model(**inputs)
|
| 29 |
+
logits = outputs.logits
|
| 30 |
+
prediction = torch.argmax(logits, dim=-1).item()
|
| 31 |
+
|
| 32 |
+
# Tahmin sonucu
|
| 33 |
+
if prediction == 1:
|
| 34 |
+
st.success("Sonuç: Yapay Zeka Tarafından Üretildi")
|
| 35 |
+
else:
|
| 36 |
+
st.info("Sonuç: İnsan Tarafından Yazıldı")
|