Spaces:
Running
Running
Commit
·
c674ab7
1
Parent(s):
f64e3dc
Add all
Browse files- .gitattributes +8 -11
- README.md +35 -11
- app.py +88 -0
- requirements.txt +2 -0
.gitattributes
CHANGED
@@ -1,35 +1,32 @@
|
|
1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
4 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
|
|
6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
|
|
11 |
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
13 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
17 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
|
|
20 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
|
22 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
|
|
24 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tfevents* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.db* filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.ark* filter=lfs diff=lfs merge=lfs -text
|
30 |
+
**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
|
31 |
+
**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
|
32 |
+
**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,14 +1,38 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
---
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
domain:
|
3 |
+
- nlp
|
4 |
+
tags:
|
5 |
+
- chatgpt
|
6 |
+
# datasets:
|
7 |
+
# evaluation:
|
8 |
+
# - damotest/beans
|
9 |
+
# test:
|
10 |
+
# - damotest/squad
|
11 |
+
# train:
|
12 |
+
# - modelscope/coco_2014_caption
|
13 |
+
# models:
|
14 |
+
# - damo/speech_charctc_kws_phone-xiaoyunxiaoyun
|
15 |
+
license: Apache License 2.0
|
16 |
+
deployspec:
|
17 |
+
cpu: 4
|
18 |
+
memory: 8000
|
19 |
+
entry_file: app.py
|
20 |
+
gpu: 0
|
21 |
+
gpu_memory: 8
|
22 |
+
instance: 1
|
23 |
+
license: Apache License 2.0
|
24 |
---
|
25 |
|
26 |
+
## AIGC Text Detector 大模型AI文本检测器
|
27 |
+
|
28 |
+
3/25/2025: Our AIGC Text Detector demo is available! 🔥🔥🔥
|
29 |
+
|
30 |
+
This app is a demo of our AIGC Detector. If you are interested in our project, please keep tuned at our [GitHub](https://github.com/YuchuanTian/AIGC_text_detector) !
|
31 |
+
本app是我们AIGC检测器工作] 的一个展示。如果您对我们的工作感兴趣,欢迎在[Github主页](https://github.com/YuchuanTian/AIGC_text_detector)上持续关注我们的工作!
|
32 |
+
|
33 |
+
The loaded weights are as follows 加载的权重如下:
|
34 |
+
English: en v2
|
35 |
+
Chinese: zh v2 (one of the best Chinese AI detectors)
|
36 |
+
|
37 |
+
Acknowledgement 致谢
|
38 |
+
We sincerely thank [Hello-SimpleAI](https://huggingface.co/spaces/Hello-SimpleAI/chatgpt-detector-single) for their code.
|
app.py
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from transformers.models.bert import BertForSequenceClassification, BertTokenizer
|
4 |
+
from transformers.models.roberta import RobertaForSequenceClassification, RobertaTokenizer
|
5 |
+
|
6 |
+
# torch.set_grad_enabled(False)
|
7 |
+
|
8 |
+
name_en = "yuchuantian/AIGC_detector_env2"
|
9 |
+
model_en = RobertaForSequenceClassification.from_pretrained(name_en)
|
10 |
+
tokenizer_en = RobertaTokenizer.from_pretrained(name_en)
|
11 |
+
|
12 |
+
name_zh = "yuchuantian/AIGC_detector_zhv2"
|
13 |
+
model_zh = BertForSequenceClassification.from_pretrained(name_zh)
|
14 |
+
tokenizer_zh = BertTokenizer.from_pretrained(name_zh)
|
15 |
+
|
16 |
+
|
17 |
+
def predict_func(text: str, tokenizer, model):
|
18 |
+
with torch.no_grad():
|
19 |
+
inputs = tokenizer(text, return_tensors='pt', max_length=512, truncation=True)
|
20 |
+
outputs = model(**inputs)
|
21 |
+
scores = outputs.logits[0].softmax(0).numpy()
|
22 |
+
result = {"label": scores.argmax().item(), "score": scores.max().item()}
|
23 |
+
return result
|
24 |
+
|
25 |
+
|
26 |
+
def predict_en(text):
|
27 |
+
id2label = ['Human', 'AI']
|
28 |
+
res = predict_func(text, tokenizer_en, model_en)
|
29 |
+
return id2label[res['label']], res['score']
|
30 |
+
|
31 |
+
|
32 |
+
def predict_zh(text):
|
33 |
+
id2label = ['人类', 'AI']
|
34 |
+
res = predict_func(text, tokenizer_zh, model_zh)
|
35 |
+
return id2label[res['label']], res['score']
|
36 |
+
|
37 |
+
|
38 |
+
print(predict_en('Peking University is one of the best universities in the world.'))
|
39 |
+
|
40 |
+
print(predict_zh('很高兴认识你!'))
|
41 |
+
|
42 |
+
|
43 |
+
with gr.Blocks() as demo:
|
44 |
+
|
45 |
+
gr.Markdown("""
|
46 |
+
## AIGC Detector 大模型AI文本检测器
|
47 |
+
|
48 |
+
3/25/2025: Our AIGC Detector demo is available! 🔥🔥🔥
|
49 |
+
|
50 |
+
This app is a demo of our AIGC Detector. If you are interested in our project, please keep tuned at our [GitHub](https://github.com/YuchuanTian/AIGC_text_detector) !
|
51 |
+
本app是我们AIGC检测器工作] 的一个展示。如果您对我们的工作感兴趣,欢迎在[Github主页](https://github.com/YuchuanTian/AIGC_text_detector)上持续关注我们的工作!
|
52 |
+
|
53 |
+
The loaded weights are as follows 加载的权重如下:
|
54 |
+
English: en v2
|
55 |
+
Chinese: zh v2 (one of the best Chinese AI detectors)
|
56 |
+
|
57 |
+
Acknowledgement 致谢
|
58 |
+
We sincerely thank [Hello-SimpleAI](https://huggingface.co/spaces/Hello-SimpleAI/chatgpt-detector-single) for their code.
|
59 |
+
|
60 |
+
""")
|
61 |
+
|
62 |
+
with gr.Tab("中文"):
|
63 |
+
gr.Markdown("""
|
64 |
+
注意: 本检测器提供的结果仅供参考,应谨慎作为事实依据。
|
65 |
+
""")
|
66 |
+
t2 = gr.Textbox(lines=5, label='文本',value="北京大学建立于1898年7月3日,初名京师大学堂,辛亥革命后于1912年改为北京大学。1938年更名为国立西南联合大学。1946年10月在北平复员。1952年成为以文理学科为主的综合性大学。")
|
67 |
+
button2 = gr.Button("🚀 检测!")
|
68 |
+
label2 = gr.Textbox(lines=1, label='预测结果')
|
69 |
+
score2 = gr.Textbox(lines=1, label='模型概率')
|
70 |
+
|
71 |
+
with gr.Tab("English"):
|
72 |
+
gr.Markdown("""
|
73 |
+
Note: The results are for reference only; they could not be used as factual evidence.
|
74 |
+
""")
|
75 |
+
t1 = gr.Textbox(lines=5, label='Text',value="Originated as the Imperial University of Peking in 1898, Peking University was China's first national comprehensive university and the supreme education authority at the time. Since the founding of the People's Republic of China in 1949, it has developed into a comprehensive university with fundamental education and research in both humanities and science. The reform and opening-up of China in 1978 has ushered in a new era for the University unseen in history.")
|
76 |
+
button1 = gr.Button("🚀 Predict!")
|
77 |
+
label1 = gr.Textbox(lines=1, label='Predicted Label')
|
78 |
+
score1 = gr.Textbox(lines=1, label='Probability')
|
79 |
+
|
80 |
+
button1.click(predict_en, inputs=[t1], outputs=[label1,score1])
|
81 |
+
button2.click(predict_zh, inputs=[t2], outputs=[label2,score2])
|
82 |
+
|
83 |
+
# Page Count
|
84 |
+
gr.Markdown("""
|
85 |
+
<center><a href='https://clustrmaps.com/site/1bsdc' title='Visit tracker'><img src='//clustrmaps.com/map_v2.png?cl=080808&w=a&t=tt&d=NXQdnwxvIm27veMbB5F7oHNID09nhSvkBRZ_Aji9eIA&co=ffffff&ct=808080'/></a></center>
|
86 |
+
""")
|
87 |
+
|
88 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
transformers>=4.20,<4.26.0
|
2 |
+
torch>=1.10,<=2.0
|