Update app.py
Browse files
app.py
CHANGED
@@ -26,14 +26,17 @@ weigths_file = download(url_weights, save_destination)
|
|
26 |
#--------------------------------
|
27 |
# setup
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
except:
|
32 |
pipeline = DiffusionPipeline.from_config_file(save_destination, infer_torch_device())
|
33 |
-
pipeline.scheduler.set_timesteps(20)
|
|
|
|
|
|
|
|
|
34 |
|
35 |
is_gpu_busy = False
|
36 |
-
def
|
37 |
global is_gpu_busy
|
38 |
|
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)
|
@@ -66,6 +69,6 @@ max_gates = col1.select_slider('Max gates', options=[4,8,12,16,20,24,28], va
|
|
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 =
|
70 |
# col2.image(image, use_column_width=True)
|
71 |
col2.pyplot(fig)
|
|
|
26 |
#--------------------------------
|
27 |
# setup
|
28 |
|
29 |
+
@st.cache_resource
|
30 |
+
def load_pipeline():
|
|
|
31 |
pipeline = DiffusionPipeline.from_config_file(save_destination, infer_torch_device())
|
32 |
+
pipeline.scheduler.set_timesteps(20)
|
33 |
+
return pipeline
|
34 |
+
|
35 |
+
pipeline = load_pipeline()
|
36 |
+
|
37 |
|
38 |
is_gpu_busy = False
|
39 |
+
def get_qcs(srv, num_of_qubits, max_gates, g):
|
40 |
global is_gpu_busy
|
41 |
|
42 |
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)
|
|
|
69 |
g = col1.slider('Guidance scale', min_value=0.0, max_value=15.0, value=7.5)
|
70 |
|
71 |
if col1.button('Generate circuits'):
|
72 |
+
fig = get_qcs(ast.literal_eval(srv), num_of_qubits, max_gates, g)
|
73 |
# col2.image(image, use_column_width=True)
|
74 |
col2.pyplot(fig)
|