mindexplorer commited on
Commit
82082cc
·
verified ·
1 Parent(s): 2d794a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -10
app.py CHANGED
@@ -30,21 +30,32 @@ def stream_data(value1,path,value2):
30
  for word in value2.split(" "):
31
  yield word + " "
32
  time.sleep(0.02)
33
- background_image = """
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  <style>
35
- [data-testid="stAppViewContainer"] > .main {
36
- background-image: url('Assets/cover.jpg');
37
- background-size: 100vw 100vh; # This sets the size to cover 100% of the viewport width and height
38
- background-position: center;
39
- background-repeat: no-repeat;
40
  }
41
  </style>
42
- """
43
 
44
- st.markdown(background_image, unsafe_allow_html=True)
45
-
46
- disease_classes = ['COPD','Healthy', 'Other']
47
 
 
48
 
49
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
50
  processor = AutoProcessor.from_pretrained("MIT/ast-finetuned-audioset-10-10-0.4593")
 
30
  for word in value2.split(" "):
31
  yield word + " "
32
  time.sleep(0.02)
33
+
34
+
35
+ disease_classes = ['COPD','Healthy', 'Other']
36
+ import base64
37
+
38
+ @st.cache(allow_output_mutation=True)
39
+ def get_base64_of_bin_file(bin_file):
40
+ with open(bin_file, 'rb') as f:
41
+ data = f.read()
42
+ return base64.b64encode(data).decode()
43
+
44
+ def set_png_as_page_bg(png_file):
45
+ bin_str = get_base64_of_bin_file(png_file)
46
+ page_bg_img = '''
47
  <style>
48
+ body {
49
+ background-image: url("data:image/jpg;base64,%s");
50
+ background-size: cover;
 
 
51
  }
52
  </style>
53
+ ''' % bin_str
54
 
55
+ st.markdown(page_bg_img, unsafe_allow_html=True)
56
+ return
 
57
 
58
+ set_png_as_page_bg('Assests/cover.jpg')
59
 
60
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
61
  processor = AutoProcessor.from_pretrained("MIT/ast-finetuned-audioset-10-10-0.4593")