Floki00 commited on
Commit
47a9ca5
1 Parent(s): d72cb20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -39,15 +39,16 @@ def get_correct_qcs_image(srv, num_of_qubits, max_gates, g):
39
  out_tensor = generate_srv_tensors(pipeline, f"Generate SRV: {srv}", samples=6, system_size=num_of_qubits, num_of_qubits=num_of_qubits, max_gates=max_gates, g=g)
40
  qc_list, _, svr_list = convert_tensors_to_srvs(out_tensor, pipeline.gate_pool)
41
 
42
- fig, axs = plt.subplots(3, 2, figsize=(7,20), constrained_layout=True, dpi=120)
43
  for qc,is_svr,ax in zip(qc_list, svr_list, axs.flatten()):
44
  qc.draw("mpl", plot_barriers=False, ax=ax)
45
  ax.set_title(f"{'Correct' if is_svr==srv else 'NOT correct'}, is SRV = {is_svr}")
46
 
47
- buf = io.BytesIO()
48
- fig.savefig(buf)
49
- buf.seek(0)
50
- return Image.open(buf)
 
51
 
52
  #--------------------------------
53
  # run
@@ -65,5 +66,6 @@ max_gates = col1.select_slider('Max gates', options=[4,8,12,16,20,24,28], va
65
  g = col1.slider('Guidance scale', min_value=0.0, max_value=15.0, value=7.5)
66
 
67
  if col1.button('Generate circuits'):
68
- image = get_correct_qcs_image(ast.literal_eval(srv), num_of_qubits, max_gates, g)
69
- col2.image(image, use_column_width=True)
 
 
39
  out_tensor = generate_srv_tensors(pipeline, f"Generate SRV: {srv}", samples=6, system_size=num_of_qubits, num_of_qubits=num_of_qubits, max_gates=max_gates, g=g)
40
  qc_list, _, svr_list = convert_tensors_to_srvs(out_tensor, pipeline.gate_pool)
41
 
42
+ fig, axs = plt.subplots(3, 2, figsize=(7,10), constrained_layout=True, dpi=120)
43
  for qc,is_svr,ax in zip(qc_list, svr_list, axs.flatten()):
44
  qc.draw("mpl", plot_barriers=False, ax=ax)
45
  ax.set_title(f"{'Correct' if is_svr==srv else 'NOT correct'}, is SRV = {is_svr}")
46
 
47
+ # buf = io.BytesIO()
48
+ # fig.savefig(buf)
49
+ # buf.seek(0)
50
+ # return Image.open(buf)
51
+ return fig
52
 
53
  #--------------------------------
54
  # run
 
66
  g = col1.slider('Guidance scale', min_value=0.0, max_value=15.0, value=7.5)
67
 
68
  if col1.button('Generate circuits'):
69
+ fig = get_correct_qcs_image(ast.literal_eval(srv), num_of_qubits, max_gates, g)
70
+ # col2.image(image, use_column_width=True)
71
+ col2.pyplot(fig)