Instructions to use fatyidha/FaceShape with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use fatyidha/FaceShape 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://fatyidha/FaceShape") - Notebooks
- Google Colab
- Kaggle
Download app.py from fatyidha/FaceShape: direct link, hf CLI and curl.
- Browser
- Download file 882 Bytes
-
https://huggingface.co/fatyidha/FaceShape/resolve/main/app.py
- Command line
-
hf download hf://fatyidha/FaceShape/app.py
-
curl -L -o app.py https://huggingface.co/fatyidha/FaceShape/resolve/main/app.py
882 Bytes
| from fastapi import FastAPI, File, UploadFile | |
| import tensorflow as tf | |
| from PIL import Image | |
| import numpy as np | |
| # Model yükleme | |
| model = tf.keras.models.load_model("face_shape_model.h5") | |
| # FastAPI başlat | |
| app = FastAPI() | |
| # Görsel veriyi tahmin için işleme | |
| def preprocess_image(image): | |
| image = image.resize((224, 224)) # Model input boyutuna göre değiştir | |
| image = np.array(image) / 255.0 # Normalize et | |
| image = np.expand_dims(image, axis=0) # Batch boyutunu ekle | |
| return image | |
| async def predict(file: UploadFile = File(...)): | |
| # Dosyayı oku ve işleme | |
| image = Image.open(file.file) | |
| processed_image = preprocess_image(image) | |
| prediction = model.predict(processed_image) | |
| predicted_class = np.argmax(prediction, axis=1)[0] # En yüksek olasılıklı sınıfı al | |
| return {"predicted_class": int(predicted_class)} | |