Instructions to use dini15/Skin_Type with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use dini15/Skin_Type with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://dini15/Skin_Type") - Notebooks
- Google Colab
- Kaggle
Download app.py from dini15/Skin_Type: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/dini15/Skin_Type/resolve/main/app.py
- Command line
-
hf download hf://dini15/Skin_Type/app.py
-
curl -L -o app.py https://huggingface.co/dini15/Skin_Type/resolve/main/app.py
1.52 kB
| #import libraries | |
| import pandas as pd | |
| impurt numpy as np | |
| import streamlit as st | |
| from tensorflow.keras.preprocessing.image import load_img, img_to_array | |
| from tensorflow_hub.keras_layer import KerasLayer | |
| import tensorflow as tf | |
| from tensorflow.keras.models import load_model | |
| #import pickle | |
| import pickle | |
| #load model | |
| def run(): | |
| st.image('https://i.ytimg.com/vi/Y7nGCB3S5Ww/maxresdefault.jpg', use_container_width=True) | |
| st.title("Skin Type Prediction Model") | |
| st.write("Upload an image to know your skin type!") | |
| file = st.file_uploader("Upload an image", type=["jpg", "png"]) | |
| model = load_model('model_aug.keras', custom_objects={'KerasLayer': KerasLayer}) | |
| target_size=(220, 220) | |
| def import_and_predict(image_data, model): | |
| image = load_img(image_data, target_size=(220,220)) | |
| img_array = img_to_array(image) | |
| img_array = tf.expand_dims(img_array, 0) | |
| #Normalize image | |
| img_array = img_array/255 | |
| #make prediction | |
| predictions = model.predict(img_array) | |
| #Get class with the highest possibility | |
| idx = np.where(predictions => 0.5, 1, 0).item() | |
| type = ['oily', 'dry', 'normal'] | |
| result = f'Prediction: {type[idx]}' | |
| return result | |
| if file is None: | |
| st.text("Please upload in image file") | |
| else: | |
| result = import_and_predict(file, model) | |
| st.image(file) | |
| st.write(result) | |
| if __name__ == "__main__" | |
| run |