Update website.py
Browse files- website.py +22 -3
website.py
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
|
|
|
| 3 |
from dateutil.utils import today
|
| 4 |
|
|
|
|
|
|
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def pomoch(age, gender, height, weight, ap_hi, ap_lo, cholesterol, gluc, smoke, alco, active):
|
| 7 |
X = [int(age), gender, int(height), int(weight), int(ap_hi), int(ap_lo), float(cholesterol), float(gluc), smoke,
|
| 8 |
alco, active]
|
|
@@ -31,8 +51,7 @@ def pomoch(age, gender, height, weight, ap_hi, ap_lo, cholesterol, gluc, smoke,
|
|
| 31 |
X[7] = 2
|
| 32 |
else:
|
| 33 |
X[7] = 3
|
| 34 |
-
|
| 35 |
-
# return main.webai(X)
|
| 36 |
|
| 37 |
|
| 38 |
demo = gr.Interface(
|
|
|
|
| 1 |
+
from huggingface_hub import hf_hub_download
|
| 2 |
import gradio as gr
|
| 3 |
+
import tensorflow as tf
|
| 4 |
+
import numpy as np
|
| 5 |
from dateutil.utils import today
|
| 6 |
|
| 7 |
+
model_path = hf_hub_download(repo_id="MaxJalo/CardioAI", filename="cardioai_model.keras")
|
| 8 |
+
model = tf.keras.models.load_model(model_path)
|
| 9 |
|
| 10 |
+
|
| 11 |
+
def webai(user_input):
|
| 12 |
+
user_input_clear = user_input
|
| 13 |
+
input_data = [user_input_clear]
|
| 14 |
+
input_data_scaled = (input_data - X_min) / (X_max - X_min)
|
| 15 |
+
print(input_data_scaled)
|
| 16 |
+
# Получаем предсказание от модели
|
| 17 |
+
predicted_result_scaled = model.predict(input_data_scaled)
|
| 18 |
+
print(predicted_result_scaled[0][0] * 100)
|
| 19 |
+
# 35 0 190 75 120 80 1 1 0 0 1
|
| 20 |
+
# 35 0 170 90 130 90 1 1 0 0 0
|
| 21 |
+
# 39 0 156 45 110 80 2 1 0 0 0
|
| 22 |
+
# 47 1 168 87 120 80 2 1 1 1 1
|
| 23 |
+
# 37 0 185 75 120 80 2 1 1 1 0
|
| 24 |
+
return f"{round(predicted_result_scaled[0][0] * 100, 2)}%"
|
| 25 |
+
|
| 26 |
def pomoch(age, gender, height, weight, ap_hi, ap_lo, cholesterol, gluc, smoke, alco, active):
|
| 27 |
X = [int(age), gender, int(height), int(weight), int(ap_hi), int(ap_lo), float(cholesterol), float(gluc), smoke,
|
| 28 |
alco, active]
|
|
|
|
| 51 |
X[7] = 2
|
| 52 |
else:
|
| 53 |
X[7] = 3
|
| 54 |
+
return webai(X)
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
demo = gr.Interface(
|