深度学习与图像处理之:人像背景虚化
生活随笔
收集整理的這篇文章主要介紹了
深度学习与图像处理之:人像背景虚化
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
簡單實現思路:
在這里,使用DeepLabV3模型對圖像內容進行分割并提取人像,實現的代碼如下:
import os from io import BytesIO import tarfile import tempfile from six.moves import urllibfrom matplotlib import gridspec from matplotlib import pyplot as plt import numpy as np from PIL import Image# 在Tensorflow 2.x中使用Tensorflow 1.x兼容 import tensorflow.compat.v1 as tf tf.disable_v2_behavior() import cv2class DeepLabModel(object):"""Class to load deeplab model and run inference."""INPUT_TENSOR_NAME = 'ImageTensor:0'OUTPUT_TENSOR_NAME = 'SemanticPredictions:0'INPUT_SIZE = 513FROZEN_GRAPH_NAME = 'frozen_inference_graph'def __init__(self, tarball_path):"""Creates and loads pretrained deeplab model."""self.graph = tf.Gra總結
以上是生活随笔為你收集整理的深度学习与图像处理之:人像背景虚化的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iis6 fastcgiiis6 mys
- 下一篇: 关于 隐私