# Background removal using U-net, GAN and image matting
This project represents the final project for The INF8225: machine learning course at polytechnique Montreal.
Contributors:
- Amine El Hattami
- Étienne Pierre-Doray
- Youri Barsalou
# Overview
In this project we tackle on the problem of background removal through image matting. It consists of predicting the foreground of an image or a video frame. However, unlike basic background / foreground segmentation, matting takes into account the transparency of an object. Indeed, object seen on images are not always present at full opacity. Think for instance of a tinted glass box. Ideal image segmentation would give a mask telling which pixel belongs to the box and which to the rest of the image. However, ideal image matting would return a transparency mask for the box’s coordinates, such that applying a mask to the box’s original image and then onto a completely different background would allow us to see this new background through the box. The following are some of the results of our model.
![images/result.png](images/result.png)
<center>From left to right: the input image, the associated input trimap, resulting extracted foreground w/o GAN, resulting extracted foreground and the ground truth</center>
## Software requirements
The project was written using **Python 3.6** with the following packages:
- Pillow
- tensorflow or tensorflow-gpu
- numpy
- google\_images\_download
- opencv-python
We also provide a requirement file to install all needed packages.
For an enviroment without GPU:
`pip3 install -r requirements.txt`
For an enviroment with GPU:
`pip3 install -r requirements-gpu.txt`
The download script uses the chromediver which is available by installing the chrome web browser. It can also be installed stand alone. Checkout the following link for more info [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/)
## Dataset
This project uses a custom dataset generated by a script. The script crawl the web to retreive foreground and background images with specific filters. Note that the output of the script was manually filtered. Refer to the Experiment section in the project article for more details about the dataset generation.
The dataset generation is done in two steps:
- Download the foreground and background images
`python3 scripts/download.py`
- Combine the the foreground and back images:
`python3 scripts/combine.py`
This will create a new folder in `data` in the `scripts` directory in wich the dataset is stored.
## Training
Once the dataset is generated, the model can be trained using the following:
`python3 train.py scripts/data`
The training script will save a checkpoint in the `log` directory after each 100 batches. it also saves a checkeck point when an exception is thrown and script terminates.
## Evaluate
In order to try our model, we included a snapshot of our trained model (in the `log` directory). That can be used as follow:
`python3 eval.py <input_img_path> <trimap_img_path> <output_img_path> --checkpoint -1`
没有合适的资源?快使用搜索试试~ 我知道了~
背景去除算法-基于UNet实现的背景去除算法-附项目源码-优质项目分享.zip
共22个文件
py:9个
txt:2个
meta:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 51 浏览量
2024-05-07
13:33:55
上传
评论
收藏 38.08MB ZIP 举报
温馨提示
背景去除算法_基于UNet实现的背景去除算法_附项目源码_优质项目分享
资源推荐
资源详情
资源评论
收起资源包目录
背景去除算法_基于UNet实现的背景去除算法_附项目源码_优质项目分享.zip (22个子文件)
背景去除算法_基于UNet实现的背景去除算法_附项目源码_优质项目分享
exploringImageMattingReport.pdf 615KB
eval.py 5KB
requirements-gpu.txt 81B
unet
__init__.py 44B
unet_parts.py 2KB
unet_model.py 3KB
README.md 67B
requirements.txt 77B
images
result.png 2.22MB
train.py 9KB
README.md 3KB
log
matting
checkpoint 93B
matting.ckpt-36800.index 15KB
matting.ckpt-83256.meta 1.36MB
matting.ckpt-36800.data-00000-of-00001 22.92MB
matting.ckpt-36800.meta 1.36MB
matting.ckpt-83256.data-00000-of-00001 22.92MB
matting.ckpt-83256.index 15KB
scripts
combine.py 5KB
__init__.py 71B
download.py 942B
image_manips.py 2KB
共 22 条
- 1
资源评论
__AtYou__
- 粉丝: 1805
- 资源: 621
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功