PeterG3 commited on
Commit
ee8d01d
·
verified ·
1 Parent(s): c9d6d9d

Upload 2 files

Browse files
Files changed (2) hide show
  1. appHF.py +52 -0
  2. model.pkl +3 -0
appHF.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pickle
3
+ import numpy as np
4
+
5
+ # Load your model (update the path to your downloaded model)
6
+ model_path = "model.pkl" # Change this to the path of your trained model
7
+ with open(model_path, 'rb') as f:
8
+ model = pickle.load(f)
9
+
10
+ # Function to make predictions
11
+ def predict_calories(age, height, weight, gender, job_type, goal):
12
+ # You can customize this function based on how you trained the model
13
+ # Convert input features into a numpy array or data structure required by the model
14
+ # Here's a basic example assuming your model expects numeric features
15
+
16
+ gender_map = {"muž": 0, "žena": 1} # Example gender encoding
17
+ job_type_map = {
18
+ 'Študent': 0,
19
+ 'Sedavé': 1,
20
+ 'Málo pohybu (do 2500 krokov)': 2,
21
+ 'Stredne pohybu (do 5000 krokov)': 3,
22
+ 'Veľa pohybu (do 10000 krokov)': 4,
23
+ }
24
+
25
+ # Prepare the input data in the format your model expects
26
+ input_data = np.array([[age, height, weight, gender_map.get(gender, 0), job_type_map.get(job_type, 0), goal]])
27
+
28
+ # Predict using the loaded model
29
+ prediction = model.predict(input_data)
30
+ return f"Recommended Daily Calories: {prediction[0]:.2f} kcal"
31
+
32
+ # Define Gradio interface
33
+ interface = gr.Interface(
34
+ fn=predict_calories,
35
+ inputs=[
36
+ gr.Slider(minimum=18, maximum=100, label="Age", default=25),
37
+ gr.Slider(minimum=120, maximum=250, label="Height (cm)", default=170),
38
+ gr.Slider(minimum=30, maximum=200, label="Weight (kg)", default=70),
39
+ gr.Radio(["muž", "žena"], label="Gender", default="muž"),
40
+ gr.Dropdown(
41
+ ["Študent", "Sedavé", "Málo pohybu (do 2500 krokov)", "Stredne pohybu (do 5000 krokov)", "Veľa pohybu (do 10000 krokov)"],
42
+ label="Job Type",
43
+ default="Sedavé"
44
+ ),
45
+ gr.Radio(["Znížiť váhu", "Udržať váhu", "Pribrať na váhe"], label="Goal", default="Udržať váhu"),
46
+ ],
47
+ outputs="text",
48
+ live=True,
49
+ )
50
+
51
+ # Launch the interface
52
+ interface.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e9e4ee8024034c9aac63f4da171baf6b0ae99792cde3100db2c90e19e0c2c36d
3
+ size 2426930