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.
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.
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.
- Make sure the
Image Denoisingdirectory is downloaded and saved on your device - Install the required dependencies in the main repository file:
pip install -r requirements.txt - You'll need to download the actual pre-trained model
u2net.pthand save it inside thesaved_models/u2net/directory. Download the model from this Google Drive Folder - You might need to fix the file paths used in the
__init__.pyfile to allow the code to run on your own local machine - Run the app.py script:
python __init__.py
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.
To utilize the denoising and sharpening functionalities:
- Download and Save: Ensure the codebase is downloaded and saved on your local device.
- Install Dependencies: Install the required dependencies included in the repository base file by running:
pip install -r requirements.txt
- Configure File Paths: Update the directory paths in the following files to match your local setup:
threshold_segmentation_denoise.pysharper_image.py
- Run the Scripts:
- Execute the denoising process:
python threshold_segmentation_denoise.py
- Execute the sharpening process:
python sharper_image.py
- Execute the denoising process:
These steps will help enhance the image quality, ensuring clearer and more detailed outputs for downstream tasks.
This repo is the derived implementation of InstantMesh. For original repo, visit https://github.com/TencentARC/InstantMesh
For a Google Colab demo, visit
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.txtThis 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.
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.
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.
- Images:
- Images of 8 types of dates, stored in separate folders.
- Each image corresponds to a specific date variety.
- Labels:
nutritional_values.csv: A file containing nutritional values for each image.
- 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.
-
Clone the repository:
git clone https://github.com/UpM-BSc-Ai-projects/IP_Project.git cd nutritional-value-prediction -
Install dependencies:
pip install -r requirements.txt
-
Train the model:
python train_model.py
-
Run the Streamlit app:
streamlit run app.py
-
Upload a date image to predict its nutritional values.
For more detailed information about the model used and performance, refer to the full README.
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).



