Instructions to use suyagi/sains-data-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use suyagi/sains-data-model 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://suyagi/sains-data-model") - Notebooks
- Google Colab
- Kaggle
Download predict.py from suyagi/sains-data-model: direct link, hf CLI and curl.
- Browser
- Download file 729 Bytes
-
https://huggingface.co/suyagi/sains-data-model/resolve/main/predict.py
- Command line
-
hf download hf://suyagi/sains-data-model/predict.py
-
curl -L -o predict.py https://huggingface.co/suyagi/sains-data-model/resolve/main/predict.py
729 Bytes
| import tensorflow as tf | |
| import numpy as np | |
| import gradio as gr | |
| from PIL import Image | |
| # load model | |
| model = tf.keras.models.load_model("model_resnet.keras") | |
| CLASS_NAMES = ['MEL','NV','BCC','AK','BKL','DF','VASC','SCC'] | |
| def predict(image): | |
| img = image.resize((224, 224)) | |
| img = np.array(img).astype("float32") / 255.0 | |
| img = np.expand_dims(img, axis=0) | |
| pred = model.predict(img) | |
| idx = int(np.argmax(pred)) | |
| conf = float(np.max(pred)) | |
| return { | |
| "class": CLASS_NAMES[idx], | |
| "confidence": conf | |
| } | |
| iface = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Image(type="pil"), | |
| outputs="json", | |
| title="ISIC 2019 Skin Cancer Classifier API" | |
| ) | |
| iface.launch() | |