Spaces:
Sleeping
Sleeping
Changed styling of tables for darkmode
Browse files
app.py
CHANGED
|
@@ -67,20 +67,50 @@ def _df_to_html_table(df: pd.DataFrame, title: str) -> str:
|
|
| 67 |
|
| 68 |
|
| 69 |
def _style_block() -> str:
|
| 70 |
-
#
|
| 71 |
return """
|
| 72 |
<style>
|
| 73 |
-
.tbl {
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
</style>
|
| 81 |
"""
|
| 82 |
|
| 83 |
|
|
|
|
| 84 |
def extract_tables(file_obj) -> Tuple[str, List[str], List[str], str]:
|
| 85 |
"""
|
| 86 |
Main pipeline:
|
|
@@ -287,7 +317,7 @@ def extract_tables(file_obj) -> Tuple[str, List[str], List[str], str]:
|
|
| 287 |
with gr.Blocks(title="GMFT Table Extraction PoC", theme=gr.themes.Soft()) as demo:
|
| 288 |
gr.Markdown(
|
| 289 |
"""
|
| 290 |
-
#
|
| 291 |
Upload a **text-based** PDF and extract tables to structured JSON.
|
| 292 |
The UI renders detected tables; you can also download the JSON + metrics.
|
| 293 |
"""
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
def _style_block() -> str:
|
| 70 |
+
# Dark-mode friendly CSS
|
| 71 |
return """
|
| 72 |
<style>
|
| 73 |
+
.tbl {
|
| 74 |
+
margin: 1rem 0;
|
| 75 |
+
padding: 0.5rem 0.75rem;
|
| 76 |
+
background: var(--block-background-fill);
|
| 77 |
+
border-radius: 12px;
|
| 78 |
+
color: var(--body-text-color);
|
| 79 |
+
}
|
| 80 |
+
.tbl h4 {
|
| 81 |
+
margin: 0.25rem 0 0.75rem;
|
| 82 |
+
font-weight: 600;
|
| 83 |
+
color: var(--body-text-color);
|
| 84 |
+
}
|
| 85 |
+
.tbl table {
|
| 86 |
+
border-collapse: collapse;
|
| 87 |
+
width: 100%;
|
| 88 |
+
font-size: 14px;
|
| 89 |
+
color: var(--body-text-color);
|
| 90 |
+
}
|
| 91 |
+
.tbl th, .tbl td {
|
| 92 |
+
border: 1px solid var(--border-color-primary);
|
| 93 |
+
padding: 8px;
|
| 94 |
+
vertical-align: top;
|
| 95 |
+
}
|
| 96 |
+
.tbl tr:nth-child(even) {
|
| 97 |
+
background-color: var(--background-fill-secondary);
|
| 98 |
+
}
|
| 99 |
+
.tbl th {
|
| 100 |
+
background-color: var(--background-fill-primary);
|
| 101 |
+
text-align: left;
|
| 102 |
+
color: var(--body-text-color);
|
| 103 |
+
}
|
| 104 |
+
.meta {
|
| 105 |
+
font-size: 12px;
|
| 106 |
+
color: var(--body-text-color-subdued);
|
| 107 |
+
margin-top: 0.25rem;
|
| 108 |
+
}
|
| 109 |
</style>
|
| 110 |
"""
|
| 111 |
|
| 112 |
|
| 113 |
+
|
| 114 |
def extract_tables(file_obj) -> Tuple[str, List[str], List[str], str]:
|
| 115 |
"""
|
| 116 |
Main pipeline:
|
|
|
|
| 317 |
with gr.Blocks(title="GMFT Table Extraction PoC", theme=gr.themes.Soft()) as demo:
|
| 318 |
gr.Markdown(
|
| 319 |
"""
|
| 320 |
+
# Table Extraction
|
| 321 |
Upload a **text-based** PDF and extract tables to structured JSON.
|
| 322 |
The UI renders detected tables; you can also download the JSON + metrics.
|
| 323 |
"""
|