Spaces:
Running
Running
Commit ·
0979f5c
1
Parent(s): fa0e8e1
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,174 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
import
|
| 4 |
-
import
|
| 5 |
-
from
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
gr.
|
| 139 |
-
gr.
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
-
button_classification.click(classification, inputs=[species_classification, k_classification], outputs=[text_classification, image_classification])
|
| 172 |
-
button_masking.click(masking, inputs=[species_masking, k_masking], outputs=[text_masking, image_masking])
|
| 173 |
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Pl@ntBERT's Gradio interface. Run `python app.py` for a local preview."""
|
| 2 |
+
|
| 3 |
+
import atexit
|
| 4 |
+
import csv
|
| 5 |
+
import json
|
| 6 |
+
import logging
|
| 7 |
+
import os
|
| 8 |
+
import shutil
|
| 9 |
+
import tempfile
|
| 10 |
+
import time
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
|
| 13 |
+
os.environ.setdefault("GRADIO_ANALYTICS_ENABLED", "False")
|
| 14 |
+
os.environ.setdefault("HF_HUB_OFFLINE", "1")
|
| 15 |
+
os.environ.setdefault("TOKENIZERS_PARALLELISM", "false")
|
| 16 |
+
|
| 17 |
import gradio as gr
|
| 18 |
+
|
| 19 |
+
from illustrations import render_illustration
|
| 20 |
+
from plantbert import ROOT, InputError, ModelUnavailable, TaxonomyError, run_inference
|
| 21 |
+
from presentation import (
|
| 22 |
+
ABOUT,
|
| 23 |
+
ACKNOWLEDGEMENTS,
|
| 24 |
+
CONTACT,
|
| 25 |
+
HERO,
|
| 26 |
+
empty_result,
|
| 27 |
+
error_result,
|
| 28 |
+
render_audit,
|
| 29 |
+
render_normalization,
|
| 30 |
+
render_results,
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
LOGGER = logging.getLogger(__name__)
|
| 34 |
+
EXPORT_DIRECTORY = Path(tempfile.mkdtemp(prefix="plantbert-exports-"))
|
| 35 |
+
atexit.register(shutil.rmtree, EXPORT_DIRECTORY, ignore_errors=True)
|
| 36 |
+
|
| 37 |
+
EXAMPLES = {
|
| 38 |
+
"habitat": [
|
| 39 |
+
("Tall-helophyte bed", "Phragmites australis, Lemna minor, Typha latifolia"),
|
| 40 |
+
(
|
| 41 |
+
"Fagus forest on non-acid soils",
|
| 42 |
+
"Fagus sylvatica, Prenanthes purpurea, Abies alba, Cardamine bulbifera, Orthilia secunda, Oxalis acetosella, Rubus idaeus",
|
| 43 |
+
),
|
| 44 |
+
],
|
| 45 |
+
"species": [
|
| 46 |
+
(
|
| 47 |
+
"Eryngium maritimum",
|
| 48 |
+
"Calamagrostis arenaria, Medicago marina, Pancratium maritimum, Thinopyrum junceum",
|
| 49 |
+
),
|
| 50 |
+
(
|
| 51 |
+
"Typha angustifolia",
|
| 52 |
+
"Trapa natans, Lemna minor, Phragmites australis, Sparganium erectum",
|
| 53 |
+
),
|
| 54 |
+
],
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def export_result(result: dict) -> str:
|
| 59 |
+
for old in EXPORT_DIRECTORY.glob("*"):
|
| 60 |
+
if old.stat().st_mtime < time.time() - 3600:
|
| 61 |
+
old.unlink(missing_ok=True)
|
| 62 |
+
with tempfile.NamedTemporaryFile(
|
| 63 |
+
mode="w",
|
| 64 |
+
suffix=".json",
|
| 65 |
+
prefix=f"plantbert-{result['task']}-",
|
| 66 |
+
dir=EXPORT_DIRECTORY,
|
| 67 |
+
delete=False,
|
| 68 |
+
encoding="utf-8",
|
| 69 |
+
) as handle:
|
| 70 |
+
json.dump(result, handle, ensure_ascii=False, indent=2, allow_nan=False)
|
| 71 |
+
return handle.name
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def export_csv(result):
|
| 75 |
+
with tempfile.NamedTemporaryFile(
|
| 76 |
+
mode="w",
|
| 77 |
+
suffix=".csv",
|
| 78 |
+
prefix="plantbert-results-",
|
| 79 |
+
dir=EXPORT_DIRECTORY,
|
| 80 |
+
delete=False,
|
| 81 |
+
encoding="utf-8",
|
| 82 |
+
newline="",
|
| 83 |
+
) as handle:
|
| 84 |
+
fields = [
|
| 85 |
+
"rank_or_step",
|
| 86 |
+
"code",
|
| 87 |
+
"name",
|
| 88 |
+
"model_score",
|
| 89 |
+
"final_position",
|
| 90 |
+
"normalized_input",
|
| 91 |
+
]
|
| 92 |
+
writer = csv.DictWriter(handle, fieldnames=fields)
|
| 93 |
+
writer.writeheader()
|
| 94 |
+
for rank, prediction in enumerate(result["predictions"], 1):
|
| 95 |
+
writer.writerow(
|
| 96 |
+
{
|
| 97 |
+
"rank_or_step": prediction.get("step", rank),
|
| 98 |
+
"code": prediction.get("code", ""),
|
| 99 |
+
"name": prediction.get("name", prediction.get("species", "")),
|
| 100 |
+
"model_score": prediction["score"],
|
| 101 |
+
"final_position": prediction.get("final_position", ""),
|
| 102 |
+
"normalized_input": ", ".join(result["input"]["names"]),
|
| 103 |
+
}
|
| 104 |
+
)
|
| 105 |
+
return handle.name
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def analyze(text, k, task, progress):
|
| 109 |
+
try:
|
| 110 |
+
result = run_inference(text, k, task, progress)
|
| 111 |
+
return (
|
| 112 |
+
render_results(result),
|
| 113 |
+
render_audit(result),
|
| 114 |
+
result,
|
| 115 |
+
gr.update(value=export_result(result), interactive=True),
|
| 116 |
+
gr.update(value=export_csv(result), interactive=True),
|
| 117 |
+
)
|
| 118 |
+
except (InputError, ModelUnavailable) as error:
|
| 119 |
+
audit = render_normalization(error.entries) if isinstance(error, TaxonomyError) else ""
|
| 120 |
+
return (
|
| 121 |
+
error_result(str(error)),
|
| 122 |
+
audit,
|
| 123 |
+
None,
|
| 124 |
+
gr.update(value=None, interactive=False),
|
| 125 |
+
gr.update(value=None, interactive=False),
|
| 126 |
+
)
|
| 127 |
+
except Exception:
|
| 128 |
+
LOGGER.exception("Pl@ntBERT inference failed")
|
| 129 |
+
return (
|
| 130 |
+
error_result(
|
| 131 |
+
"The model could not complete this request. Please retry with a shorter plot. "
|
| 132 |
+
"If the problem persists, contact the developer through Methods & citation."
|
| 133 |
+
),
|
| 134 |
+
"",
|
| 135 |
+
None,
|
| 136 |
+
gr.update(value=None, interactive=False),
|
| 137 |
+
gr.update(value=None, interactive=False),
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
def classify(text, k, progress=gr.Progress()): # noqa: B008 - Gradio injects this default
|
| 142 |
+
return analyze(text, k, "habitat", progress)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def complete(text, k, progress=gr.Progress()): # noqa: B008 - Gradio injects this default
|
| 146 |
+
return analyze(text, k, "species", progress)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def clear_results(task):
|
| 150 |
+
return (
|
| 151 |
+
empty_result(task),
|
| 152 |
+
"Run a prediction to review the names used by the model.",
|
| 153 |
+
None,
|
| 154 |
+
gr.update(value=None, interactive=False),
|
| 155 |
+
gr.update(value=None, interactive=False),
|
| 156 |
+
"",
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def build_task(task):
|
| 161 |
+
habitat = task == "habitat"
|
| 162 |
+
with gr.Row(equal_height=True, elem_classes="workspace"):
|
| 163 |
+
with gr.Column(scale=1, min_width=300, elem_classes=["work-panel", "input-panel"]):
|
| 164 |
+
gr.HTML('<div class="section-kicker">01 YOUR VEGETATION PLOT</div>')
|
| 165 |
+
gr.Markdown("### Which plants occur together?")
|
| 166 |
+
species = gr.Textbox(
|
| 167 |
+
label="Scientific plant names",
|
| 168 |
+
lines=4,
|
| 169 |
+
max_lines=10,
|
| 170 |
+
placeholder="Phragmites australis, Lemna minor, Typha latifolia",
|
| 171 |
+
value=EXAMPLES[task][0][1],
|
| 172 |
+
info="Separate names with commas or new lines. Order by decreasing cover when known.",
|
| 173 |
+
elem_classes="species-input",
|
| 174 |
+
)
|
| 175 |
+
gr.HTML('<p class="example-label">START WITH AN EXAMPLE</p>')
|
| 176 |
+
example_buttons = []
|
| 177 |
+
with gr.Row(elem_classes="example-buttons"):
|
| 178 |
+
for label, text in EXAMPLES[task]:
|
| 179 |
+
button = gr.Button(label, size="sm", variant="secondary")
|
| 180 |
+
example_buttons.append(button)
|
| 181 |
+
button.click(
|
| 182 |
+
lambda value=text: value,
|
| 183 |
+
outputs=species,
|
| 184 |
+
queue=False,
|
| 185 |
+
api_visibility="private",
|
| 186 |
+
)
|
| 187 |
+
k = gr.Slider(
|
| 188 |
+
1,
|
| 189 |
+
5,
|
| 190 |
+
value=3 if habitat else 1,
|
| 191 |
+
step=1,
|
| 192 |
+
label="Habitats to display" if habitat else "Species to add sequentially",
|
| 193 |
+
info="Compare the highest-scoring habitat classes."
|
| 194 |
+
if habitat
|
| 195 |
+
else "Each addition informs the next. More additions take longer.",
|
| 196 |
+
)
|
| 197 |
+
run = gr.Button(
|
| 198 |
+
"Identify habitat →" if habitat else "Suggest missing species →",
|
| 199 |
+
variant="primary",
|
| 200 |
+
elem_classes="run-button",
|
| 201 |
+
)
|
| 202 |
+
with gr.Column(scale=1, min_width=300, elem_classes=["work-panel", "output-panel"]):
|
| 203 |
+
gr.HTML('<div class="section-kicker">02 MODEL EXPLORATION</div>')
|
| 204 |
+
result = gr.HTML(empty_result(task))
|
| 205 |
+
photo = gr.HTML()
|
| 206 |
+
with gr.Column(elem_classes="record-panel"):
|
| 207 |
+
gr.HTML(
|
| 208 |
+
'<div class="section-kicker">03 CHECK NAMES & SAVE RESULTS</div>'
|
| 209 |
+
'<p class="record-intro">Review the species used, then take your results with you.</p>'
|
| 210 |
)
|
| 211 |
+
audit = gr.HTML("Run a prediction to review the names used by the model.")
|
| 212 |
+
with gr.Row(elem_classes="download-row"):
|
| 213 |
+
csv_download = gr.DownloadButton(
|
| 214 |
+
"Download results · CSV", interactive=False, variant="primary"
|
| 215 |
+
)
|
| 216 |
+
download = gr.DownloadButton("Download full record · JSON", interactive=False)
|
| 217 |
+
with gr.Accordion(
|
| 218 |
+
"Scientific record · settings, name checks & checkpoint provenance", open=False
|
| 219 |
+
):
|
| 220 |
+
record = gr.JSON(label="Reproducibility record", value=None)
|
| 221 |
+
outputs = [result, audit, record, download, csv_download]
|
| 222 |
+
controls = [species, k, run, *example_buttons]
|
| 223 |
+
run.click(
|
| 224 |
+
lambda: [gr.update(interactive=False) for _ in controls],
|
| 225 |
+
outputs=controls,
|
| 226 |
+
queue=False,
|
| 227 |
+
api_visibility="private",
|
| 228 |
+
).then(
|
| 229 |
+
classify if habitat else complete,
|
| 230 |
+
inputs=[species, k],
|
| 231 |
+
outputs=outputs,
|
| 232 |
+
api_name="classify_habitat" if habitat else "suggest_species",
|
| 233 |
+
concurrency_limit=1,
|
| 234 |
+
concurrency_id="plantbert-cpu",
|
| 235 |
+
trigger_mode="once",
|
| 236 |
+
).then(
|
| 237 |
+
render_illustration,
|
| 238 |
+
inputs=record,
|
| 239 |
+
outputs=photo,
|
| 240 |
+
concurrency_id="illustrations",
|
| 241 |
+
concurrency_limit=4,
|
| 242 |
+
api_visibility="private",
|
| 243 |
+
).then(
|
| 244 |
+
lambda: [gr.update(interactive=True) for _ in controls],
|
| 245 |
+
outputs=controls,
|
| 246 |
+
queue=False,
|
| 247 |
+
api_visibility="private",
|
| 248 |
+
)
|
| 249 |
+
for component in (species, k):
|
| 250 |
+
component.change(
|
| 251 |
+
lambda: clear_results(task),
|
| 252 |
+
outputs=[*outputs, photo],
|
| 253 |
+
queue=False,
|
| 254 |
+
api_visibility="private",
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
def build_demo():
|
| 259 |
+
with gr.Blocks(
|
| 260 |
+
title="Pl@ntBERT · Plant community explorer",
|
| 261 |
+
analytics_enabled=False,
|
| 262 |
+
delete_cache=(3600, 3600),
|
| 263 |
+
) as demo:
|
| 264 |
+
with gr.Row(elem_classes="theme-toolbar"):
|
| 265 |
+
theme_toggle = gr.Button("Dark mode", size="sm", elem_id="theme-toggle")
|
| 266 |
+
demo.load(fn=None, js=(ROOT / "assets/theme.js").read_text(), queue=False)
|
| 267 |
+
theme_toggle.click(
|
| 268 |
+
fn=None,
|
| 269 |
+
js=(ROOT / "assets/theme-change.js").read_text(),
|
| 270 |
+
queue=False,
|
| 271 |
+
)
|
| 272 |
+
gr.HTML(HERO)
|
| 273 |
+
with gr.Tabs(elem_id="task-tabs"):
|
| 274 |
+
with gr.Tab("Identify a habitat", id="habitat"):
|
| 275 |
+
build_task("habitat")
|
| 276 |
+
with gr.Tab("Find missing species", id="species"):
|
| 277 |
+
build_task("species")
|
| 278 |
+
with gr.Tab("Methods & citation", id="methods"):
|
| 279 |
+
gr.Markdown(ABOUT, elem_classes="methods")
|
| 280 |
+
gr.HTML(ACKNOWLEDGEMENTS, elem_classes="methods-funding")
|
| 281 |
+
with gr.Accordion(
|
| 282 |
+
"Contact the developer", open=False, elem_classes="contact-accordion"
|
| 283 |
+
):
|
| 284 |
+
gr.HTML(CONTACT)
|
| 285 |
+
gr.HTML(
|
| 286 |
+
'<footer class="research-footer"><span><strong>Pl@ntBERT</strong> · Learning the syntax of plant assemblages</span>'
|
| 287 |
+
"<span>Research demo / Interpret with ecological context</span></footer>"
|
| 288 |
+
)
|
| 289 |
+
return demo.queue(max_size=12, default_concurrency_limit=1)
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
THEME = gr.themes.Base(
|
| 293 |
+
primary_hue="emerald",
|
| 294 |
+
secondary_hue="stone",
|
| 295 |
+
neutral_hue="stone",
|
| 296 |
+
font=["Inter", "ui-sans-serif", "system-ui", "sans-serif"],
|
| 297 |
+
font_mono=["ui-monospace", "monospace"],
|
| 298 |
+
radius_size="lg",
|
| 299 |
+
).set(
|
| 300 |
+
body_background_fill="#f8f9f5",
|
| 301 |
+
body_background_fill_dark="#14241f",
|
| 302 |
+
body_text_color="#203c32",
|
| 303 |
+
body_text_color_dark="#e2ede6",
|
| 304 |
+
block_background_fill="#ffffff",
|
| 305 |
+
block_background_fill_dark="#1c3028",
|
| 306 |
+
block_border_color="#dce5dd",
|
| 307 |
+
block_border_color_dark="#3c5146",
|
| 308 |
+
button_primary_background_fill="#24664d",
|
| 309 |
+
button_primary_background_fill_hover="#184b38",
|
| 310 |
+
button_primary_text_color="#ffffff",
|
| 311 |
+
button_primary_border_color="#24664d",
|
| 312 |
+
button_primary_background_fill_dark="#79b99a",
|
| 313 |
+
button_primary_text_color_dark="#10271d",
|
| 314 |
+
button_secondary_background_fill="#f1f5ee",
|
| 315 |
+
button_secondary_background_fill_dark="#263e32",
|
| 316 |
+
input_background_fill="#fbfcf9",
|
| 317 |
+
input_background_fill_dark="#14271e",
|
| 318 |
+
input_border_color="#cfdbd0",
|
| 319 |
+
input_border_color_focus="#327557",
|
| 320 |
+
block_shadow="none",
|
| 321 |
+
block_title_text_weight="500",
|
| 322 |
+
)
|
| 323 |
|
|
|
|
|
|
|
| 324 |
|
| 325 |
+
if __name__ == "__main__":
|
| 326 |
+
build_demo().launch(
|
| 327 |
+
theme=THEME,
|
| 328 |
+
css_paths=[ROOT / "assets" / "style.css"],
|
| 329 |
+
server_name="0.0.0.0" if os.environ.get("SPACE_ID") else "127.0.0.1",
|
| 330 |
+
server_port=int(os.environ.get("PORT", "7860")),
|
| 331 |
+
share=False,
|
| 332 |
+
ssr_mode=False,
|
| 333 |
+
footer_links=[],
|
| 334 |
+
show_error=False,
|
| 335 |
+
)
|