jiinkwan commited on
Commit
d359701
·
verified ·
1 Parent(s): 662a673

Upload streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +2 -18
src/streamlit_app.py CHANGED
@@ -1,13 +1,7 @@
1
  import streamlit as st
2
  import numpy as np
3
  from PIL import Image
4
- try:
5
- import cv2
6
- except ImportError as e:
7
- import subprocess
8
- subprocess.run(["apt-get", "update"])
9
- subprocess.run(["apt-get", "install", "-y", "libgl1"])
10
- import cv2
11
  import tensorflow as tf
12
  from tensorflow.keras.preprocessing.image import img_to_array
13
  from tensorflow.keras.applications.vgg19 import preprocess_input
@@ -24,18 +18,8 @@ def pearson_corr(y_true, y_pred):
24
  y = y_pred - K.mean(y_pred)
25
  return K.sum(x * y) / (K.sqrt(K.sum(K.square(x))) * K.sqrt(K.sum(K.square(y))) + K.epsilon())
26
 
27
- # === Download model
28
- import gdown
29
- url = "https://drive.google.com/file/d/1XevL2OQH6i6vTRnK7GUc49x4OD6IEFxz/view?usp=sharing" # NOT the share link
30
- output = "bmi_model_gender.keras"
31
- gdown.download(url, output, quiet=False)
32
-
33
  # === Load model and scaler ===
34
- # model = tf.keras.models.load_model("bmi_model_gender.keras", custom_objects={'pearson_corr': pearson_corr})
35
- model = tf.keras.models.load_model(
36
- output,
37
- custom_objects={'pearson_corr': pearson_corr} # Include if used
38
- )
39
  scaler = joblib.load("./label_scaler.pkl")
40
 
41
  # === Sidebar ===
 
1
  import streamlit as st
2
  import numpy as np
3
  from PIL import Image
4
+ import cv2
 
 
 
 
 
 
5
  import tensorflow as tf
6
  from tensorflow.keras.preprocessing.image import img_to_array
7
  from tensorflow.keras.applications.vgg19 import preprocess_input
 
18
  y = y_pred - K.mean(y_pred)
19
  return K.sum(x * y) / (K.sqrt(K.sum(K.square(x))) * K.sqrt(K.sum(K.square(y))) + K.epsilon())
20
 
 
 
 
 
 
 
21
  # === Load model and scaler ===
22
+ model = tf.keras.models.load_model("bmi_model_gender.keras", custom_objects={'pearson_corr': pearson_corr})
 
 
 
 
23
  scaler = joblib.load("./label_scaler.pkl")
24
 
25
  # === Sidebar ===