Recent Posts
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- SSL
- Python
- 3d
- 자료구조
- REACT
- Depth estimation
- GAN
- cs
- pytorch
- CV
- Vision
- Front
- math
- 알고리즘
- computervision
- Meta Learning
- FGVC
- 딥러닝
- 머신러닝
- nerf
- FineGrained
- nlp
- classification
- dl
- clean code
- algorithm
- web
- Torch
- PRML
- ML
- Today
- Total
KalelPark's LAB
[CODE] Masking imaging 코드 구현 본문
import torch
from PIL import Image
import numpy as np
from torchvision.transforms import transforms
tf = transforms.ToPILImage()
# Load image
image = Image.open("/content/img.jpeg")
image = np.array(image)
tensor_image = torch.tensor(image)
tensor_image = tensor_image.float()
mask = torch.zeros_like(tensor_image) # Create binary mask
mask[50:300, 200:300, :] = 1.0 # column, row
mask[50:300, 420:500, :] = 1.0
masked_image = tensor_image * mask # Apply mask to image
masked_image = (masked_image * 255.0)
masked_image = masked_image.permute(2, 0, 1)
imgg = tf(masked_image)
imgg.show() # Convert masked image back to PIL image and save
'Data Science > CODE' 카테고리의 다른 글
[ Computer Vision ] Real-Time Depth Estimation CODE (2) | 2023.05.01 |
---|---|
[CODE] Attention Convd 구현 (1) | 2023.04.13 |
[CODE] Profile 팁 및 라이브러리 소개 및 logging 추천 (0) | 2023.03.26 |
[CODE] Multi-GPU (Ver.2) 활용하기 (0) | 2023.03.21 |
[CODE] Gradient Clipping이란? (0) | 2023.03.21 |
Comments