Spaces:
Sleeping
Sleeping
Swap Plotly prediction plot for matplotlib to rule out render freeze
Browse filesUsers reported the page freezing after inference on the default example.
Server-side inference completes fine in the logs, so the freeze is in the
browser rendering. Gradio 6.x has several reported issues with gr.Plot +
Plotly figures (heavy CUSTOM_CSS, visibility toggles) that match the
symptom. Switching to the existing matplotlib figure removes Plotly from
the suspect list; if the freeze persists we look elsewhere.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
app.py
CHANGED
|
@@ -940,14 +940,12 @@ def predict(sequence: str, stride: int = DEFAULT_STRIDE, threshold: float = DEFA
|
|
| 940 |
# User-facing coordinates are 1-based. Core inference stays 0-based.
|
| 941 |
display_positions = [pos + 1 for pos in result.positions]
|
| 942 |
|
| 943 |
-
#
|
| 944 |
-
|
| 945 |
-
|
| 946 |
-
# Create static matplotlib plot for PNG/PDF export
|
| 947 |
output_dir = make_output_dir("crispr_prediction")
|
| 948 |
-
|
| 949 |
-
png_path, pdf_path = save_figure_to_file(
|
| 950 |
-
plt.close(static_fig)
|
| 951 |
|
| 952 |
# Create CSV with prediction data
|
| 953 |
csv_path = os.path.join(output_dir, "crispr_predictions.csv")
|
|
|
|
| 940 |
# User-facing coordinates are 1-based. Core inference stays 0-based.
|
| 941 |
display_positions = [pos + 1 for pos in result.positions]
|
| 942 |
|
| 943 |
+
# Use matplotlib figure for display AND export.
|
| 944 |
+
# Plotly + Gradio 6.x + heavy CUSTOM_CSS was freezing the browser after inference;
|
| 945 |
+
# matplotlib is the boring-and-reliable fallback to rule that out.
|
|
|
|
| 946 |
output_dir = make_output_dir("crispr_prediction")
|
| 947 |
+
fig = create_prediction_plot(display_positions, result.probabilities, threshold, regions)
|
| 948 |
+
png_path, pdf_path = save_figure_to_file(fig, "crispr_prediction", output_dir)
|
|
|
|
| 949 |
|
| 950 |
# Create CSV with prediction data
|
| 951 |
csv_path = os.path.join(output_dir, "crispr_predictions.csv")
|