from fastapi import FastAPI from transformers import pipeline import numpy as np app = FastAPI(docs_url="/") def preprocess_image(image: np.ndarray): # Resize the image to a fixed size image = image.resize((224, 224)) # Normalize the image image = image / 255.0 # Return the image return image @app.post("/predict") def predict_endpoint(image: np.ndarray): # Preprocess the image image = preprocess_image(image) # Create a pipeline for image classification classifier = pipeline("andupets/real-estate-image-classification-30classes") # Classify the image result = classifier(image) # Return the classification result return result