Spaces:
Sleeping
Sleeping
svlipatov
commited on
Interface main.py
Browse files
main.py
CHANGED
@@ -52,16 +52,21 @@ def load_images():
|
|
52 |
)
|
53 |
if uploaded_files is not None:
|
54 |
images = []
|
|
|
55 |
for file in uploaded_files:
|
56 |
image_data = file.getvalue()
|
57 |
-
st.image(image_data)
|
58 |
images.append(image_data)
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
return [Image.open(io.BytesIO(image_data)) for image_data in images]
|
61 |
else:
|
62 |
return None
|
63 |
|
64 |
|
|
|
65 |
# Load models
|
66 |
landmark_model = load_recognition_model()
|
67 |
summarizer, tokenizer = load_summarizer()
|
@@ -69,7 +74,7 @@ summarizer, tokenizer = load_summarizer()
|
|
69 |
st.title("Распознавание достопримечательностей")
|
70 |
|
71 |
# Images input.
|
72 |
-
images = load_images()
|
73 |
|
74 |
summarize_checkbox = st.checkbox("Короткое описание")
|
75 |
result = st.button('Распознать')
|
@@ -77,7 +82,6 @@ result = st.button('Распознать')
|
|
77 |
if images and result:
|
78 |
# Get predictions
|
79 |
names = predict_images(images, landmark_model)
|
80 |
-
st.write(names)
|
81 |
|
82 |
# Request descriptions and coordinates from Wikipedia.
|
83 |
wiki_data = getWikipedia(names)
|
@@ -88,7 +92,13 @@ if images and result:
|
|
88 |
description = landmark['summary']
|
89 |
summarized = summarize(description, summarizer, tokenizer)
|
90 |
landmark['summarized'] = summarized
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
# Draw a map.
|
94 |
-
|
|
|
|
52 |
)
|
53 |
if uploaded_files is not None:
|
54 |
images = []
|
55 |
+
cols_list = []
|
56 |
for file in uploaded_files:
|
57 |
image_data = file.getvalue()
|
|
|
58 |
images.append(image_data)
|
59 |
+
container = st.container(border=True)
|
60 |
+
cols = container.columns([1, 3])
|
61 |
+
cols[0].image(image_data, width=300)
|
62 |
+
cols_list.append(cols[1])
|
63 |
|
64 |
+
return [Image.open(io.BytesIO(image_data)) for image_data in images], cols_list
|
65 |
else:
|
66 |
return None
|
67 |
|
68 |
|
69 |
+
st.set_page_config(layout="wide")
|
70 |
# Load models
|
71 |
landmark_model = load_recognition_model()
|
72 |
summarizer, tokenizer = load_summarizer()
|
|
|
74 |
st.title("Распознавание достопримечательностей")
|
75 |
|
76 |
# Images input.
|
77 |
+
images, cols_list = load_images()
|
78 |
|
79 |
summarize_checkbox = st.checkbox("Короткое описание")
|
80 |
result = st.button('Распознать')
|
|
|
82 |
if images and result:
|
83 |
# Get predictions
|
84 |
names = predict_images(images, landmark_model)
|
|
|
85 |
|
86 |
# Request descriptions and coordinates from Wikipedia.
|
87 |
wiki_data = getWikipedia(names)
|
|
|
92 |
description = landmark['summary']
|
93 |
summarized = summarize(description, summarizer, tokenizer)
|
94 |
landmark['summarized'] = summarized
|
95 |
+
for posts, cols in zip(wiki_data, cols_list):
|
96 |
+
cols.markdown('**' + posts['find'] + '**')
|
97 |
+
if summarize_checkbox:
|
98 |
+
cols.markdown(posts['summarized'])
|
99 |
+
else:
|
100 |
+
cols.markdown(posts['summary'])
|
101 |
|
102 |
# Draw a map.
|
103 |
+
with st.container():
|
104 |
+
plot_map(wiki_data)
|