cd14 commited on
Commit
130b2b1
1 Parent(s): 718bbbd

bug fixing for recom_cta

Browse files
Files changed (2) hide show
  1. app.py +22 -0
  2. requirements.txt +4 -1
app.py CHANGED
@@ -19,11 +19,29 @@ from bs4 import BeautifulSoup
19
  import numpy as np
20
  import tempfile
21
  from sklearn.preprocessing import normalize
 
 
 
 
22
 
23
 
24
  CURRENT_THEME = "blue"
25
  IS_DARK_THEME = True
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  def add_bg_from_url():
28
  st.markdown(
29
  f"""
@@ -651,6 +669,10 @@ def get_predictions(selected_variable, selected_industry, selected_campaign,
651
  target_rate = random.uniform(increment - 0.02, increment)
652
  increment = target_rate - 0.001
653
  recom_cta = row[2]
 
 
 
 
654
  print(f" {(color(' ', fore='#ffffff', back=recom_cta))} \x1b[1m{round(target_rate*100, 2)}%\x1b[22m")
655
 
656
  else:
 
19
  import numpy as np
20
  import tempfile
21
  from sklearn.preprocessing import normalize
22
+ from colr import color
23
+ import cv2
24
+ from PIL import ImageColor
25
+
26
 
27
 
28
  CURRENT_THEME = "blue"
29
  IS_DARK_THEME = True
30
 
31
+
32
+ def get_rgb(color_str):
33
+ return ImageColor.getcolor(color_str, "RGB")
34
+
35
+ def create_image(width, height, rgb_color=(0, 0, 0)):
36
+ """Create new image(numpy array) filled with certain color in RGB"""
37
+ # Create black blank image
38
+ image = np.zeros((height, width, 3), np.uint8)
39
+ # Since OpenCV uses BGR, convert the color first
40
+ color = tuple(reversed(rgb_color))
41
+ # Fill image with color
42
+ image[:] = color
43
+ return image
44
+
45
  def add_bg_from_url():
46
  st.markdown(
47
  f"""
 
669
  target_rate = random.uniform(increment - 0.02, increment)
670
  increment = target_rate - 0.001
671
  recom_cta = row[2]
672
+ st.markdown('##### recom_cta is: <span style="color:yellow">{}</span>'.format(recom_cta), unsafe_allow_html=True)
673
+ st.markdown('##### target_rate for recom_cta is: <span style="color:yellow">{}</span>'.format(target_rate), unsafe_allow_html=True)
674
+
675
+
676
  print(f" {(color(' ', fore='#ffffff', back=recom_cta))} \x1b[1m{round(target_rate*100, 2)}%\x1b[22m")
677
 
678
  else:
requirements.txt CHANGED
@@ -7,4 +7,7 @@ gensim
7
  scikit-learn
8
  numpy
9
  altair<5
10
- s3fs
 
 
 
 
7
  scikit-learn
8
  numpy
9
  altair<5
10
+ s3fs
11
+ colr
12
+ opencv-python
13
+ pillow