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:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://suyagi/sains-data-model") - Notebooks
- Google Colab
- Kaggle
| 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() | |