Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,149 +1,159 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
Structura AI
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
*
|
| 26 |
-
*
|
| 27 |
-
*
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
#
|
| 87 |
-
|
| 88 |
-
```
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
---
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
title: 'Structura AI: Depth & Structural Masking'
|
| 4 |
+
sdk: docker
|
| 5 |
+
emoji: π
|
| 6 |
+
colorFrom: indigo
|
| 7 |
+
colorTo: blue
|
| 8 |
+
pinned: true
|
| 9 |
+
app_port: 8000
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Structura AI: Depth & Structural Masking Web Application
|
| 13 |
+
|
| 14 |
+
Structura AI is a web-based image analysis tool that generates a structural mask by combining monocular depth estimation and texture-based feature detection.
|
| 15 |
+
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.
|
| 16 |
+
|
| 17 |
+
This mask is useful for segmentation workflows, diffusion model conditioning, preprocessing for generative AI, architectural analysis, and general computer vision pipelines.
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## Features
|
| 22 |
+
|
| 23 |
+
* MiDaS Depth Estimation: High-quality depth prediction using the DPT-Hybrid model.
|
| 24 |
+
* Combined Structural Masking: Fusion of depth gradients, edges (Canny), Laplacian detail, and Harris corner responses.
|
| 25 |
+
* FastAPI Backend: Clean API endpoint (`POST /mask/`) returning PNG masks with inference time metadata.
|
| 26 |
+
* Web UI: A simple and modern interface built with HTML, CSS, and JavaScript allowing image upload, preview, overlay visualization, and mask download.
|
| 27 |
+
* Docker Support: Fully dockerized and ready for deployment on services such as Hugging Face Spaces.
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## Demo
|
| 32 |
+
|
| 33 |
+
This section is reserved for demo images and demo videos.
|
| 34 |
+
Add examples such as:
|
| 35 |
+
|
| 36 |
+
* Original input image
|
| 37 |
+
* Generated structural mask
|
| 38 |
+
* Overlay visualization
|
| 39 |
+
* A short screen recording demonstrating the UI
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## Technology Stack
|
| 44 |
+
|
| 45 |
+
Backend: FastAPI, Uvicorn
|
| 46 |
+
AI / Computer Vision: PyTorch, MiDaS, OpenCV (headless), NumPy
|
| 47 |
+
Frontend: HTML, CSS, JavaScript
|
| 48 |
+
Deployment: Docker, Hugging Face Spaces
|
| 49 |
+
|
| 50 |
+
---
|
| 51 |
+
|
| 52 |
+
## Repository Structure
|
| 53 |
+
|
| 54 |
+
```
|
| 55 |
+
structura-ai/
|
| 56 |
+
βββ app.py
|
| 57 |
+
βββ depth_texture_mask.py
|
| 58 |
+
βββ requirements.txt
|
| 59 |
+
βββ Dockerfile
|
| 60 |
+
βββ templates/
|
| 61 |
+
β βββ index.html
|
| 62 |
+
βββ static/
|
| 63 |
+
βββ styles.css
|
| 64 |
+
βββ app.js
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## Local Installation and Usage
|
| 70 |
+
|
| 71 |
+
### 1. Clone the Repository
|
| 72 |
+
|
| 73 |
+
```
|
| 74 |
+
git clone https://github.com/PritamTheCoder/midas-depth-texture-mask-api.git
|
| 75 |
+
cd midas-depth-texture-mask-api
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
### 2. Create and Activate a Virtual Environment
|
| 79 |
+
|
| 80 |
+
```
|
| 81 |
+
python -m venv venv
|
| 82 |
+
|
| 83 |
+
# Windows
|
| 84 |
+
venv\Scripts\activate
|
| 85 |
+
|
| 86 |
+
# macOS / Linux
|
| 87 |
+
source venv/bin/activate
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### 3. Install Dependencies
|
| 91 |
+
|
| 92 |
+
```
|
| 93 |
+
pip install -r requirements.txt
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
### 4. Start the Application
|
| 97 |
+
|
| 98 |
+
```
|
| 99 |
+
uvicorn app:app --reload --host 0.0.0.0 --port 8000
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
### 5. Access the Web UI
|
| 103 |
+
|
| 104 |
+
Open the browser and navigate to:
|
| 105 |
+
[http://127.0.0.1:8000/](http://127.0.0.1:8000/)
|
| 106 |
+
|
| 107 |
+
The MiDaS model weights will automatically download on the first startup.
|
| 108 |
+
|
| 109 |
+
---
|
| 110 |
+
|
| 111 |
+
## Deployment on Hugging Face Spaces (Docker)
|
| 112 |
+
|
| 113 |
+
The project includes a Dockerfile configured for seamless deployment on Hugging Face Spaces.
|
| 114 |
+
|
| 115 |
+
### Required File Structure
|
| 116 |
+
|
| 117 |
+
Ensure the following files are present at the repository root:
|
| 118 |
+
|
| 119 |
+
```
|
| 120 |
+
Dockerfile
|
| 121 |
+
app.py
|
| 122 |
+
depth_texture_mask.py
|
| 123 |
+
requirements.txt
|
| 124 |
+
templates/
|
| 125 |
+
static/
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
### Deployment Steps
|
| 129 |
+
|
| 130 |
+
1. Create a new Hugging Face Space.
|
| 131 |
+
2. Select "Docker" as the runtime.
|
| 132 |
+
3. Upload or commit all repository files.
|
| 133 |
+
4. Hugging Face will automatically:
|
| 134 |
+
|
| 135 |
+
* Build the Docker image
|
| 136 |
+
* Install dependencies
|
| 137 |
+
* Expose the correct port
|
| 138 |
+
* Start the FastAPI server
|
| 139 |
+
|
| 140 |
+
The application will then be available as a hosted interactive web demo.
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
## License
|
| 145 |
+
|
| 146 |
+
This project is licensed under the MIT License.
|
| 147 |
+
See the LICENSE file for details.
|
| 148 |
+
|
| 149 |
+
---
|
| 150 |
+
|
| 151 |
+
## Acknowledgements
|
| 152 |
+
|
| 153 |
+
MiDaS by Intel-ISL
|
| 154 |
+
FastAPI for backend framework
|
| 155 |
+
OpenCV for feature detection and image processing
|
| 156 |
+
PyTorch for deep learning inference support
|
| 157 |
+
Hugging Face for deployment infrastructure
|
| 158 |
+
|
| 159 |
+
---
|