Spaces:
Sleeping
Sleeping
| license: mit | |
| title: 'Structura AI: Depth & Structural Masking' | |
| sdk: docker | |
| emoji: π | |
| colorFrom: indigo | |
| colorTo: blue | |
| pinned: true | |
| app_port: 8000 | |
| # 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 | |
| This section is reserved for demo images and demo videos. | |
| Add examples such as: | |
| * Original input image | |
| * Generated structural mask | |
| * Overlay visualization | |
| * A short screen recording demonstrating the UI | |
| --- | |
| ## 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/](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 | |
| --- |