Devashri commited on
Commit
c343a7e
·
verified ·
1 Parent(s): d04d7b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -32,20 +32,27 @@ gamma = st.slider("Recovery Rate (γ)", min_value=0.0, max_value=1.0, value=0.1,
32
  # st.pyplot(fig)
33
  # st.success('Model executed successfully with user input and slider values.')
34
 
35
- # Call the modified run_sir_model function with user input and slider values
36
  # Call the modified run_sir_model function with user input and slider values
37
  figures = run_sir_model(total_population, initial_infected, initial_recovered, beta, gamma, mode="run")
 
38
  for fig in figures:
39
  if isinstance(fig, matplotlib.animation.FuncAnimation):
40
  st.write("Animated Plot:")
41
  fig.save('animated_plot.gif', writer='imagemagick') # Save the animated plot as a GIF
42
- st.image('animated_plot.gif') # Display the animated plot in Streamlit
 
 
 
 
43
  else:
44
  st.pyplot(fig)
45
 
46
  st.success('Model executed successfully with user input and slider values.')
47
 
48
 
 
 
 
49
  st.success('Model executed successfully with user input and slider values.')
50
 
51
  # Buttons to control the simulation
 
32
  # st.pyplot(fig)
33
  # st.success('Model executed successfully with user input and slider values.')
34
 
 
35
  # Call the modified run_sir_model function with user input and slider values
36
  figures = run_sir_model(total_population, initial_infected, initial_recovered, beta, gamma, mode="run")
37
+
38
  for fig in figures:
39
  if isinstance(fig, matplotlib.animation.FuncAnimation):
40
  st.write("Animated Plot:")
41
  fig.save('animated_plot.gif', writer='imagemagick') # Save the animated plot as a GIF
42
+ animated_plot = st.image('animated_plot.gif') # Display the animated plot in Streamlit
43
+
44
+ # Display the animated plot frame by frame
45
+ for frame in fig.new_saved_frame_seq():
46
+ animated_plot.image(frame)
47
  else:
48
  st.pyplot(fig)
49
 
50
  st.success('Model executed successfully with user input and slider values.')
51
 
52
 
53
+ st.success('Model executed successfully with user input and slider values.')
54
+
55
+
56
  st.success('Model executed successfully with user input and slider values.')
57
 
58
  # Buttons to control the simulation