Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,91 +1,45 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
-
|
4 |
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
9 |
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
<div class="container-fluid">
|
15 |
-
<div class="row align-items-start">
|
16 |
-
<div class="col-md-4 col-sm-4">
|
17 |
-
<div class="position-relative">
|
18 |
-
<a href={url}><img src={thumbnail} class="img-fluid" style="width: 192px; height: 106px"></a>
|
19 |
-
</div>
|
20 |
-
</div>
|
21 |
-
<div class="col-md-8 col-sm-8">
|
22 |
-
<a href={url}>{title}</a>
|
23 |
-
<br>
|
24 |
-
<span style="color: #808080;">
|
25 |
-
<small>{context[:200].capitalize()+"...."}</small>
|
26 |
-
</span>
|
27 |
-
</div>
|
28 |
-
</div>
|
29 |
-
</div>
|
30 |
-
""",
|
31 |
-
unsafe_allow_html=True,
|
32 |
-
)
|
33 |
|
|
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
# YouTube Q&A
|
38 |
|
39 |
-
|
40 |
|
41 |
-
|
|
|
|
|
42 |
|
43 |
-
|
|
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
- GANs
|
55 |
-
- Tensorflow
|
56 |
-
"""
|
57 |
-
)
|
58 |
-
|
59 |
-
st.markdown(
|
60 |
-
"""
|
61 |
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
62 |
-
""",
|
63 |
-
unsafe_allow_html=True,
|
64 |
-
)
|
65 |
-
|
66 |
-
# Connect app to Pinecone Client
|
67 |
-
conn = st.experimental_connection(
|
68 |
-
"PineconeVectorDB",
|
69 |
-
type=PineconeConnection,
|
70 |
-
environment="us-west1-gcp-free",
|
71 |
-
api_key="1ec08295-4f82-472a-b324-f2f21663acf3",
|
72 |
-
)
|
73 |
-
cursor = conn.cursor()
|
74 |
-
|
75 |
-
retriever = init_retriever()
|
76 |
-
|
77 |
-
query_str = st.text_input("Please enter Search Query:", "")
|
78 |
-
|
79 |
-
if query_str != "":
|
80 |
-
xq = retriever.encode([query_str]).tolist()
|
81 |
-
xc = conn.query(
|
82 |
-
index_name="youtube-search", query_vector=xq, top_k=5, include_metadata=True
|
83 |
-
)
|
84 |
-
|
85 |
-
for context in xc:
|
86 |
-
card(
|
87 |
-
context["metadata"]["thumbnail"],
|
88 |
-
context["metadata"]["title"],
|
89 |
-
context["metadata"]["url"],
|
90 |
-
context["metadata"]["text"],
|
91 |
-
)
|
|
|
1 |
import streamlit as st
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
import numpy as np
|
4 |
|
5 |
+
def plot_polygon(edges, vertices):
|
6 |
+
if len(edges) != len(vertices):
|
7 |
+
st.warning("Number of edges and vertices should be the same.")
|
8 |
+
return
|
9 |
|
10 |
+
fig, ax = plt.subplots()
|
11 |
+
ax.set_aspect('equal', adjustable='box')
|
12 |
+
ax.set_title('Polygon Plot')
|
13 |
+
ax.grid(True)
|
14 |
|
15 |
+
edges = np.array(edges)
|
16 |
+
vertices = np.array(vertices)
|
17 |
|
18 |
+
for i in range(len(edges)):
|
19 |
+
ax.plot([vertices[i][0], vertices[(i + 1) % len(edges)][0]],
|
20 |
+
[vertices[i][1], vertices[(i + 1) % len(edges)][1]], 'b-')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
ax.scatter(vertices[:, 0], vertices[:, 1], color='red')
|
23 |
|
24 |
+
plt.xlim(np.min(vertices[:, 0]) - 1, np.max(vertices[:, 0]) + 1)
|
25 |
+
plt.ylim(np.min(vertices[:, 1]) - 1, np.max(vertices[:, 1]) + 1)
|
|
|
26 |
|
27 |
+
st.pyplot(fig)
|
28 |
|
29 |
+
def main():
|
30 |
+
st.title("Polygon Plotter")
|
31 |
+
st.write("Enter the number of edges and vertices for the polygon, then input the coordinates.")
|
32 |
|
33 |
+
num_edges = st.number_input("Number of Edges:", min_value=3, step=1)
|
34 |
+
vertices = []
|
35 |
|
36 |
+
for i in range(num_edges):
|
37 |
+
x = st.number_input(f"Vertex {i + 1} - x:", key=f"x{i}")
|
38 |
+
y = st.number_input(f"Vertex {i + 1} - y:", key=f"y{i}")
|
39 |
+
vertices.append((x, y))
|
40 |
|
41 |
+
if st.button("Plot Polygon"):
|
42 |
+
plot_polygon(range(num_edges), vertices)
|
43 |
|
44 |
+
if __name__ == "__main__":
|
45 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|