36 Commits

Author SHA1 Message Date
2637226c23 Update README.md 2025-02-15 09:49:03 +08:00
f638c5d65e Update README.md 2025-02-13 13:48:59 +08:00
6bd52ea74a Update README.md 2025-02-13 13:47:19 +08:00
4e55b325e0 feat: add "Get Cookie" button next to GitHub icon
- Introduced a new green "Get Cookie" button to the UI.
- Positioned the button to the right of the history button for easy access.
- Implemented functionality to open the URL `https://chat.qwenlm.ai` in a new tab when the button is clicked.
- Enhanced user experience by providing a direct link for users to obtain their cookie.
2025-02-13 13:15:20 +08:00
2f8f57ade7 Update README.md 2025-02-13 09:20:15 +08:00
ad532bd994 docs: update API endpoint examples 2025-02-10 12:15:24 +08:00
9c6745fcf5 docs: update API endpoint examples and usage notes 2025-02-10 12:02:12 +08:00
d7e0bf4106 docs: update API endpoint examples and usage notes 2025-02-10 11:54:33 +08:00
bee8754e24 feat: enhance API implementation and add documentation
- Added detailed comments to API endpoint implementations for clarity.
- Ensured consistent error handling across all endpoints with standardized JSON responses.
- Implemented unit tests for API endpoints to verify functionality.
- Updated constants and added comments for better understanding of parameters.
- Ensured code logic aligns with the updated README documentation.
2025-02-10 11:48:05 +08:00
f825b18d88 Update README.md 2025-02-10 10:06:48 +08:00
3f32cb4de2 fix(cookie): resolve hardcoded cookie issue (oversight fix) 2025-02-04 00:31:30 +08:00
989bb531f9 update readme about cookie 2025-02-03 15:03:19 +08:00
1c25f0d70d Update README.md 2025-02-03 14:43:38 +08:00
061d05dfe8 refactor(api): update authentication and request parameters for enhanced compatibility
- Replace token-based authentication with cookie-based authentication for improved security and usability
- Add support for chat_type field in both request body and content object to align with updated API requirements
- Ensure prompt content remains unchanged while adapting to the new interface specifications
- Update frontend interface to include a dedicated field for cookie input under Token management
This change ensures seamless integration with the updated API while maintaining backward compatibility and user experience.
2025-02-03 14:39:25 +08:00
ec554bc93a refactor(api): update authentication and request parameters for enhanced compatibility 2025-02-03 14:31:27 +08:00
77997c592e Fix some symbol issues at line 1221 2025-02-02 21:17:52 +08:00
6f6383a31f Update vision model to qwen2.5-vl-72b-instruct
- Upgraded model version to qwen2.5-vl-72b-instruct
- Updated configuration files to support the new model
- Fixed compatibility issues related to the new model
2025-01-28 07:59:11 +08:00
bfc1a28fc4 Update README.md 2025-01-25 10:29:23 +08:00
09905c0990 Merge branch 'main' of https://github.com/Cunninger/ocr-based-qwen 2025-01-24 21:17:09 +08:00
6b75d87808 Fix CORS policy issue for fetch request
- Resolved the CORS policy error when accessing 'https://chat.qwenlm.ai/api/v1/files/' from 'https://ocr.doublefenzhuan.me'.
- Added 'Access-Control-Allow-Origin' header to the server response to allow cross-origin requests.
- Alternatively, set the request mode to 'no-cors' if an opaque response is acceptable.

This change ensures that the fetch request can be made without being blocked by CORS policy restrictions.
2025-01-24 21:16:25 +08:00
c49f1d6598 Update README.md 2025-01-24 18:48:55 +08:00
8110a8b752 Update README.md 2025-01-18 14:55:26 +08:00
d8eb58b88f style: adjust layout and styling for better alignment 2025-01-18 14:54:38 +08:00
7da3c8e81b fix: display image correctly in recognition history when input from URL 2025-01-18 14:43:58 +08:00
b38a40911b chore: add github link 2025-01-18 14:34:47 +08:00
4dc33f25ba Merge branch 'main' of https://github.com/Cunninger/ocr-based-qwen 2025-01-18 14:13:34 +08:00
5a9630ca94 chore: add favicon to the website 2025-01-18 14:12:48 +08:00
9eee66ae9a Update README.md 2025-01-18 12:30:43 +08:00
235394180e Update README.md 2025-01-18 12:29:14 +08:00
87dcdd9928 Merge branch 'main' of https://github.com/Cunninger/ocr-based-qwen 2025-01-18 12:25:09 +08:00
744b544aea feat: add URL input button for image support on main interface 2025-01-18 12:24:09 +08:00
b9c1baade2 Update LICENSE 2025-01-17 15:24:11 +08:00
d1c81e7d14 Update LICENSE 2025-01-17 15:22:55 +08:00
4ba70a858f fix: resolve issue with .gitignore$ being copied in recognized content 2025-01-15 08:24:52 +08:00
5deb60c82f Update README.md 2025-01-15 07:45:56 +08:00
21e3d6c494 Update README.md 2025-01-14 20:26:14 +08:00
6 changed files with 555 additions and 158 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/

16
LICENSE
View File

@ -1,14 +1,13 @@
重要声明
由于本项目是对 QwenLM 的逆向工程实现,仅供学习和研究使用。任何商业用途或滥用行为均与作者无关。请遵守相关法律法规和平台的使用条款。
项目性质:本项目是对 QwenLM 的逆向工程实现,仅供学习和研究使用。
免责声明:任何商业用途或滥用行为均与作者无关。
法律合规:使用者需遵守相关法律法规和平台的使用条款。
开源协议 (LICENSE)
本项目采用 MIT 许可证,明确限制仅用于学习和研究目的。以下是 LICENSE 文件内容:
本项目采用 MIT 许可证,明确限制仅用于学习和研究目的。以下是 LICENSE 文件内容的补充说明
```
MIT License
Copyright (c) 2025 [cunninger]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@ -22,6 +21,8 @@ furnished to do so, subject to the following conditions:
2. The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
3. If you modify or distribute the Software, you must include a reference to the original project's open-source address: https://github.com/Cunninger/ocr-based-qwen.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -29,4 +30,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
补充说明
二次开发声明如果您对项目进行二次开发或分发必须声明本项目的开源地址https://github.com/Cunninger/ocr-based-qwen。
请确保在使用或修改本项目时遵守上述条款和条件。

106
README.md
View File

@ -1,10 +1,17 @@
# 🖼️ QwenLM OCR 逆向工程项目
<div align="center"> <img src="https://github.com/Cunninger/ocr-based-qwen/blob/main/ocr.png?raw=true" width="120"> </div>
本项目是对 [QwenLM](https://chat.qwenlm.ai/) 的 OCR 功能进行逆向工程的实现。通过调用 QwenLM 的 API你可以从图片中提取文字内容并且该项目支持一键部署到 **Cloudflare Workers** (CF) 上。
# QwenLM OCR
本项目基于 [QwenLM](https://chat.qwenlm.ai/) 。通过调用 QwenLM 的 API你可以从图片中提取文字内容并且该项目支持一键部署到 **Cloudflare Workers** (CF) 上。
## 项目展示
![image](https://github.com/user-attachments/assets/6a292a81-98e4-4f6d-8759-a310c95499b1)
![image](https://github.com/user-attachments/assets/9e794686-f914-4fb7-9931-1ada7c22bb2d)
## 测试cookie
```txt
cna=LI8HIAirQyACAWrg3cNOjH8F; _gcl_au=1.1.1200556497.1736728490; xlly_s=1; acw_tc=c2b96feb4d2929a1649ea96dc00590956477696933f61783d23e6c95429ecf74; x-ap=ap-southeast-1; token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUzZTk0Nzg4LWMwM2QtNDY4Mi05OTNhLWE0ZDNjNGUyZDY0OSIsImV4cCI6MTc0MTE0ODM0MX0.-2hF4l1iJf8r5U6UzoXyc-TFqx0i5luWmtJk0kk8T5o; ssxmod_itna=Yq+hqIxjx=AKi7eitD8IDCWBfbxxl4BtGRDeq7tDRDFqApxDHmLWxoDUxxu2hE80DD0ADnG3BUxGN4tDxiNDAg40iDC4mL37ezTxthtQQhgDCTYCu2rpTCGGE7P3rnTE0M25BA6w3KxxGLDY=DCqhxl4eD4R3Dt4DIDAYDDxDWFeGIDGYD7hb=ymbDm44aYxGy3nbDA3TDbhb5xitYDDUAKeG2igbhDDNheFY49GG7yC0OorHDAqh==GbDjqPD/RxLP+bkXtkh/CTA=BapCeaWxBQD7we3xYE4c=IdqZawfiEwDELx0De/iGKGxdYmPlvzYKGlpVGGoWDqjqQlXnlvnnPDDc=Y9=buiDrP3KYtvS85lmHQDxPoGb0rz0THimDgri0i8B0=nxNCDtYDb30eDBeIG4/g8BvDD; ssxmod_itna2=Yq+hqIxjx=AKi7eitD8IDCWBfbxxl4BtGRDeq7tDRDFqApxDHmLWxoDUxxu2hE80DD0ADnG3BDxDfk7K7e5xDLiARWCTe9A4D/9o1+WeqlSGSWe4dTPhBUq4kzjyE41MPvWM=BtDwWHWiQ4B+GVChGZYlDDoA6gCj2VGnQeqqxeBSiqeT69Cg2Q6qrEGqv/DTQR8MRo3m3E7Gd7mf42Re2lYpNic=beSRp3tCDgWT7khOXGqf2lBpre5BtExlRw6cUwWwDxNSFUl/8Un/RGZz8/jLk2t1XZC79Eb7iRTPTMPn5MTHW2fs1DlsH0z9RxCLW1Rdb2QFhd9biugr+2aTW1oeYAbtORQNMW43+m2Gcb=TuFtQGqhiTqrNfdwSOe8WHSWTr7cRaw833Yzw31d4iN+Q9OO7izUj1uSdYrh4dIvx5CwYD45Vji4EbkiaNQQGbt1hDa8Ymmda3r3lThChY8Nm2IscznS+mS43izuLzUYN94syC3tQi03=u3Q6az931moHSOLY3OFPKoMjqMUDbtebxw=rT2rBAv08uRkWHzFtGp2lUSSb3z41pTZcx/8NB3jD+XnIpLFEw8bv4r58wRLLwubFTQ9cPDv+9k36tvoCYXlso4qGA44E3y737YNBDmUct2Iahxq76iTrlGotG1NBBN=Tx4hkA2Zp887gfc4Tp8V1wGCf49XeA=0Xu3uIKqYQADh0ABmqlQ4w=YVlDPjO9KH2xaG3C8ID5DeY41AxMxR2NIGhSD+5q0UQGx0Ue4dAi0DwbY+f7n1Gwz014LQ2DY+42xI2zG5TmhfDtXehC40aWxfDi0xIGNQ3gGkYeu2fAfADwY31mkAooDxD; SERVERID=da7472215188c88fe194f138f1242089|1738557149|1738556339; SERVERCORSID=da7472215188c88fe194f138f1242089|1738557149|1738556339; isg=BBcXHLltPM7zv7hi-FnT0HW6pothXOu-LIccEmlG4eZGmDrabS7mDq_--ziGPsM2; tfstk=gxYniE986HSQfEpYpd7Icypow5otjW_5cLUReaBrbOW6JLnCehbygKjRyBdPr4XN8gtde9BlrQ9m6x3xkBOCPgkxHqIXCrTVlurzY8QNb_blTz_06LRCPaktd3lv5B9qU3M64alG7_fz8aWFTPlGZsXPz9SzQl5VQT7yU9SaQ617YJzUzRlGNOWPzaJP7jQ8r9CV1FkgVOPK4CrD_6jh3BWH9KLadGrBiO4zzFjfxtuAIzzyS6Ot3kbuo0B2c9IACduT-aANZKfDKRkGzCYBoG8ECzvDIn7G1hMuqtxy9ntPjXueswXhmFI0Zk7H4pTlAHVSGC7eCn6fYcM1seLAqtsgQvR9s9SDqpH_z9KD_djvWRUA7I-GSgozbo5IVz1ZwFr7VM51stK4FEPS3FZLvfcg0MIF16r-sfq7VM51sthisoJlY11U2
```
## 🚀 功能特性
- **图片 OCR**:使用 QwenLM 强大的 OCR 功能从图片中提取文字。
@ -14,7 +21,7 @@
- **历史记录**:保存每次识别的结果和图片,方便查看。
- **一键复制**:轻松复制识别结果到剪贴板。
- **数学公式识别**:特别优化了对数学公式的提取,支持 LaTeX 格式输出。
- **API 支持**:提供 `curl` 接口调用,支持 base64 和图片 URL 种方式。
- **API 支持**:提供 `curl` 接口调用,支持通过图片文件、base64 和图片 URL 3种方式。(Apifox调用文档示例(仅作为代码示例,尝试本地调试)https://we4q3dzb3r.apifox.cn/)
- **验证码识别**:新增验证码识别功能,支持常见类型的验证码(如数字、字母、混合字符等),提升自动化处理能力。
## 🛠️ 部署指南
@ -31,10 +38,12 @@
## 🧩 使用说明
1. **设置 Token**
- 前往 [QwenLM](https://chat.qwenlm.ai/) 获取 Token
- 点击右上角的 **⚙️ Token设置** 按钮。
- 输入你的 QwenLM API Token多个 Token 用英文逗号分隔)。
1. **设置 Cookie**
- 前往 [QwenLM](https://chat.qwenlm.ai/) 获取对话请求中的 Cookie
![alt text](image.png)
- 点击右上角的 **⚙️ Cookie设置** 按钮。
- 输入你的 Cookie或者使用测试Cookie
- 点击 **保存**
2. **上传图片**
@ -52,20 +61,22 @@
5. **API 调用**
- **支持 base64**
```bash
curl --location 'https://ocr.doublefenzhuan.me/api/recognize/base64' \
--header 'Content-Type: application/json' \
--data '{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUzZTk0Nzg4LWMwM2QtNDY4Mi05OTNhLWE0ZDNjNGUyZDY0OSIsImV4cCI6MTczOTA3NTE0MX0.FtwG6xDLYd2rngWUhuldg56WXCiLSTL0RI6xJJQ4vHM",
"base64Image": "xxx"
}'
curl -X POST \
'https://test-qwen-cor.aughumes8.workers.dev/api/recognize/base64' \
-H 'Content-Type: application/json' \
-H 'x-custom-cookie: YOUR_COOKIE_STRING' \
-d '{
"base64Image": "YOUR_BASE64_IMAGE_STRING"
}'
```
- **支持图片 URL**:
```bash
curl --location 'https://ocr.doublefenzhuan.me/api/recognize/url' \
--header 'Content-Type: application/json' \
--data '{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUzZTk0Nzg4LWMwM2QtNDY4Mi05OTNhLWE0ZDNjNGUyZDY0OSIsImV4cCI6MTczOTA3NTE0MX0.FtwG6xDLYd2rngWUhuldg56WXCiLSTL0RI6xJJQ4vHM",
"imageUrl": "xxxx"
curl -X POST \
'https://test-qwen-cor.aughumes8.workers.dev/api/recognize/url' \
-H 'Content-Type: application/json' \
-H 'x-custom-cookie: YOUR_COOKIE_STRING' \
-d '{
"imageUrl": "YOUR_IMAGE_URL"
}'
```
6. **验证码识别**
@ -110,29 +121,50 @@
### 2025/01/13 18点34分 支持`curl`接口调用
- **支持base64**
```
curl --location 'https://ocr.doublefenzhuan.me/api/recognize/base64' \
--header 'Content-Type: application/json' \
--data '{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUzZTk0Nzg4LWMwM2QtNDY4Mi05OTNhLWE0ZDNjNGUyZDY0OSIsImV4cCI6MTczOTA3NTE0MX0.FtwG6xDLYd2rngWUhuldg56WXCiLSTL0RI6xJJQ4vHM",
"base64Image": "xxx"
}'
```bash
curl -X POST \
'https://test-qwen-cor.aughumes8.workers.dev/api/recognize/base64' \
-H 'Content-Type: application/json' \
-H 'x-custom-cookie: YOUR_COOKIE_STRING' \
-d '{
"base64Image": "YOUR_BASE64_IMAGE_STRING"
}'
```
- 效果图:
![image](https://github.com/user-attachments/assets/ef160aae-e741-49d3-96f0-a0969b883f1a)
![image](https://github.com/user-attachments/assets/363afb39-444b-4308-a2bd-55831df81b6f)
- **支持图片URL**:
```bash
curl --location 'https://ocr.doublefenzhuan.me/api/recognize/url' \
--header 'Content-Type: application/json' \
--data '{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUzZTk0Nzg4LWMwM2QtNDY4Mi05OTNhLWE0ZDNjNGUyZDY0OSIsImV4cCI6MTczOTA3NTE0MX0.FtwG6xDLYd2rngWUhuldg56WXCiLSTL0RI6xJJQ4vHM",
"imageUrl": "xxxx"
}'
curl -X POST \
'https://test-qwen-cor.aughumes8.workers.dev/api/recognize/url' \
-H 'Content-Type: application/json' \
-H 'x-custom-cookie: YOUR_COOKIE_STRING' \
-d '{
"imageUrl": "YOUR_IMAGE_URL"
}'
```
- 效果图:
![image](https://github.com/user-attachments/assets/db0c89f9-96f1-45b1-b1e9-88ac3d01e196)
![image](https://github.com/user-attachments/assets/a816085e-8a52-4425-b02c-94ea543bf95b)
- **通过图片文件识别需要先上传获取imageId**
```bash
# 1. 先上传文件
curl -X POST \
'https://test-qwen-cor.aughumes8.workers.dev/proxy/upload' \
-H 'x-custom-cookie: YOUR_COOKIE_STRING' \
-F 'file=@/path/to/your/image.jpg'
# 2. 使用返回的imageId进行识别
curl -X POST \
'https://test-qwen-cor.aughumes8.workers.dev/recognize' \
-H 'Content-Type: application/json' \
-H 'x-custom-cookie: YOUR_COOKIE_STRING' \
-d '{
"imageId": "RETURNED_IMAGE_ID"
}'
```
## Cloudflare访问数据
![image](https://github.com/user-attachments/assets/bb456075-6107-47ee-a361-a0edba532c38)
## 趋势
[![Star History Chart](https://api.star-history.com/svg?repos=cunninger/ocr-based-qwen&type=Date&v=20231001)](https://star-history.com/#Cunninger/ocr-based-qwen&Date)
[![Star History Chart](https://api.star-history.com/svg?repos=cunninger/ocr-based-qwen&type=Date)](https://star-history.com/#Cunninger/ocr-based-qwen&Date)

BIN
image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 KiB

BIN
ocr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

590
worker.js

File diff suppressed because one or more lines are too long