Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import gradio as gr
|
3 |
+
import IPython
|
4 |
+
import streamlit as st
|
5 |
+
import streamlit.components.v1 as components
|
6 |
+
from IPython.display import IFrame
|
7 |
+
|
8 |
+
#quantum imports:
|
9 |
+
import qiskit
|
10 |
+
from qiskit import QuantumCircuit, QuantumRegister, execute
|
11 |
+
|
12 |
+
src='' # URL parameter to change the iframe url
|
13 |
+
|
14 |
+
def SetIframeURL(option_selected):
|
15 |
+
if (option_selected=='QCEngine'):
|
16 |
+
src='https://oreilly-qc.github.io?p=2-1'
|
17 |
+
if (option_selected=='Grok'):
|
18 |
+
src='https://javafxpert.github.io/grok-bloch/'
|
19 |
+
if (option_selected=='Playground'):
|
20 |
+
src='https://davidbkemp.github.io/quantum-gate-playground/'
|
21 |
+
if (option_selected=='Circuit'):
|
22 |
+
src='https://algassert.com/quirk#circuit={%22cols%22:[[%22H%22],[%22Bloch%22],[%22Measure%22]]}'
|
23 |
+
|
24 |
+
# Render iframe contents
|
25 |
+
#st.set_page_config(layout="wide")
|
26 |
+
width = st.sidebar.slider("Width", 200, 1500, 800, 100)
|
27 |
+
height = st.sidebar.slider("Height", 200, 1500, 900, 100)
|
28 |
+
st.components.v1.iframe(src, width, height, scrolling=True)
|
29 |
+
|
30 |
+
# query params exist
|
31 |
+
try:
|
32 |
+
options = ['QCEngine', 'Grok', 'Playground', 'Circuit']
|
33 |
+
query_params = st.experimental_get_query_params()
|
34 |
+
query_option = query_params['option'][0] #throws an exception when visiting http://host:port
|
35 |
+
option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))
|
36 |
+
if option_selected:
|
37 |
+
st.experimental_set_query_params(option=option_selected)
|
38 |
+
SetIframeURL(option_selected)
|
39 |
+
|
40 |
+
# run when query params don't exist. e.g on first launch
|
41 |
+
except: # catch exception and set query param to predefined value
|
42 |
+
options = ['QCEngine', 'Grok', 'Playground', 'Circuit']
|
43 |
+
st.experimental_set_query_params(option=options[1]) # defaults to dog
|
44 |
+
query_params = st.experimental_get_query_params()
|
45 |
+
query_option = query_params['option'][0]
|
46 |
+
option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))
|
47 |
+
if option_selected:
|
48 |
+
st.experimental_set_query_params(option=option_selected)
|
49 |
+
SetIframeURL(option_selected)
|
50 |
+
|
51 |
+
def LoadGradioAIModels():
|
52 |
+
title = "AI Quantum - QGAN and QCEngine"
|
53 |
+
description = "Using Superposition Advantage from Quantum for QGAN AI."
|
54 |
+
article = "<p style='text-align: center'></p>"
|
55 |
+
|
56 |
+
examples = [
|
57 |
+
["Scientific breakthroughs in treatment of HIV/AIDS may be solved in our lifetime using a procedure called [MASK] modulation which strengthens the immune system to fight the disease."],["A disease called [MASK] disease involves progressive memory loss and has new treatments to improve memory and delay progression of the disease."],["[MASK] refers to the uncontrolled growth of abnormal cells in the body. With chemotherapy and radiation therapy have improvements and replacements that destroy cancer cells before they become resistant to current treatment methods."],["The hereditary disease [MASK] is caused by mucus abnormally thick preventing lungs and pancreas from doing their jobs correctly."],["[MASK] or atherosclerosis is the buildup of cholesterol, fatty cells, and inflammatory deposits in the arteries. Stem cells, mechanical devices, and lowering cholesterol and blood pressure levels are helping prevention."]]
|