Spaces:
Running on Zero
Running on Zero
Commit ·
4c9b328
1
Parent(s): 72953e1
fix: pipeline
Browse files- ntv3_tracks_pipeline.py +16 -7
- style.css +62 -6
ntv3_tracks_pipeline.py
CHANGED
|
@@ -331,7 +331,7 @@ class NTv3TracksPipeline(Pipeline):
|
|
| 331 |
"If passing a model module, pass tokenizer explicitly."
|
| 332 |
)
|
| 333 |
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 334 |
-
self.model_id, trust_remote_code=trust_remote_code, token=token
|
| 335 |
)
|
| 336 |
elif isinstance(tokenizer, str):
|
| 337 |
self.tokenizer = AutoTokenizer.from_pretrained(
|
|
@@ -488,14 +488,22 @@ class NTv3TracksPipeline(Pipeline):
|
|
| 488 |
def postprocess(
|
| 489 |
self, model_outputs: dict[str, Any], **kwargs: Any
|
| 490 |
) -> NTv3TracksOutput:
|
| 491 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
|
| 493 |
def to_np(x):
|
| 494 |
return x.detach().float().cpu().numpy()
|
| 495 |
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
|
|
|
| 499 |
|
| 500 |
# Normalize shapes to remove batch/(optional assembly) dims
|
| 501 |
if bigwig_np.ndim == 3:
|
|
@@ -540,8 +548,9 @@ class NTv3TracksPipeline(Pipeline):
|
|
| 540 |
input_ids=model_inputs["input_ids"],
|
| 541 |
species_ids=model_inputs["species_ids"],
|
| 542 |
)
|
| 543 |
-
|
| 544 |
-
|
|
|
|
| 545 |
|
| 546 |
def __call__(
|
| 547 |
self,
|
|
|
|
| 331 |
"If passing a model module, pass tokenizer explicitly."
|
| 332 |
)
|
| 333 |
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 334 |
+
self.model_id, trust_remote_code=trust_remote_code, token=token,
|
| 335 |
)
|
| 336 |
elif isinstance(tokenizer, str):
|
| 337 |
self.tokenizer = AutoTokenizer.from_pretrained(
|
|
|
|
| 488 |
def postprocess(
|
| 489 |
self, model_outputs: dict[str, Any], **kwargs: Any
|
| 490 |
) -> NTv3TracksOutput:
|
| 491 |
+
# Extract model_output and meta from the dict returned by _forward
|
| 492 |
+
if isinstance(model_outputs, dict) and "model_output" in model_outputs:
|
| 493 |
+
model_out = model_outputs["model_output"]
|
| 494 |
+
meta = model_outputs.get("meta", {})
|
| 495 |
+
else:
|
| 496 |
+
# Fallback for direct ModelOutput (shouldn't happen with current code)
|
| 497 |
+
model_out = model_outputs
|
| 498 |
+
meta = {}
|
| 499 |
|
| 500 |
def to_np(x):
|
| 501 |
return x.detach().float().cpu().numpy()
|
| 502 |
|
| 503 |
+
# Access model output - ModelOutput objects support both dict and attribute access
|
| 504 |
+
bigwig_np = to_np(model_out["bigwig_tracks_logits"])
|
| 505 |
+
bed_np = to_np(model_out["bed_tracks_logits"])
|
| 506 |
+
mlm_np = to_np(model_out["logits"])
|
| 507 |
|
| 508 |
# Normalize shapes to remove batch/(optional assembly) dims
|
| 509 |
if bigwig_np.ndim == 3:
|
|
|
|
| 548 |
input_ids=model_inputs["input_ids"],
|
| 549 |
species_ids=model_inputs["species_ids"],
|
| 550 |
)
|
| 551 |
+
# Return a dict containing the model output and meta separately
|
| 552 |
+
# since ModelOutput objects are immutable
|
| 553 |
+
return {"model_output": out, "meta": meta}
|
| 554 |
|
| 555 |
def __call__(
|
| 556 |
self,
|
style.css
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 2 |
:root {
|
| 3 |
--bg: #0b1020;
|
| 4 |
--card: rgba(255, 255, 255, 0.06);
|
| 5 |
-
--text: rgba(255, 255, 255, 0.
|
| 6 |
-
--muted: rgba(255, 255, 255, 0.
|
| 7 |
--link: #7dd3fc;
|
| 8 |
--border: rgba(255, 255, 255, 0.12);
|
| 9 |
--shadow: 0 10px 30px rgba(0,0,0,0.35);
|
|
@@ -12,7 +12,7 @@
|
|
| 12 |
--input-border: rgba(125, 211, 252, 0.2);
|
| 13 |
--input-focus-bg: rgba(125, 211, 252, 0.12);
|
| 14 |
--input-focus-border: rgba(125, 211, 252, 0.35);
|
| 15 |
-
--placeholder: rgba(255, 255, 255, 0.
|
| 16 |
--modebar-bg: rgba(255, 255, 255, 0.9);
|
| 17 |
}
|
| 18 |
|
|
@@ -21,8 +21,8 @@
|
|
| 21 |
:root {
|
| 22 |
--bg: #ffffff;
|
| 23 |
--card: rgba(0, 0, 0, 0.04);
|
| 24 |
-
--text: rgba(0, 0, 0, 0.
|
| 25 |
-
--muted: rgba(0, 0, 0, 0.
|
| 26 |
--link: #0369a1;
|
| 27 |
--border: rgba(0, 0, 0, 0.12);
|
| 28 |
--shadow: 0 10px 30px rgba(0,0,0,0.1);
|
|
@@ -30,7 +30,7 @@
|
|
| 30 |
--input-border: rgba(3, 105, 161, 0.2);
|
| 31 |
--input-focus-bg: rgba(3, 105, 161, 0.12);
|
| 32 |
--input-focus-border: rgba(3, 105, 161, 0.35);
|
| 33 |
-
--placeholder: rgba(0, 0, 0, 0.
|
| 34 |
--modebar-bg: rgba(255, 255, 255, 0.95);
|
| 35 |
}
|
| 36 |
}
|
|
@@ -39,6 +39,7 @@
|
|
| 39 |
body, .gradio-container {
|
| 40 |
background: var(--bg) !important;
|
| 41 |
min-height: 100vh;
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
/* Add subtle gradient only in dark mode */
|
|
@@ -51,6 +52,61 @@ body, .gradio-container {
|
|
| 51 |
}
|
| 52 |
}
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
/* Plot container */
|
| 55 |
#tracks_plot {
|
| 56 |
position: relative;
|
|
|
|
| 2 |
:root {
|
| 3 |
--bg: #0b1020;
|
| 4 |
--card: rgba(255, 255, 255, 0.06);
|
| 5 |
+
--text: rgba(255, 255, 255, 0.75);
|
| 6 |
+
--muted: rgba(255, 255, 255, 0.55);
|
| 7 |
--link: #7dd3fc;
|
| 8 |
--border: rgba(255, 255, 255, 0.12);
|
| 9 |
--shadow: 0 10px 30px rgba(0,0,0,0.35);
|
|
|
|
| 12 |
--input-border: rgba(125, 211, 252, 0.2);
|
| 13 |
--input-focus-bg: rgba(125, 211, 252, 0.12);
|
| 14 |
--input-focus-border: rgba(125, 211, 252, 0.35);
|
| 15 |
+
--placeholder: rgba(255, 255, 255, 0.4);
|
| 16 |
--modebar-bg: rgba(255, 255, 255, 0.9);
|
| 17 |
}
|
| 18 |
|
|
|
|
| 21 |
:root {
|
| 22 |
--bg: #ffffff;
|
| 23 |
--card: rgba(0, 0, 0, 0.04);
|
| 24 |
+
--text: rgba(0, 0, 0, 0.75);
|
| 25 |
+
--muted: rgba(0, 0, 0, 0.55);
|
| 26 |
--link: #0369a1;
|
| 27 |
--border: rgba(0, 0, 0, 0.12);
|
| 28 |
--shadow: 0 10px 30px rgba(0,0,0,0.1);
|
|
|
|
| 30 |
--input-border: rgba(3, 105, 161, 0.2);
|
| 31 |
--input-focus-bg: rgba(3, 105, 161, 0.12);
|
| 32 |
--input-focus-border: rgba(3, 105, 161, 0.35);
|
| 33 |
+
--placeholder: rgba(0, 0, 0, 0.4);
|
| 34 |
--modebar-bg: rgba(255, 255, 255, 0.95);
|
| 35 |
}
|
| 36 |
}
|
|
|
|
| 39 |
body, .gradio-container {
|
| 40 |
background: var(--bg) !important;
|
| 41 |
min-height: 100vh;
|
| 42 |
+
color: var(--text) !important;
|
| 43 |
}
|
| 44 |
|
| 45 |
/* Add subtle gradient only in dark mode */
|
|
|
|
| 52 |
}
|
| 53 |
}
|
| 54 |
|
| 55 |
+
/* Ensure all text elements use the correct color - default to white for dark mode */
|
| 56 |
+
body, .gradio-container {
|
| 57 |
+
color: var(--text) !important;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/* All text elements in gradio container */
|
| 61 |
+
.gradio-container *,
|
| 62 |
+
.gradio-container p,
|
| 63 |
+
.gradio-container span,
|
| 64 |
+
.gradio-container div:not([class*="plotly"]):not([class*="modebar"]),
|
| 65 |
+
.gradio-container label,
|
| 66 |
+
.gradio-container h1,
|
| 67 |
+
.gradio-container h2,
|
| 68 |
+
.gradio-container h3,
|
| 69 |
+
.gradio-container h4,
|
| 70 |
+
.gradio-container h5,
|
| 71 |
+
.gradio-container h6,
|
| 72 |
+
.gradio-container li,
|
| 73 |
+
.gradio-container td,
|
| 74 |
+
.gradio-container th {
|
| 75 |
+
color: var(--text) !important;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/* Input values and selected text */
|
| 79 |
+
.gradio-container input,
|
| 80 |
+
.gradio-container textarea,
|
| 81 |
+
.gradio-container select,
|
| 82 |
+
.gradio-container input::placeholder,
|
| 83 |
+
.gradio-container textarea::placeholder {
|
| 84 |
+
color: var(--text) !important;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/* Links */
|
| 88 |
+
.gradio-container a {
|
| 89 |
+
color: var(--link) !important;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
.gradio-container a:hover {
|
| 93 |
+
color: var(--link) !important;
|
| 94 |
+
opacity: 0.8;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/* Markdown content */
|
| 98 |
+
.gradio-container .markdown,
|
| 99 |
+
.gradio-container .markdown *,
|
| 100 |
+
.gradio-container [class*="markdown"] * {
|
| 101 |
+
color: var(--text) !important;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/* Ensure dropdown options are visible */
|
| 105 |
+
.gradio-container select option {
|
| 106 |
+
color: var(--text) !important;
|
| 107 |
+
background: var(--input-bg) !important;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
/* Plot container */
|
| 111 |
#tracks_plot {
|
| 112 |
position: relative;
|