diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index df87960..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -model/* filter=lfs diff=lfs merge=lfs -text diff --git a/aigc_check_fun.py b/aigc_check_fun.py index 6a2883c..71cc7bf 100644 --- a/aigc_check_fun.py +++ b/aigc_check_fun.py @@ -389,6 +389,7 @@ async def aigc_check(file: UploadFile,device,model,tokenizer): # 将“AIGC检测结果”插入 doc_output.paragraphs[0].insert_paragraph_before("AIGC检测结果") + doc_output.paragraphs[0].insert_paragraph_before("广告为原生存在,欢迎大家关注DragonOS开源社区,打造属于国人的开源社区") # 设置字体样式为黑体 run = doc_output.paragraphs[0].runs[0] run.font.bold = True @@ -421,15 +422,6 @@ async def aigc_check(file: UploadFile,device,model,tokenizer): # # 设置页眉居中对齐 # header_paragraph.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER - # 在末尾增加一段 - last_paragraph = doc_output.add_paragraph() - - # 在该段落中插入图片 - run = last_paragraph.add_run() - run.add_picture('static/dragonos.jpg', width=Inches(5.00), height=Inches(2.655)) - - last_paragraph.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER - doc_output.save(output_file_path) with open(output_file_path, "rb") as f: diff --git a/check.py b/check.py index 18b1d49..c3c3583 100644 --- a/check.py +++ b/check.py @@ -2,35 +2,120 @@ import requests import base64 import logging +import sys +from datetime import datetime +import tkinter as tk +from tkinter import filedialog +from tkinter import messagebox +import ctypes +import click +import subprocess -# 设置日志级别 -logging.basicConfig(level=logging.INFO) +os.system("del /q logs") -URL = "http://localhost:8000/ai_check" +logs_dir = "./logs" input_dir = "./input" output_dir = "./output" +def base_path(path): + if getattr(sys, 'frozen', None): + basedir = sys._MEIPASS + else: + basedir = os.path.dirname(__file__) + return os.path.join(basedir, path) + +tmd = base_path('') +os.chdir(tmd) + +os.makedirs(logs_dir, exist_ok=True) os.makedirs(input_dir, exist_ok=True) os.makedirs(output_dir, exist_ok=True) -# 使用os模块遍历目录 -for root, dirs, files in os.walk(input_dir): - for file in files: - if file.endswith(".docx"): - # 检查文件是否已经被处理过 - if os.path.exists(os.path.join(output_dir, file)): - logging.info(f"文件 {file} 已处理过,跳过此文件") - continue +# 生成带有时间戳的日志文件名 +log_filename = f'./logs/AIGCall-{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.log' + +# 设置日志级别 +logging.basicConfig( + filename=log_filename, + level=logging.DEBUG, + format='[%(levelname)s] - %(message)s', +) + + +class CommandLineApp: + def __init__(self, root): + self.root = root + self.root.title("TextRecogn-AIGC文字检测顾瑶分支 v1.5.b") + + # 创建文本框来模拟命令行界面 + self.text = tk.Text(root, wrap=tk.WORD, bg='black', fg='yellow', insertbackground='white', font=("微软雅黑", 20)) + self.text.pack(expand=True, fill=tk.BOTH) + + # 在文本框中插入一些行 + self.text.insert(tk.END, " 欢迎使用TextRecogn-AIGC文字检测顾瑶分支\n") + os.system("cd") + self.text.insert(tk.END, "\n") + self.text.insert(tk.END, " 请单击您要使用的服务\n") + self.text.insert(tk.END, " 1. 单文件检测\n") + self.text.insert(tk.END, " 2. 多文件检测\n") + self.text.insert(tk.END, " 3. 跳转至原作者项目Github\n") + self.text.insert(tk.END, " 4. 跳转至本项目Github\n") + self.text.insert(tk.END, " 5. 跳转至本项目介绍页\n") + + # 绑定鼠标点击事件 + self.text.bind("", self.on_click) + + def on_click(self, event): + # 获取鼠标点击的行号 + index = self.text.index("@%s,%s" % (event.x, event.y)) + line_number = int(index.split(".")[0]) + + # 根据行号执行相应操作 + if line_number == 4: + self.single_file_selection() + elif line_number == 5: + self.multi_file_selection() + elif line_number == 6: + self.goto_originauth_github() + elif line_number == 7: + self.goto_guyao_github() + elif line_number == 8: + self.goto_guyao_web() + else: + messagebox.showinfo("错误信息", "点击了其他行,请点击想要使用的服务") + + def single_file_selection(self): + # 单文件选择逻辑 + messagebox.showinfo("提示", "你选择了单文件检测,正跳转至单文件检测模块,请在接下来的窗口中选择要检测的文件") + messagebox.showinfo("提示", "检测需要时间,若30s后仍然未自动打开请重新尝试,若多次尝试均未成功,请在上一页面中找到本项目介绍页联系顾瑶") + # 跳转到check_onlyone.py + subprocess.run(["python", "./check_onlyone.py"]) + sys.exit() + + def multi_file_selection(self): + # 多文件选择逻辑 + messagebox.showinfo("提示", "你选择了多文件检测,正跳转至多文件检测模块,请在output文件夹中放入要检测的文件") + messagebox.showinfo("提示", "检测需要时间,若30s后仍然未自动打开请重新尝试,若多次尝试均未成功,请在上一页面中找到本项目介绍页联系顾瑶") + # 跳转到check_all.py + subprocess.run(["python", "./check_all.py"]) + sys.exit() - logging.info(f"开始处理文件 {file}") + def goto_originauth_github(self): + # 跳转至原作者项目Github + messagebox.showinfo("提示", "正在跳转至原作者项目Github") + os.system("start https://github.com/fslongjin/textrecogn") - input_file = os.path.join(root, file) - with open(input_file, "rb") as f: - response = requests.post(URL, files={"file": ("a.docx", f, "application/octet-stream")}) + def goto_guyao_github(self): + # 跳转至本项目Github + messagebox.showinfo("提示", "正在跳转至本项目Github") + os.system("start https://github.com/Guyao146/TextRecognAIGC-COPY") - # 将结果保存到 output_dir - output_file = os.path.join(output_dir, file) - with open(output_file, "wb") as f: - f.write(base64.b64decode(response.text)) + def goto_guyao_web(self): + # 跳转至本项目网页 + messagebox.showinfo("提示", "正在跳转至本项目介绍页") + os.system("start https://aigc.mcylyr.cn/") - logging.info(f"处理结束,结果已保存到 {output_file}") +if __name__ == "__main__": + root = tk.Tk() + app = CommandLineApp(root) + root.mainloop() \ No newline at end of file diff --git a/check_all.py b/check_all.py new file mode 100644 index 0000000..680071a --- /dev/null +++ b/check_all.py @@ -0,0 +1,87 @@ +import os +import requests +import base64 +import logging +from datetime import datetime +import tkinter as tk +from tkinter import filedialog +import time # 导入 time 模块 +import shutil +from datetime import datetime + +input_dir = "./input" +output_dir = "./output" + +os.makedirs(input_dir, exist_ok=True) +os.makedirs(output_dir, exist_ok=True) + +# 生成带有时间戳的日志文件名 +log_filename = f'./logs/AIGCall-{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.log' + +# 获取用户桌面路径 +desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop') + +# 设置日志级别 +logging.basicConfig( + filename=log_filename, + level=logging.DEBUG, + format='[%(levelname)s] - %(message)s', +) + +Custom_titles = 'TextRecogn-AIGC多文件检测' + +print("") +print("感谢使用TextRecogn项目,github地址https://github.com/fslongjin/TextRecogn") +print("") +print("日志仅保存在本地用于诊断脚本问题,不上传至服务器,请放心使用") +print("") + +logging.info('感谢使用TextRecogn项目,github地址https://github.com/fslongjin/TextRecogn') +logging.info('本日志仅保存在本地用于诊断脚本问题,不上传至服务器,请放心使用') + +URL = "http://aigc.mcylyr.cn:20000/ai_check" + +# 使用os模块遍历目录 +for root, dirs, files in os.walk(input_dir): + for file in files: + if file.endswith(".docx"): + input_file = os.path.join(root, file) + output_file = os.path.join(output_dir, file) + + # 检查文件是否已经被处理过 + if os.path.exists(output_file): + print(f"文件 {file} 已处理过,跳过此文件") + logging.info(f"文件 {file} 已处理过,跳过此文件") + continue + + logging.info(f"开始处理文件 {file}") + print(f"开始处理文件 {file}") + + with open(input_file, "rb") as f: + response = requests.post(URL, files={"file": ("a.docx", f, "application/octet-stream")}) + + # 检查网络请求是否成功 + if response.status_code != 200: + logging.error(f"网络请求失败,状态码{response.status_code} 返回信息{response.text}") + print(f"网络请求失败,状态码{response.status_code} 返回信息{response.text}") + else: + # 将结果保存到 output_dir + with open(output_file, "wb") as f: + f.write(base64.b64decode(response.text)) + + logging.info(f"处理结束,结果已保存到 {output_file}") + print(f"处理结束,结果已保存到 {output_file}") + +# 将 output 文件夹的内容复制到桌面上 +for item in os.listdir(output_dir): + s = os.path.join(output_dir, item) + d = os.path.join(desktop, item) + if os.path.isdir(s): + shutil.copytree(s, d) + else: + shutil.copy2(s, d) + +# 增加延时,确保文件操作完成 +time.sleep(1) + +print("所有文件已复制到桌面") diff --git a/check_onlyone.py b/check_onlyone.py new file mode 100644 index 0000000..a8ff038 --- /dev/null +++ b/check_onlyone.py @@ -0,0 +1,92 @@ +import os +import requests +import base64 +import logging +from datetime import datetime +import tkinter as tk +from tkinter import filedialog +import subprocess # 导入 subprocess 模块 +import shutil +import time # 导入 time 模块 + +input_dir = "./input" +output_dir = "./output" + +os.makedirs(input_dir, exist_ok=True) +os.makedirs(output_dir, exist_ok=True) + +# 生成带有时间戳的日志文件名 +log_filename = f'./logs/AIGCone-{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.log' + +# 获取用户桌面路径 +desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop') + +# 设置日志级别 +logging.basicConfig( + filename=log_filename, + level=logging.DEBUG, + format='[%(levelname)s] - %(message)s', +) + +Custom_titles = 'TextRecogn-AIGC单文件检测' + +print("") +print("感谢使用TextRecogn项目,github地址https://github.com/fslongjin/TextRecogn") +print("") +print("日志仅保存在本地用于诊断脚本问题,不上传至服务器,请放心使用") +print("") + +logging.info('感谢使用TextRecogn项目,github地址https://github.com/fslongjin/TextRecogn') +logging.info('本日志仅保存在本地用于诊断脚本问题,不上传至服务器,请放心使用') + +URL = "http://aigc.mcylyr.cn:20000/ai_check" + +def select_file(): + root = tk.Tk() + root.withdraw() # 隐藏主窗口 + file_path = filedialog.askopenfilename() # 打开文件选择对话框 + return file_path + +file_path = select_file() + +if not file_path: + print("未选择文件,返回主菜单") + logging.info("未选择文件,返回主菜单") + subprocess.run(["python", "check.py"]) # 运行主菜单脚本 + exit() # 退出当前脚本 + +logging.info(f"选择的文件是:{file_path}") +print(f"你选择的文件是:{file_path}") + +with open(file_path, "rb") as f: + response = requests.post(URL, files={"file": ("a.docx", f, "application/octet-stream")}) + + # 检查网络请求是否成功 + if response.status_code != 200: + logging.error(f"网络请求失败,状态码{response.status_code} 返回信息{response.text}") + print(f"网络请求失败,状态码{response.status_code} 返回信息{response.text}") + else: + # 将结果保存到 output_dir + output_file = os.path.join(output_dir, os.path.basename(file_path)) + with open(output_file, "wb") as f: + f.write(base64.b64decode(response.text)) + + logging.info(f"处理结束,结果已保存到 {output_file}") + print(f"处理结束,结果已保存到 {output_file}") + + # 将output文件夹的内容复制到桌面上 + for item in os.listdir(output_dir): + s = os.path.join(output_dir, item) + d = os.path.join(desktop, item) + if os.path.isdir(s): + shutil.copytree(s, d) + else: + shutil.copy2(s, d) + + destination_file_path = os.path.join(desktop, os.path.basename(output_file)) + if os.path.exists(destination_file_path): + print(f"正在打开文件:{destination_file_path}") + os.startfile(destination_file_path) + else: + print(f"文件 {destination_file_path} 不存在") + time.sleep(3) diff --git a/logo.ico b/logo.ico new file mode 100644 index 0000000..f4239a6 Binary files /dev/null and b/logo.ico differ