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()