This is a web application that allows users to upload images and perform various operations on them, such as object detection, image classification, image captioning, and annotated images. The application is built using Flask for the backend, React for the frontend, and Vite as the build tool. It also utilizes TailwindCSS for styling and is containerized using Docker for easy deployment.
- Introduction
- Features
- Setup and Installation
- Running the Application
- Folder Structure
- Configuration
- Usage
- Contributing
- Conclusion
- Creator
- Demo Video
React + Flask Based AI Image processing app. The application utilises various image processing techniques such as object detection, image classification, and image captioning. We have used Mobilenetv3 for image classification because it is efficient and lightweight and good for scalability and low latency. It consists of a React frontend that interacts with a Flask backend to handle image processing tasks. The frontend communicates with the backend via HTTP requests.
- Object Detection: The application can detect objects present in an uploaded image and provide bounding boxes around them.
- Image Classification: The application can classify the uploaded image into different categories.
- Image Captioning: The application can generate a textual description (caption) for the uploaded image.
- Docker Containerization: The application is containerized using Docker, making it easy to deploy and run in different environments.
- Node.js
- npm (Node Package Manager)
- Python 3.x
- Docker (optional, for containerization)
git clone https://github.com/pratikranaa/ImageCraft.gitcd ai-frontendnpm installcd ..
python -m venv env
source env/bin/activate # For Unix/Mac
env\Scripts\activate # For Windows
pip install -r requirements.txtTo run the application in development mode, you need to start both the frontend and backend servers.
cd ai-frontend #if not in frontend directory
npm run devThe frontend development server will start running on the default port (5173).
Open a web browser and navigate to http://localhost:5173/ to view the application.
python3 main.py # go in directory containing main.py The application will start running on the default port (5000).
To build the application for production, follow these steps:
cd ai-frontend
npm run buildcd .. #go back to main directory
cp -r ai-frontend/dist .python3 main.pyThe application will start running on the default port and open the link displayed in browser.
To run the application in production mode using Docker, follow these steps:
- Build the Docker image:
docker-compose build- Run the Docker containers:
docker-compose upThe application will be available at http://localhost:5000 or the link displayed after deployment.
Imagecraft/
├── ai-frontend/
│ ├── src/
│ │ ├── components/
│ │ ├── utils/
│ │ ├── App.jsx
│ │ ├── index.jsx
│ │ ├── ...
│ ├── package.json
│ ├── vite.config.js
│ ├── ...
├── app/
│ ├── __init__.py
│ ├── captioning.py
│ ├── classification.py
│ ├── detection.py
│ ├── file_delete.py
│ ├── ...
├── main.py
├── docker-compose.yml
├── Dockerfile
├── requirements.txt
├── .env
├── dist # after npm run build and copying frontend build files
│ ├── index.html
│ ├── main.js
│ ├── ...
├── ...
ai-frontend/: Contains the React application source code.app/: Contains the Flask application source code.main.py: The main Flask application file.docker-compose.yml: Docker Compose configuration file.Dockerfile: Dockerfile for building the Docker image.requirements.txt: Python dependencies..env: Environment variables (if any).dist: Contains the built frontend files. need to copy from ai-frontend after npm run build
-
Backend Configuration: No additional configuration is required for the backend. However, you can modify the Flask application logic in
main.pyas needed. -
Frontend Configuration: Update the
proxyfield inAI-frontend/package.jsonif the backend server is running on a different port.
On the web interface, you can upload image for processing. The uploaded images will undergo object detection, image classification, and image captioning.
Once images are uploaded, the application will process them using the following steps:
- Object Detection: Detects objects present in the image.
- Image Classification: Classifies the image into predefined categories.
- Image Captioning: Generates a descriptive caption for the image.
- The processed images with annotations will be displayed on the web interface.
After processing, the application will return the results to the output table, including detected objects, image categories, and generated captions.
Alternatively, you can interact with the application programmatically using the provided API endpoints.
POST /api/process_images
Send a POST request to /process_images endpoint with a JSON object containing base64-encoded images.
{
"Images": [
"base64_encoded_image_1",
...
]
}
The endpoint will return a JSON object containing the processed results for each image. Example Response:
[
{
"detection": {
"objects": ["object_1", "object_2", ...]
},
"classification": "image_category",
"captioning": "image_caption",
"image": "base64_encoded_image_1"
},
{
"detection": {
"objects": ["object_1", "object_2", ...]
},
"classification": "image_category",
"captioning": "image_caption",
"image": "base64_encoded_image_2"
},
...
]
Contributions are welcome! If you find any issues or want to add new features, please open an issue or submit a pull request.
- Fork the repository.
- Create a new branch (
git checkout -b feature/fooBar). - Make changes and commit them (
git commit -am 'Add some fooBar'). - Push to the branch (
git push origin feature/fooBar). - Create a new pull request.
Whether through the web interface or API endpoints, you can easily process images and obtain object detection, image classification, and image captioning results.
This project was created by:
You can see a demo of the application in the following video:
.gif)