"딥페이크"의 두 판 사이의 차이
둘러보기로 가기
검색하러 가기
(새 문서: == 개요 == 범죄에도 악용될 수 있는... 위험한 기술. == 사전준비 == # CUDA 세팅 : CPU연산은 너무 오래걸린다. http://id8436.iptime.org:2786/mediawiki/i...) |
|||
(같은 사용자의 중간 판 하나는 보이지 않습니다) | |||
1번째 줄: | 1번째 줄: | ||
== 개요 == | == 개요 == | ||
− | 범죄에도 악용될 수 있는... 위험한 기술. | + | 범죄에도 악용될 수 있는... 위험한 기술. 간단하게 서비스 해주는 곳도 있다.(https://www.youtube.com/watch?v=qaB0YqSfasM) |
+ | |||
+ | 샌프란샘박사님의 딥페이크 영상 만들기에 공개된 코드이다. | ||
+ | |||
+ | https://github.com/iperov/DeepFaceLab<nowiki/>도 참고해보자. | ||
+ | |||
+ | 이곳저곳 찾아본 결과... 코드 실행 한 번으로 간단하게 결과물이 나오는 것은 없었다;;; 다 번거로운 중간 클릭과정들을 거쳐야 했다..ㅜ | ||
+ | |||
+ | === 결론 === | ||
+ | 어플을 사용하는 게 가장 간편한 방법. 다양한 코드들로 진행한다 해서 간단하게 아주 양질의 결과물을 얻을 수 있는 것은 아니다. | ||
== 사전준비 == | == 사전준비 == | ||
+ | {| class="wikitable" | ||
+ | !과정 | ||
+ | !설명 | ||
+ | !방법 | ||
+ | |- | ||
+ | |필요 패키지 설치 | ||
+ | |프로젝트 디렉터리에서 진행. | ||
+ | |pip install scikit-video | ||
+ | git clone <nowiki>https://github.com/drminix/first-order-model</nowiki> | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |} | ||
+ | |||
+ | == 사용 == | ||
+ | {| class="wikitable" | ||
+ | !과정 | ||
+ | !설명 | ||
+ | !방법 | ||
+ | |- | ||
+ | |입력영상과 사진 불러오기 | ||
+ | |영상과 그 영상에 덧입힐 사진을 지정한다. | ||
+ | |<syntaxhighlight lang="python"> | ||
+ | import imageio | ||
+ | import numpy as np | ||
+ | import matplotlib.pyplot as plt | ||
+ | import matplotlib.animation as animation | ||
+ | from skimage.transform import resize | ||
+ | from IPython.display import HTML | ||
+ | import warnings | ||
+ | import os | ||
+ | import skvideo.io | ||
+ | warnings.filterwarnings("ignore") | ||
+ | |||
+ | #입력사진 | ||
+ | source_image = imageio.imread('/이미지 경로.jpg') | ||
+ | |||
+ | #입력영상 | ||
+ | driving_video = skvideo.io.vread('/영상 경로.mp4') | ||
+ | |||
+ | #Resize image and video to 256x256 | ||
+ | source_image = resize(source_image, (256, 256))[..., :3] | ||
+ | |||
+ | driving_video = [resize(frame, (256, 256))[..., :3] for frame in driving_video] | ||
+ | |||
+ | |||
+ | def display(source, driving, generated=None): | ||
+ | fig = plt.figure(figsize=(8 + 4 * (generated is not None), 6)) | ||
+ | |||
+ | ims = [] | ||
+ | for i in range(len(driving)): | ||
+ | cols = [source] | ||
+ | cols.append(driving[i]) | ||
+ | if generated is not None: | ||
+ | cols.append(generated[i]) | ||
+ | im = plt.imshow(np.concatenate(cols, axis=1), animated=True) | ||
+ | plt.axis('off') | ||
+ | ims.append([im]) | ||
+ | |||
+ | ani = animation.ArtistAnimation(fig, ims, interval=50, repeat_delay=1000) | ||
+ | plt.close() | ||
+ | return ani | ||
+ | |||
+ | HTML(display(source_image, driving_video).to_html5_video()) | ||
+ | </syntaxhighlight> | ||
+ | |- | ||
+ | |영상만들기 | ||
+ | | | ||
+ | |<syntaxhighlight lang="python"> | ||
+ | from demo import load_checkpoints | ||
+ | import os | ||
+ | generator, kp_detector = load_checkpoints(config_path='config/vox-256.yaml', | ||
+ | checkpoint_path=os.path.join(target_folder,'vox-cpk.pth.tar')) | ||
+ | |||
+ | from demo import make_animation | ||
+ | from skimage import img_as_ubyte | ||
+ | |||
+ | predictions = make_animation(source_image, driving_video, generator, kp_detector, relative=True) | ||
+ | |||
+ | #save resulting video | ||
+ | imageio.mimsave('../생성할파일경로.mp4', [img_as_ubyte(frame) for frame in predictions]) | ||
+ | #video can be downloaded from /content folder | ||
− | + | HTML(display(source_image, driving_video, predictions).to_html5_video()) | |
− | + | </syntaxhighlight> | |
− | + | |} | |
# | # | ||
[[분류:인공지능 기능구현]] | [[분류:인공지능 기능구현]] |
2021년 10월 13일 (수) 16:27 기준 최신판
1 개요[편집 | 원본 편집]
범죄에도 악용될 수 있는... 위험한 기술. 간단하게 서비스 해주는 곳도 있다.(https://www.youtube.com/watch?v=qaB0YqSfasM)
샌프란샘박사님의 딥페이크 영상 만들기에 공개된 코드이다.
https://github.com/iperov/DeepFaceLab도 참고해보자.
이곳저곳 찾아본 결과... 코드 실행 한 번으로 간단하게 결과물이 나오는 것은 없었다;;; 다 번거로운 중간 클릭과정들을 거쳐야 했다..ㅜ
1.1 결론[편집 | 원본 편집]
어플을 사용하는 게 가장 간편한 방법. 다양한 코드들로 진행한다 해서 간단하게 아주 양질의 결과물을 얻을 수 있는 것은 아니다.
2 사전준비[편집 | 원본 편집]
과정 | 설명 | 방법 |
---|---|---|
필요 패키지 설치 | 프로젝트 디렉터리에서 진행. | pip install scikit-video
git clone https://github.com/drminix/first-order-model |
3 사용[편집 | 원본 편집]
과정 | 설명 | 방법 |
---|---|---|
입력영상과 사진 불러오기 | 영상과 그 영상에 덧입힐 사진을 지정한다. | import imageio
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from skimage.transform import resize
from IPython.display import HTML
import warnings
import os
import skvideo.io
warnings.filterwarnings("ignore")
#입력사진
source_image = imageio.imread('/이미지 경로.jpg')
#입력영상
driving_video = skvideo.io.vread('/영상 경로.mp4')
#Resize image and video to 256x256
source_image = resize(source_image, (256, 256))[..., :3]
driving_video = [resize(frame, (256, 256))[..., :3] for frame in driving_video]
def display(source, driving, generated=None):
fig = plt.figure(figsize=(8 + 4 * (generated is not None), 6))
ims = []
for i in range(len(driving)):
cols = [source]
cols.append(driving[i])
if generated is not None:
cols.append(generated[i])
im = plt.imshow(np.concatenate(cols, axis=1), animated=True)
plt.axis('off')
ims.append([im])
ani = animation.ArtistAnimation(fig, ims, interval=50, repeat_delay=1000)
plt.close()
return ani
HTML(display(source_image, driving_video).to_html5_video())
|
영상만들기 | from demo import load_checkpoints
import os
generator, kp_detector = load_checkpoints(config_path='config/vox-256.yaml',
checkpoint_path=os.path.join(target_folder,'vox-cpk.pth.tar'))
from demo import make_animation
from skimage import img_as_ubyte
predictions = make_animation(source_image, driving_video, generator, kp_detector, relative=True)
#save resulting video
imageio.mimsave('../생성할파일경로.mp4', [img_as_ubyte(frame) for frame in predictions])
#video can be downloaded from /content folder
HTML(display(source_image, driving_video, predictions).to_html5_video())
|