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