import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2 . imread ( 'messi5.jpg' , 0 ) f = np . fft . fft2 ( img ) fshift = np . fft . fftshift ( f ) magnitude_spectrum = 20 * np . log ( np . abs ( fshift )) plt . subplot ( 121 ), plt . imshow ( img , cmap = 'gray' ) plt . title ( 'Input Image' ), plt . xticks ([]), plt . yticks ([]) plt . subplot ( 122 ), plt . imshow ( magnitude_spectrum , cmap = 'gray' ) plt . title ( 'Magnitude Spectrum' ), plt . xticks ([]), plt . yticks ([]) plt . show () rows , cols = img . shape crow , ccol = rows / 2 , cols / 2 fshift [ crow - 30 : crow + 30 , ccol - 30 : ccol + 30 ] = 0 f_ishift = np . fft . ifftshift ( fshift ) img_back = np . fft . ifft2 ( f_ishift ) img_back = np . abs ( img_back ) plt . subplot ( 131 ), plt . imshow ( img , cmap = 'gray' ) plt . title ( 'Input Image' ), plt . xticks ([]), ...
파이토치 인스털:
답글삭제pip install http://download.pytorch.org/whl/cu80/torch-0.1.12.post2-cp27-none-linux_x86_64.whl
pip install torchvision
운영체계 및 파이썬 버전별 설치:
https://github.com/pytorch/pytorch
파이토치 설치여부 확인:
답글삭제python에서 import torch 가 먹어줘야 ...
# 분류망 통과에 클래스 갯수 조정 !
답글삭제model_ft.fc = nn.Linear(num_ftrs, 3)