Spaces:
Runtime error
Runtime error
Andy Lau
commited on
Commit
·
95dd922
1
Parent(s):
98b85f9
wip
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import numpy as np
|
|
3 |
import pandas as pd
|
4 |
import PIL
|
5 |
import torch
|
|
|
6 |
import torchvision.transforms as transforms
|
7 |
|
8 |
import pickle
|
@@ -155,15 +156,44 @@ def read_image_from_s3(bucket, key):
|
|
155 |
|
156 |
|
157 |
# ---- Title Screen -----------
|
158 |
-
st.markdown('# Image Optimization: Email Industry')
|
159 |
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
-
col1, col2
|
|
|
|
|
163 |
|
164 |
with col2:
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
# with col2:
|
168 |
# html3 = f"""
|
169 |
# <div class="total-dc"">
|
@@ -224,9 +254,18 @@ with stats_col4:
|
|
224 |
# info_col1, info_col2, info_col3 = st.columns([1,1,1])
|
225 |
with st.sidebar:
|
226 |
with st.expander('Model Description', expanded=False):
|
|
|
|
|
227 |
st.markdown('Adding an image to an email campaign that will provide optimal engagement metrics can be challenging. How do you know which image to upload to your HTML, that will make an impact or significantly move the needle? And why would this image garner the best engagement? This model seeks to help campaign engineers understand which images affect their user engagement rate the most. The specific model is implemented using ResNet 18 and ResNet 34 for image embeddings extraction, and then we used these image embeddings as further inputs into a Gradient Boosted Tree model to generate probabilities on a user-specified target variable. The base model was adapted to car images and accurately predicted the user engagement rates with 91% accuracy. This model is adaptable for any large-scale marketing campaign using images. This model will identify the best images for optimal engagement for an email marketing campaign and serve engagement metrics prior to campaign launch. The model serves up several different images in milliseconds, so the campaign engineer understands which image to select in the campaign for optimized engagement.')
|
228 |
|
229 |
with st.expander('Model Information', expanded=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
st.table(table_data())
|
231 |
|
232 |
url_button('Model Homepage','https://www.loxz.com/#/models/IO')
|
|
|
3 |
import pandas as pd
|
4 |
import PIL
|
5 |
import torch
|
6 |
+
# import streamlit_analytics
|
7 |
import torchvision.transforms as transforms
|
8 |
|
9 |
import pickle
|
|
|
156 |
|
157 |
|
158 |
# ---- Title Screen -----------
|
|
|
159 |
|
160 |
+
def add_bg_from_url():
|
161 |
+
st.markdown(
|
162 |
+
f"""
|
163 |
+
<style>
|
164 |
+
.stApp {{
|
165 |
+
background-image: linear-gradient(#0A3144,#126072,#1C8D99);
|
166 |
+
background-attachment: fixed;
|
167 |
+
background-size: cover
|
168 |
+
}}
|
169 |
+
</style>
|
170 |
+
""",
|
171 |
+
unsafe_allow_html=True
|
172 |
+
)
|
173 |
+
|
174 |
+
|
175 |
+
st.set_page_config(layout="wide")
|
176 |
+
if 'user_counts' not in st.session_state:
|
177 |
+
st.session_state['user_counts'] = 0
|
178 |
+
|
179 |
+
add_bg_from_url()
|
180 |
+
|
181 |
+
st.session_state.user_counts +=1 # Increase usercounter
|
182 |
|
183 |
+
col1, col2 = st.columns([10,1])
|
184 |
+
with col1:
|
185 |
+
st.markdown('# Image Optimization: Email Industry')
|
186 |
|
187 |
with col2:
|
188 |
+
st.write(st.session_state.user_counts)
|
189 |
+
|
190 |
+
# image = Image.Open('figures/ModelIO.png')
|
191 |
+
|
192 |
+
# col1, col2, col3 = st.columns([1,1,1])
|
193 |
+
|
194 |
+
# with col2:
|
195 |
+
# img = PIL.Image.open('figures/IO.png')
|
196 |
+
# st.image(img)
|
197 |
# with col2:
|
198 |
# html3 = f"""
|
199 |
# <div class="total-dc"">
|
|
|
254 |
# info_col1, info_col2, info_col3 = st.columns([1,1,1])
|
255 |
with st.sidebar:
|
256 |
with st.expander('Model Description', expanded=False):
|
257 |
+
img = PIL.Image.open('figures/IO.png')
|
258 |
+
st.image(img)
|
259 |
st.markdown('Adding an image to an email campaign that will provide optimal engagement metrics can be challenging. How do you know which image to upload to your HTML, that will make an impact or significantly move the needle? And why would this image garner the best engagement? This model seeks to help campaign engineers understand which images affect their user engagement rate the most. The specific model is implemented using ResNet 18 and ResNet 34 for image embeddings extraction, and then we used these image embeddings as further inputs into a Gradient Boosted Tree model to generate probabilities on a user-specified target variable. The base model was adapted to car images and accurately predicted the user engagement rates with 91% accuracy. This model is adaptable for any large-scale marketing campaign using images. This model will identify the best images for optimal engagement for an email marketing campaign and serve engagement metrics prior to campaign launch. The model serves up several different images in milliseconds, so the campaign engineer understands which image to select in the campaign for optimized engagement.')
|
260 |
|
261 |
with st.expander('Model Information', expanded=False):
|
262 |
+
hide_table_row_index = """
|
263 |
+
<style>
|
264 |
+
thead tr th:first-child {display:none}
|
265 |
+
tbody th {display:none}
|
266 |
+
</style>
|
267 |
+
"""
|
268 |
+
st.markdown(hide_table_row_index, unsafe_allow_html=True)
|
269 |
st.table(table_data())
|
270 |
|
271 |
url_button('Model Homepage','https://www.loxz.com/#/models/IO')
|