Spaces:
Running
Running
Upload 4 files
Browse files- README.md +35 -31
- requirements.txt +1 -1
README.md
CHANGED
@@ -1,51 +1,55 @@
|
|
1 |
-
#
|
2 |
|
3 |
-
|
4 |
|
5 |
-
##
|
6 |
|
7 |
-
-
|
8 |
-
-
|
9 |
-
-
|
10 |
-
-
|
|
|
|
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
1. 啟動應用:
|
17 |
```bash
|
18 |
python app.py
|
19 |
```
|
20 |
|
21 |
-
|
22 |
-
- `simple`:適用於文字可複製的 PDF
|
23 |
-
- `ocr`:適用於圖片 PDF 或文字亂碼
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
|
|
30 |
|
31 |
-
|
32 |
-
pip install -r requirements.txt
|
33 |
-
sudo apt install tesseract-ocr tesseract-ocr-chi-tra poppler-utils
|
34 |
-
```
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
-
##
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
├── pdf2text.py # PDF 文字擷取
|
43 |
-
├── summarize.py # 摘要產生邏輯
|
44 |
-
├── requirements.txt
|
45 |
-
├── examples/
|
46 |
-
│ └── example1.txt
|
47 |
-
```
|
48 |
|
49 |
---
|
50 |
|
51 |
-
|
|
|
1 |
+
# Document Summarization Web App
|
2 |
|
3 |
+
本專案是一個基於 Gradio 的文件摘要工具,支援 `.txt`, `.md`, 及 `.pdf` 檔案上傳與處理,具備以下特色:
|
4 |
|
5 |
+
## 🧠 功能特色
|
6 |
|
7 |
+
- ⌨️ **純文字摘要模式**:適用 `.txt` 或 `.md`,自動斷詞並進行摘要
|
8 |
+
- 🖼️ **OCR 模式 (自動切換)**:針對 `.pdf` 檔案使用 OCR 模型(Doctr)讀取文字後進行摘要
|
9 |
+
- 📑 **多模型支援**:支援多種 long document summarization 模型
|
10 |
+
- ⚙️ **可調參數**:支援 beam search, token batch size, repetition penalty 等參數設定
|
11 |
+
- 📤 **可上傳/選擇內建範例進行摘要**
|
12 |
+
- 📄 **下載摘要結果**:可將摘要輸出下載為文字檔
|
13 |
|
14 |
+
## 📁 使用方式
|
15 |
|
16 |
+
### 安裝依賴套件
|
17 |
+
|
18 |
+
```bash
|
19 |
+
pip install -r requirements.txt
|
20 |
+
```
|
21 |
+
|
22 |
+
### 執行應用程式
|
23 |
|
|
|
24 |
```bash
|
25 |
python app.py
|
26 |
```
|
27 |
|
28 |
+
### Command line 參數說明
|
|
|
|
|
29 |
|
30 |
+
| 參數 | 說明 |
|
31 |
+
|------|------|
|
32 |
+
| `--share` | 建立可分享的 public 網址 |
|
33 |
+
| `--model` | 加入自訂模型名稱 |
|
34 |
+
| `--add_beam_option` | 新增 beam 選項 |
|
35 |
+
| `--token_batch_option` | 新增 token batch 大小 |
|
36 |
+
| `--log_level` | 設定日誌等級(DEBUG/INFO/WARNING/ERROR)|
|
37 |
|
38 |
+
## 📂 範例資料夾說明
|
39 |
|
40 |
+
- 將 `.txt`、`.md`、`.pdf` 範例檔案放置於 `examples/` 資料夾內
|
41 |
+
- 啟動時自動讀取資料夾內檔案並於 UI 中顯示範例選項
|
42 |
|
43 |
+
## ✅ 支援語系
|
|
|
|
|
|
|
44 |
|
45 |
+
- 中文(含繁體)與英文文件皆可摘要
|
46 |
+
- 建議使用 OCR 模式處理掃描型 PDF
|
47 |
|
48 |
+
## 📌 備註
|
49 |
|
50 |
+
- OCR 模式預設最大讀取 20 頁(可透過環境變數 `APP_OCR_MAX_PAGES` 設定)
|
51 |
+
- OCR 使用的模型為 `doctr`,預設配置為 `"db_resnet50" + "crnn_mobilenet_v3_large"`
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
---
|
54 |
|
55 |
+
本專案修改自 [pszemraj/document-summarization](https://huggingface.co/spaces/pszemraj/document-summarization),加入多種中文處理優化與 UI 強化功能。
|
requirements.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
accelerate
|
2 |
clean-text[gpl]
|
3 |
-
gradio
|
4 |
natsort
|
5 |
nltk
|
6 |
pyspellchecker
|
|
|
1 |
accelerate
|
2 |
clean-text[gpl]
|
3 |
+
gradio>=4.28.3
|
4 |
natsort
|
5 |
nltk
|
6 |
pyspellchecker
|