Spaces:
Sleeping
Sleeping
Claude commited on
Commit ·
0070798
1
Parent(s): d1665e8
feat: add step instructions to ingest, greyscale always, OCR progress indicator
Browse files- smoke_signal_tab.py +16 -16
smoke_signal_tab.py
CHANGED
|
@@ -2075,20 +2075,13 @@ def run_ocr(page_selection: str = "", page_exclusion: str = "", replace_book_que
|
|
| 2075 |
else:
|
| 2076 |
page = doc[page_num - 1]
|
| 2077 |
render_start = time.time()
|
| 2078 |
-
|
| 2079 |
-
|
| 2080 |
-
|
| 2081 |
-
|
| 2082 |
-
|
| 2083 |
-
|
| 2084 |
-
|
| 2085 |
-
else:
|
| 2086 |
-
pix = page.get_pixmap(
|
| 2087 |
-
dpi=render_dpi,
|
| 2088 |
-
alpha=False,
|
| 2089 |
-
annots=False,
|
| 2090 |
-
colorspace=fitz.csRGB,
|
| 2091 |
-
)
|
| 2092 |
render_dir = RENDERS_DIR / book_id
|
| 2093 |
render_dir.mkdir(exist_ok=True)
|
| 2094 |
render_path = render_dir / f"{book_id}_page_{page_num:04d}_{render_dpi}dpi.png"
|
|
@@ -2722,6 +2715,13 @@ def smoke_signal_tab():
|
|
| 2722 |
<div class="ss-panel-icon">📥</div>
|
| 2723 |
<div><p class="ss-panel-title">Source Registry</p>
|
| 2724 |
<p class="ss-panel-sub">Upload PDFs · Register · Auto-profile · Rights class</p></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2725 |
</div>""")
|
| 2726 |
|
| 2727 |
ingest_status = gr.HTML(_ingest_status_html("idle"))
|
|
@@ -2891,7 +2891,7 @@ def smoke_signal_tab():
|
|
| 2891 |
label="Replace existing review queue entries for processed books",
|
| 2892 |
value=True,
|
| 2893 |
)
|
| 2894 |
-
ocr_btn = gr.Button("Run OCR →", elem_classes=["ss-btn-run"])
|
| 2895 |
ocr_log = gr.Textbox(label="Log", lines=10, interactive=False, elem_classes=["ss-log"])
|
| 2896 |
ocr_copy_log_btn = gr.Button("Copy Log", size="sm")
|
| 2897 |
ocr_copy_log_btn.click(
|
|
@@ -2905,7 +2905,7 @@ def smoke_signal_tab():
|
|
| 2905 |
run_ocr,
|
| 2906 |
inputs=[ocr_page_selection, ocr_page_exclusion, ocr_replace_queue],
|
| 2907 |
outputs=[ocr_status, ocr_log],
|
| 2908 |
-
show_progress="
|
| 2909 |
trigger_mode="once",
|
| 2910 |
)
|
| 2911 |
ocr_tab.select(
|
|
|
|
| 2075 |
else:
|
| 2076 |
page = doc[page_num - 1]
|
| 2077 |
render_start = time.time()
|
| 2078 |
+
# Always render greyscale — better OCR, consistent review display
|
| 2079 |
+
pix = page.get_pixmap(
|
| 2080 |
+
dpi=render_dpi,
|
| 2081 |
+
alpha=False,
|
| 2082 |
+
annots=False,
|
| 2083 |
+
colorspace=fitz.csGRAY,
|
| 2084 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2085 |
render_dir = RENDERS_DIR / book_id
|
| 2086 |
render_dir.mkdir(exist_ok=True)
|
| 2087 |
render_path = render_dir / f"{book_id}_page_{page_num:04d}_{render_dpi}dpi.png"
|
|
|
|
| 2715 |
<div class="ss-panel-icon">📥</div>
|
| 2716 |
<div><p class="ss-panel-title">Source Registry</p>
|
| 2717 |
<p class="ss-panel-sub">Upload PDFs · Register · Auto-profile · Rights class</p></div>
|
| 2718 |
+
</div>
|
| 2719 |
+
<div style="background:#1a2535;border:1px solid #30363d;border-radius:8px;padding:14px 18px;margin:12px 0;font-size:13px;color:#8b949e;line-height:2.0">
|
| 2720 |
+
<b style="color:#e6edf3">▶ How to run OCR — follow this order:</b><br>
|
| 2721 |
+
<span style="color:#3fb950">1.</span> Drop your PDF · set <b style="color:#e6edf3">Rights Class</b> · enter <b style="color:#e6edf3">Book Code</b> + <b style="color:#e6edf3">Year</b> · click <b style="color:#f0883e">Register + Auto-Profile</b><br>
|
| 2722 |
+
<span style="color:#3fb950">2.</span> Enter <b style="color:#e6edf3">Story Pages Include</b> (e.g. 7-27) and <b style="color:#e6edf3">Story Pages Exclude</b> (e.g. 1,2,3) · click <b style="color:#f0883e">Save Book Pages</b><br>
|
| 2723 |
+
<span style="color:#3fb950">3.</span> Go to tab <b style="color:#e6edf3">③ OCR</b> · click <b style="color:#f0883e">Run OCR</b> · wait for the log to complete (may take 1-2 min)<br>
|
| 2724 |
+
<span style="color:#3fb950">4.</span> Go to tab <b style="color:#e6edf3">④ Review</b> · click <b style="color:#f0883e">↻ Load Review Queue</b> · accept / edit / reject pages
|
| 2725 |
</div>""")
|
| 2726 |
|
| 2727 |
ingest_status = gr.HTML(_ingest_status_html("idle"))
|
|
|
|
| 2891 |
label="Replace existing review queue entries for processed books",
|
| 2892 |
value=True,
|
| 2893 |
)
|
| 2894 |
+
ocr_btn = gr.Button("Run OCR →", elem_classes=["ss-btn-run"], interactive=True)
|
| 2895 |
ocr_log = gr.Textbox(label="Log", lines=10, interactive=False, elem_classes=["ss-log"])
|
| 2896 |
ocr_copy_log_btn = gr.Button("Copy Log", size="sm")
|
| 2897 |
ocr_copy_log_btn.click(
|
|
|
|
| 2905 |
run_ocr,
|
| 2906 |
inputs=[ocr_page_selection, ocr_page_exclusion, ocr_replace_queue],
|
| 2907 |
outputs=[ocr_status, ocr_log],
|
| 2908 |
+
show_progress="minimal",
|
| 2909 |
trigger_mode="once",
|
| 2910 |
)
|
| 2911 |
ocr_tab.select(
|