Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -96,7 +96,7 @@ def run_deep_learning_cascade(dna_sequence):
|
|
| 96 |
# --- LEVEL 2: LightGBM Structural Classification ---
|
| 97 |
lgb_prediction = int(lightgbm_model.predict(vector)[0])
|
| 98 |
structural_feature = FEATURE_DICT.get(lgb_prediction, "Unknown Region")
|
| 99 |
-
raw_scores["Predicted Structure"] = structural_feature
|
| 100 |
|
| 101 |
# THE CONTRADICTION RESOLVER
|
| 102 |
# The fine-tuned LightGBM overrides any contradiction during class assignment
|
|
@@ -141,7 +141,7 @@ def run_deep_learning_cascade(dna_sequence):
|
|
| 141 |
|
| 142 |
validation = "High Confidence Regulatory Element" if p_promoter >= 0.50 else "Weak Regulatory Signal"
|
| 143 |
summary_dict["Validation"] = validation
|
| 144 |
-
raw_scores["
|
| 145 |
|
| 146 |
return summary_dict, confidence, raw_scores
|
| 147 |
|
|
@@ -230,25 +230,26 @@ def gradio_inference(dna_sequence, run_mapping):
|
|
| 230 |
# Run AI Models (GPU)
|
| 231 |
summary_dict, conf, raw_scores = run_deep_learning_cascade(dna_sequence)
|
| 232 |
|
| 233 |
-
# Build Custom HTML for Stats
|
| 234 |
stats_html = """
|
| 235 |
<div style="border: 1px solid #4b5563; border-radius: 8px; padding: 15px; margin-bottom: 15px;">
|
| 236 |
-
<h3 style="margin-top: 0; margin-bottom: 10px;">Internal Pipeline Statistics</h3>
|
| 237 |
<div style="font-size: 1.15em; line-height: 1.8;">
|
| 238 |
"""
|
| 239 |
for key, val in raw_scores.items():
|
| 240 |
if isinstance(val, float):
|
| 241 |
-
|
|
|
|
| 242 |
else:
|
| 243 |
stats_html += f"{key}: <b>{val}</b><br>"
|
| 244 |
stats_html += "</div></div>"
|
| 245 |
|
| 246 |
-
# Build Custom HTML for Summary
|
| 247 |
summary_html = f"""
|
| 248 |
-
<div style="border: 1px solid #4b5563; border-radius: 8px; padding: 15px; margin-bottom:
|
| 249 |
-
<h3 style="margin-top: 0; margin-bottom: 10px;"> Classification Summary <span style="color: #
|
| 250 |
<div style="font-size: 1.15em; line-height: 1.8">
|
| 251 |
-
Final Classification: <b style="color: #
|
| 252 |
Feature: <b>{summary_dict.get('Feature')}</b><br>
|
| 253 |
"""
|
| 254 |
if "Phenotype" in summary_dict:
|
|
@@ -256,6 +257,7 @@ def gradio_inference(dna_sequence, run_mapping):
|
|
| 256 |
if "Validation" in summary_dict:
|
| 257 |
summary_html += f"Validation: <b>{summary_dict['Validation']}</b><br>"
|
| 258 |
|
|
|
|
| 259 |
summary_html += f"Confidence Score: <b style='color: #10b981;'>{conf:.2%}</b></div></div>"
|
| 260 |
|
| 261 |
if not run_mapping:
|
|
|
|
| 96 |
# --- LEVEL 2: LightGBM Structural Classification ---
|
| 97 |
lgb_prediction = int(lightgbm_model.predict(vector)[0])
|
| 98 |
structural_feature = FEATURE_DICT.get(lgb_prediction, "Unknown Region")
|
| 99 |
+
# raw_scores["Predicted Structure"] = structural_feature
|
| 100 |
|
| 101 |
# THE CONTRADICTION RESOLVER
|
| 102 |
# The fine-tuned LightGBM overrides any contradiction during class assignment
|
|
|
|
| 141 |
|
| 142 |
validation = "High Confidence Regulatory Element" if p_promoter >= 0.50 else "Weak Regulatory Signal"
|
| 143 |
summary_dict["Validation"] = validation
|
| 144 |
+
raw_scores["Promoter Signal"] = p_promoter
|
| 145 |
|
| 146 |
return summary_dict, confidence, raw_scores
|
| 147 |
|
|
|
|
| 230 |
# Run AI Models (GPU)
|
| 231 |
summary_dict, conf, raw_scores = run_deep_learning_cascade(dna_sequence)
|
| 232 |
|
| 233 |
+
# Build Custom HTML for Stats
|
| 234 |
stats_html = """
|
| 235 |
<div style="border: 1px solid #4b5563; border-radius: 8px; padding: 15px; margin-bottom: 15px;">
|
| 236 |
+
<h3 style="margin-top: 0; margin-bottom: 10px;"> Internal Pipeline Statistics</h3>
|
| 237 |
<div style="font-size: 1.15em; line-height: 1.8;">
|
| 238 |
"""
|
| 239 |
for key, val in raw_scores.items():
|
| 240 |
if isinstance(val, float):
|
| 241 |
+
# Added color: #10b981; to make all percentage scores GREEN
|
| 242 |
+
stats_html += f"{key}: <b style='color: #10b981;'>{val:.2%}</b><br>"
|
| 243 |
else:
|
| 244 |
stats_html += f"{key}: <b>{val}</b><br>"
|
| 245 |
stats_html += "</div></div>"
|
| 246 |
|
| 247 |
+
# Build Custom HTML for Summary
|
| 248 |
summary_html = f"""
|
| 249 |
+
<div style="border: 1px solid #4b5563; border-radius: 8px; padding: 15px; margin-bottom: 15px;">
|
| 250 |
+
<h3 style="margin-top: 0; margin-bottom: 10px;"> Classification Summary <span style="color: #0d6efd; font-size: 0.85em; font-weight: normal;">(Deep Scan Complete)</span></h3>
|
| 251 |
<div style="font-size: 1.15em; line-height: 1.8">
|
| 252 |
+
Final Classification: <b style="color: #10b981;">{summary_dict.get('Final Classification')}</b><br>
|
| 253 |
Feature: <b>{summary_dict.get('Feature')}</b><br>
|
| 254 |
"""
|
| 255 |
if "Phenotype" in summary_dict:
|
|
|
|
| 257 |
if "Validation" in summary_dict:
|
| 258 |
summary_html += f"Validation: <b>{summary_dict['Validation']}</b><br>"
|
| 259 |
|
| 260 |
+
# Confidence score remains green
|
| 261 |
summary_html += f"Confidence Score: <b style='color: #10b981;'>{conf:.2%}</b></div></div>"
|
| 262 |
|
| 263 |
if not run_mapping:
|