Skip to content

PritamTheCoder/midas-depth-texture-mask-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Structura AI: Depth & Structural Masking Web Application

Structura AI is a web-based image analysis tool that generates a structural mask by combining monocular depth estimation and texture-based feature detection. The system integrates MiDaS (DPT-Hybrid) for depth prediction with OpenCV-based edge, corner, and texture fusion to produce a detailed, high-frequency structural representation of any input image.

This mask is useful for segmentation workflows, diffusion model conditioning, preprocessing for generative AI, architectural analysis, and general computer vision pipelines.


Features

  • MiDaS Depth Estimation: High-quality depth prediction using the DPT-Hybrid model.
  • Combined Structural Masking: Fusion of depth gradients, edges (Canny), Laplacian detail, and Harris corner responses.
  • FastAPI Backend: Clean API endpoint (POST /mask/) returning PNG masks with inference time metadata.
  • Web UI: A simple and modern interface built with HTML, CSS, and JavaScript allowing image upload, preview, overlay visualization, and mask download.
  • Docker Support: Fully dockerized and ready for deployment on services such as Hugging Face Spaces.

Demo

Live Demo on Hugging Face Spaces: Structura AI Demo

This section is reserved for demo images and demo videos. Add examples such as:


Technology Stack

Backend: FastAPI, Uvicorn AI / Computer Vision: PyTorch, MiDaS, OpenCV (headless), NumPy Frontend: HTML, CSS, JavaScript Deployment: Docker, Hugging Face Spaces


Repository Structure

structura-ai/
├── app.py
├── depth_texture_mask.py
├── requirements.txt
├── Dockerfile
├── templates/
│   └── index.html
└── static/
    ├── styles.css
    └── app.js

Local Installation and Usage

1. Clone the Repository

git clone https://github.com/PritamTheCoder/midas-depth-texture-mask-api.git
cd midas-depth-texture-mask-api

2. Create and Activate a Virtual Environment

python -m venv venv

# Windows
venv\Scripts\activate

# macOS / Linux
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Start the Application

uvicorn app:app --reload --host 0.0.0.0 --port 8000

5. Access the Web UI

Open the browser and navigate to: http://127.0.0.1:8000/

The MiDaS model weights will automatically download on the first startup.


Deployment on Hugging Face Spaces (Docker)

The project includes a Dockerfile configured for seamless deployment on Hugging Face Spaces.

Required File Structure

Ensure the following files are present at the repository root:

Dockerfile
app.py
depth_texture_mask.py
requirements.txt
templates/
static/

Deployment Steps

  1. Create a new Hugging Face Space.

  2. Select "Docker" as the runtime.

  3. Upload or commit all repository files.

  4. Hugging Face will automatically:

    • Build the Docker image
    • Install dependencies
    • Expose the correct port
    • Start the FastAPI server

The application will then be available as a hosted interactive web demo.


License

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


Acknowledgements

MiDaS by Intel-ISL FastAPI for backend framework OpenCV for feature detection and image processing PyTorch for deep learning inference support Hugging Face for deployment infrastructure


About

Depth & Structural masking fastapi and web app hosted on huggingface spaces.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published