Skip to content

UpM-BSc-Ai-projects/IP_Project

Repository files navigation

Date Image Preprocessing & 3D Image Reconstruction

Table of Contents

  1. Image Preprocessing

  2. 3D Image Reconstruction Using InstantMesh

  3. Others

  4. License


Image Preprocessing

Image Background Remover Using U2Net

This project utilizes the pretrained U2NET model for background removal. The code for background removal is based on the Image-Background-Remover-Python repository. For more details on how the model was implemented, please refer to the original repository.

Overview

The Image Background Remover is a program designed to remove backgrounds from images using advanced techniques such as deep learning and image processing. This code was specifically used for cleaning, removing the background and processing date images. It was used during the Medina Hackathon 2023 for enhancing our dataset. The application leverages a pre-trained U2NET model for effective background removal and includes various scripts for processing images, renaming files, and analyzing pixel values.

Usage

To use the image background remover, their is required structure for the directories for the program to work. The code and model inside the Image Denoising directory is independant of the files and directories outside of it. You can download the Image Denoising by itself to run this code individually.

  1. Make sure the Image Denoising directory is downloaded and saved on your device
  2. Install the required dependencies in the main repository file: pip install -r requirements.txt
  3. You'll need to download the actual pre-trained model u2net.pth and save it inside the saved_models/u2net/ directory. Download the model from this Google Drive Folder
  4. You might need to fix the file paths used in the __init__.py file to allow the code to run on your own local machine
  5. Run the app.py script: python __init__.py

Image Denoising and Sharpening

After removing the image background, further enhancement can be applied by denoising and sharpening the images. These processes refine the visual quality by reducing residual noise and enhancing edges and details. The sharpening step leverages the unsharp_mask function from skimage to highlight finer image details.

Usage for Denoising

To utilize the denoising and sharpening functionalities:

  1. Download and Save: Ensure the codebase is downloaded and saved on your local device.
  2. Install Dependencies: Install the required dependencies included in the repository base file by running:
    pip install -r requirements.txt
  3. Configure File Paths: Update the directory paths in the following files to match your local setup:
    • threshold_segmentation_denoise.py
    • sharper_image.py
  4. Run the Scripts:
    • Execute the denoising process:
      python threshold_segmentation_denoise.py
    • Execute the sharpening process:
      python sharper_image.py

These steps will help enhance the image quality, ensuring clearer and more detailed outputs for downstream tasks.


3D Image Reconstruction Using InstantMesh

This repo is the derived implementation of InstantMesh. For original repo, visit https://github.com/TencentARC/InstantMesh

For a Google Colab demo, visit Button Text

3D Examples

Demo Demo Demo

Model Architecture

Logo

Dependencies and Installation

We recommend using Python>=3.10, PyTorch>=2.1.0, and CUDA>=12.1.

conda create --name instantmesh python=3.10
conda activate instantmesh
pip install -U pip

# Ensure Ninja is installed
conda install Ninja

# Install the correct version of CUDA
conda install cuda -c nvidia/label/cuda-12.1.0

# Install PyTorch and xformers
# You may need to install another xformers version if you use a different PyTorch version
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121
pip install xformers==0.0.22.post7

# Install Triton 
pip install triton

# Install other requirements
pip install -r requirements.txt

Others

This section includes code and models that, while not directly integral to the project, were utilized to streamline tasks, or serve as tools to achieve specific objectives, or enhance the project's overall value and outcomes.


Nutritional Value Prediction of Dates Using Machine Learning and Deep Learning

This project aims to predict the nutritional values of date fruits based on their images using machine learning (ML) and deep learning (DL). The solution leverages Convolutional Neural Networks (CNNs) and pretrained architectures to deliver accurate and efficient predictions.

Objective

The goal is to estimate the following nutritional parameters of date fruits:

  • Calories
  • Carbohydrates
  • Proteins
  • Total Fat
  • Glucose
  • Cholesterol
  • Vitamins
  • Water Content
  • Energy

The predictions are made directly from date images, reducing the need for manual or laboratory-based testing.

Dataset

  1. Images:
    • Images of 8 types of dates, stored in separate folders.
    • Each image corresponds to a specific date variety.
  2. Labels:
    • nutritional_values.csv: A file containing nutritional values for each image.

Preprocessing

  • Images resized to:
    • 28x28 (CNNs) for simplicity.
    • 224x224 (Pretrained Models) for feature extraction.
  • Normalized pixel values to range [0, 1].
  • Split into 80% training and 20% testing datasets.

Nutritional Usage

  1. Clone the repository:

    git clone https://github.com/UpM-BSc-Ai-projects/IP_Project.git
    cd nutritional-value-prediction
  2. Install dependencies:

    pip install -r requirements.txt
  3. Train the model:

    python train_model.py
  4. Run the Streamlit app:

    streamlit run app.py
  5. Upload a date image to predict its nutritional values.

For more detailed information about the model used and performance, refer to the full README.


License

This project incorporates models and code developed by other contributors, which are governed by their respective licenses. Specifically:

  • The Background Remover Using U2Net and 3D Reconstruction Using InstantMesh components are licensed under the Apache License 2.0.

The remaining parts of this project, including custom implementations and additional features, are licensed under the Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors