/floor-plan-segmentation-api

This repository contains a Flask-based API designed for managing PDF files, analyzing architectural floor plans drawn in AutoCAD, and integrating with various AI models for image segmentation, object detection, and LLMs.

Primary LanguagePython

Image Segmentation Backend Service API

Overview

This repository contains a Flask-based API for managing PDF files, analyzing architectural floor plans that drawn in AutoCAD, and interacting with various AI models. The API provides endpoints for uploading, retrieving, and deleting PDFs, as well as performing various analyses on the content of the PDFs.

Table of Contents

Features

  • Upload, retrieve, and delete PDF files.
  • Analyze architectural floor plans using AI models.
  • Extract and map descriptions from floor plan legends.
  • Summarize floor plan pages.
  • Handle user feedback and contact requests.
  • Integrate with Firebase for data storage and authentication.
  • Use OpenAI for natural language processing tasks.

Installation

  1. Clone the repository:

    git clone https://github.com/your-repo/pdf-service-api.git
    cd pdf-service-api
  2. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install the dependencies:

    pip install -r requirements.txt
  4. Set up environment variables:

    • Create a .env file in the root directory.
    • Add the necessary environment variables (refer to config.py for required variables).
  5. Run the application:

    python app.py

Configuration

Configuration settings are managed in config.py. You can set environment variables in the .env file to override default settings.

Usage

The API can be accessed at http://localhost:5000. You can use tools like Postman or cURL to interact with the endpoints.

API Endpoints

PDFs

  • GET /pdfs: Retrieve all PDFs.
  • GET /pdfs/{pdf_id}: Retrieve a specific PDF by ID.
  • GET /pdfs/base64/{pdf_id}: Retrieve a PDF's Base64-encoded content.
  • POST /pdfs: Upload a new PDF.
  • DELETE /pdfs/{pdf_id}: Delete a specific PDF by ID.
  • PUT /pdfs/update: Update an existing PDF's data.

Analyze

  • POST /analyze-legend-roboflow: Analyze the legend using the legend reading model.
  • POST /analyze-floor-plans-roboflow: Analyze floor plans using the Roboflow model.
  • POST /decide-and-process-pdf_images: Decide and process PDF images.
  • POST /analyze-electrical-plans-roboflow: Analyze electrical plans using the icon reading model.
  • POST /segment-rooms-roboflow: Analyze room plans using the Roboflow model.
  • POST /segment-rooms-unet: Analyze room plans using the UNet model.
  • POST /analyze-floor-plans: Analyze floor plans using the chat service.

Feedback

  • POST /contact-us: Save user feedback.

LLM

  • POST /analyzellm: Analyze floor plans using the LLM service.

Products

  • GET /products: Retrieve all products.
  • GET /products/{product_id}: Retrieve a product by ID.
  • POST /products: Create a new product.
  • DELETE /products/{product_id}: Delete a product by ID.
  • PUT /products/update: Update an existing product.
  • POST /products/update-prices: Update product prices by fetching from the external API.
  • GET /products/list/{object_key}: List products filtered by their object key.

Services

Models

Helpers

License

This project is licensed under the MIT License. See the LICENSE file for more details.