File size: 1,614 Bytes
7c4fac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231fa06
 
 
7c4fac8
 
 
 
 
 
 
 
 
231fa06
5e3eaea
7c4fac8
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from fastai import *
from fastcore.all import *
from fastai.vision.all import *
import pandas as pd 
import re
import gradio as gr


def get_x(data_set):
  return Path(data_set['image_path'])

def get_y(data_set):
  return data_set['bf_est']

  

def new_splitter(df):
  # Get the unique values in the 'id' column
  unique_ids = df['id'].unique()

  # Shuffle the unique values
  np.random.seed(42)
  np.random.shuffle(unique_ids)

  # Calculate the number of unique values to be included in the first dataframe
  num_unique_in_test = int(np.ceil(len(unique_ids) * 0.8))

  # Get the first 'num_unique_in_df1' unique values
  test_ids = unique_ids[:num_unique_in_test]

  # Get the rows of the original dataframe that contain the 'df1_ids'
  test = df.index[df['id'].isin(test_ids)].tolist()

  # Get the rest of the rows from the original dataframe
  valid = df.index[~df['id'].isin(test_ids)].tolist()
  
  return test, valid

title = "Body Fat Predictor"
description = "A Body Fat Predictor trained on the subreddit \"guessmybf\"."
article = "for best preformence upload a front facing photo"

learner = load_learner("bf_model.pkl")

def predict_bf(img):
  # pil_img = PILImage.create(img)
  return round(float(learner.predict(img)[1]),2)

image = gr.Image(shape=(192,192))
# label = gr.float()
intf = gr.Interface(fn =predict_bf, inputs = image, outputs = "number", title=title, description=description, article=article)
intf.launch(inline= False)

# def greet(name):
#     return "Hello " + name + "!!" + "This is version 2!!!"

# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
# iface.launch()