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 |
Tags
- 3d
- 자료구조
- algorithm
- PRML
- Front
- 알고리즘
- nerf
- Torch
- 딥러닝
- ML
- Vision
- FGVC
- math
- nlp
- 머신러닝
- cs
- classification
- pytorch
- computervision
- SSL
- dl
- FineGrained
- Depth estimation
- Python
- CV
- Meta Learning
- clean code
- GAN
- REACT
- web
- 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