genomenet Claude Opus 4.7 (1M context) commited on
Commit
8bea4eb
·
1 Parent(s): adb26ab

Swap Plotly prediction plot for matplotlib to rule out render freeze

Browse files

Users 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>

Files changed (1) hide show
  1. app.py +5 -7
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
- # Create interactive Plotly plot
944
- fig = create_interactive_prediction_plot(display_positions, result.probabilities, threshold, regions)
945
-
946
- # Create static matplotlib plot for PNG/PDF export
947
  output_dir = make_output_dir("crispr_prediction")
948
- static_fig = create_prediction_plot(display_positions, result.probabilities, threshold, regions)
949
- png_path, pdf_path = save_figure_to_file(static_fig, "crispr_prediction", output_dir)
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")