added codes
@ -0,0 +1,54 @@
|
|||||||
|
import os
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
img_dir = 'C:/Users/pinb/Desktop/imgs'
|
||||||
|
mask_dir = 'C:/Users/pinb/Desktop/masks'
|
||||||
|
|
||||||
|
names = ['gold_ii',
|
||||||
|
'gold_ie',
|
||||||
|
'gold_io',
|
||||||
|
'gold_ee',
|
||||||
|
'gold_ei',
|
||||||
|
'gold_eo',
|
||||||
|
'gold_oi',
|
||||||
|
'gold_oe',
|
||||||
|
'gold_oo',
|
||||||
|
'silver_ii',
|
||||||
|
'silver_ie',
|
||||||
|
'silver_io',
|
||||||
|
'silver_ee',
|
||||||
|
'silver_ei',
|
||||||
|
'silver_eo',
|
||||||
|
'silver_oi',
|
||||||
|
'silver_oe',
|
||||||
|
'silver_oo']
|
||||||
|
|
||||||
|
|
||||||
|
list_imgs = glob(os.path.join(img_dir, '**', '*.png'), recursive=True)
|
||||||
|
list_masks = glob(os.path.join(mask_dir, '**', '*.png'), recursive=True)
|
||||||
|
|
||||||
|
remove_file = []
|
||||||
|
|
||||||
|
# 마스크 파일 이름 목록 생성 (확장자 제거 및 '_mask' 추가)
|
||||||
|
list_imgs_basenames = set([x.replace('_mask', '').replace(mask_dir, img_dir) for x in list_masks])
|
||||||
|
|
||||||
|
# list_imgs에서 list_masks에 없는 파일 찾기
|
||||||
|
imgs_to_delete = [mask for mask in list_imgs_basenames if mask not in list_imgs]
|
||||||
|
|
||||||
|
print(len(list_imgs))
|
||||||
|
print(len(list_masks))
|
||||||
|
print(len(imgs_to_delete))
|
||||||
|
print(imgs_to_delete)
|
||||||
|
|
||||||
|
masks_to_delete = set([x.replace('.png', '_mask.png').replace(img_dir, mask_dir) for x in imgs_to_delete])
|
||||||
|
|
||||||
|
for mask in masks_to_delete:
|
||||||
|
os.remove(mask)
|
||||||
|
print(f'Deleted: {mask}')
|
||||||
|
|
||||||
|
|
||||||
|
list_imgs = glob(os.path.join(img_dir, '**', '*.png'), recursive=True)
|
||||||
|
list_masks = glob(os.path.join(mask_dir, '**', '*.png'), recursive=True)
|
||||||
|
|
||||||
|
print(len(list_imgs))
|
||||||
|
print(len(list_masks))
|
@ -0,0 +1,31 @@
|
|||||||
|
import torch
|
||||||
|
|
||||||
|
print("PyTorch 버전:", torch.__version__)
|
||||||
|
|
||||||
|
# CUDA 사용 가능 여부 확인
|
||||||
|
if torch.cuda.is_available():
|
||||||
|
print("CUDA is available! Testing CUDA...")
|
||||||
|
|
||||||
|
# CUDA 디바이스 설정
|
||||||
|
device = torch.device("cuda")
|
||||||
|
|
||||||
|
# CUDA 디바이스에 텐서를 생성하고 연산 수행
|
||||||
|
x = torch.rand(5, 5, device=device)
|
||||||
|
y = torch.rand(5, 5, device=device)
|
||||||
|
z = x + y
|
||||||
|
|
||||||
|
# 결과 출력
|
||||||
|
print("Successfully performed a CUDA operation:")
|
||||||
|
print(z)
|
||||||
|
else:
|
||||||
|
print("CUDA is not available.")
|
||||||
|
|
||||||
|
|
||||||
|
# PyTorch 버전 확인
|
||||||
|
print("PyTorch version:", torch.__version__)
|
||||||
|
|
||||||
|
# CUDA 사용 가능 여부 및 버전 확인
|
||||||
|
cuda_available = torch.cuda.is_available()
|
||||||
|
print("CUDA available:", cuda_available)
|
||||||
|
if cuda_available:
|
||||||
|
print("CUDA version:", torch.version.cuda)
|
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 17 KiB |
@ -0,0 +1,8 @@
|
|||||||
|
Data types: int32 int32
|
||||||
|
Shapes: (262144,) (262144,)
|
||||||
|
Label sample: [0 0 0 ... 0 0 0]
|
||||||
|
Output sample: [0 0 0 ... 0 0 0]
|
||||||
|
Accuracy: 0.9977531433105469
|
||||||
|
Precision: 0.9608572440665958
|
||||||
|
Recall: 0.9866327180140039
|
||||||
|
F1 Score: 0.9735744089012517
|
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,8 @@
|
|||||||
|
Data types: int32 int32
|
||||||
|
Shapes: (262144,) (262144,)
|
||||||
|
Label sample: [0 0 0 ... 0 0 0]
|
||||||
|
Output sample: [0 0 0 ... 0 0 0]
|
||||||
|
Accuracy: 0.9964599609375
|
||||||
|
Precision: 0.9360505166475316
|
||||||
|
Recall: 0.9564758329422807
|
||||||
|
F1 Score: 0.9461529534640826
|
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,8 @@
|
|||||||
|
Data types: int32 int32
|
||||||
|
Shapes: (262144,) (262144,)
|
||||||
|
Label sample: [0 0 0 ... 0 0 0]
|
||||||
|
Output sample: [0 0 0 ... 0 0 0]
|
||||||
|
Accuracy: 0.9957275390625
|
||||||
|
Precision: 0.9423006583760059
|
||||||
|
Recall: 0.9546970539188439
|
||||||
|
F1 Score: 0.9484583525080534
|
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,8 @@
|
|||||||
|
Data types: int32 int32
|
||||||
|
Shapes: (262144,) (262144,)
|
||||||
|
Label sample: [0 0 0 ... 0 0 0]
|
||||||
|
Output sample: [0 0 0 ... 0 0 0]
|
||||||
|
Accuracy: 0.9977951049804688
|
||||||
|
Precision: 0.9486012970670796
|
||||||
|
Recall: 0.9952269726820351
|
||||||
|
F1 Score: 0.9713549410248785
|
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,8 @@
|
|||||||
|
Data types: int32 int32
|
||||||
|
Shapes: (262144,) (262144,)
|
||||||
|
Label sample: [0 0 0 ... 0 0 0]
|
||||||
|
Output sample: [0 0 0 ... 0 0 0]
|
||||||
|
Accuracy: 0.998199462890625
|
||||||
|
Precision: 0.9588396707173658
|
||||||
|
Recall: 0.9947132980886539
|
||||||
|
F1 Score: 0.9764471057884232
|
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 206 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 17 KiB |
@ -0,0 +1,8 @@
|
|||||||
|
Data types: int32 int32
|
||||||
|
Shapes: (262144,) (262144,)
|
||||||
|
Label sample: [0 0 0 ... 0 0 0]
|
||||||
|
Output sample: [0 0 0 ... 0 0 0]
|
||||||
|
Accuracy: 0.9981002807617188
|
||||||
|
Precision: 0.9655700766110861
|
||||||
|
Recall: 0.9892880229014683
|
||||||
|
F1 Score: 0.9772851669403393
|
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,8 @@
|
|||||||
|
Data types: int32 int32
|
||||||
|
Shapes: (262144,) (262144,)
|
||||||
|
Label sample: [0 0 0 ... 0 0 0]
|
||||||
|
Output sample: [0 0 0 ... 0 0 0]
|
||||||
|
Accuracy: 0.9965438842773438
|
||||||
|
Precision: 0.947846012832264
|
||||||
|
Recall: 0.9684397827308485
|
||||||
|
F1 Score: 0.9580322401334075
|
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 17 KiB |
@ -0,0 +1,8 @@
|
|||||||
|
Data types: int32 int32
|
||||||
|
Shapes: (262144,) (262144,)
|
||||||
|
Label sample: [0 0 0 ... 0 0 0]
|
||||||
|
Output sample: [0 0 0 ... 0 0 0]
|
||||||
|
Accuracy: 0.9976158142089844
|
||||||
|
Precision: 0.9365956036672927
|
||||||
|
Recall: 0.994021101992966
|
||||||
|
F1 Score: 0.9644543024512312
|
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 206 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 17 KiB |
@ -0,0 +1,4 @@
|
|||||||
|
Accuracy: 0.9975090026855469
|
||||||
|
Precision: 0.9646868359809775
|
||||||
|
Recall: 0.9690994104492783
|
||||||
|
F1 Score: 0.9668880888393083
|
@ -0,0 +1,47 @@
|
|||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
from PIL import Image
|
||||||
|
import cv2
|
||||||
|
|
||||||
|
image_path = 'C:/Users/pinb/Desktop/image/'
|
||||||
|
mask_path = 'C:/Users/pinb/Desktop/mask/'
|
||||||
|
|
||||||
|
# names = ['gold_ii',
|
||||||
|
# 'gold_ie',
|
||||||
|
# 'gold_io',
|
||||||
|
# 'gold_ee',
|
||||||
|
# 'gold_ei',
|
||||||
|
# 'gold_eo',
|
||||||
|
# 'gold_oi',
|
||||||
|
# 'gold_oe',
|
||||||
|
# 'gold_oo',
|
||||||
|
names = ['silver_ii',
|
||||||
|
'silver_ie',
|
||||||
|
'silver_io',
|
||||||
|
'silver_ee',
|
||||||
|
'silver_ei',
|
||||||
|
'silver_eo',
|
||||||
|
'silver_oi',
|
||||||
|
'silver_oe',
|
||||||
|
'silver_oo']
|
||||||
|
|
||||||
|
|
||||||
|
for name in names:
|
||||||
|
image_forder = image_path + name
|
||||||
|
mask_forder = mask_path + name
|
||||||
|
for dir in os.listdir(image_forder):
|
||||||
|
image_bar_folder = os.path.join(image_forder, dir)
|
||||||
|
for file in os.listdir(image_bar_folder):
|
||||||
|
new_filename = os.path.join(image_bar_folder, file)
|
||||||
|
png_filename = os.path.splitext(os.path.basename(file))[0] + '.png'
|
||||||
|
new_png_file = os.path.join(image_bar_folder, png_filename)
|
||||||
|
img = cv2.imread(new_filename, cv2.IMREAD_GRAYSCALE)
|
||||||
|
cv2.imwrite(new_png_file, img)
|
||||||
|
os.remove(new_filename)
|
||||||
|
print(f'Converted "{new_filename}" to "{new_png_file}"')
|
||||||
|
# with Image.open(new_filename) as img:
|
||||||
|
# # PNG로 저장
|
||||||
|
# img.save(new_png_file, 'PNG')
|
||||||
|
# img.close()
|
||||||
|
# os.remove(new_filename)
|
||||||
|
# print(f'Converted "{new_filename}" to "{new_png_file}"')
|
@ -0,0 +1,86 @@
|
|||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
from PIL import Image
|
||||||
|
import cv2
|
||||||
|
|
||||||
|
# # 변환하고자 하는 폴더의 경로
|
||||||
|
# folder_path = 'C:/Users/pinb/Desktop/image/silver_oe/'
|
||||||
|
|
||||||
|
# # 변경하고자 하는 문자열과 변경될 문자열
|
||||||
|
# old_string = 'ie'
|
||||||
|
# new_string = 'oe'
|
||||||
|
|
||||||
|
# # 폴더 내의 모든 파일에 대해 반복
|
||||||
|
# for dir in os.listdir(folder_path):
|
||||||
|
# bar_folder = os.path.join(os.path.dirname(folder_path), dir)
|
||||||
|
# for filename in os.listdir(bar_folder):
|
||||||
|
# if old_string in filename:
|
||||||
|
# # 파일의 새 이름 생성
|
||||||
|
# new_filename = filename.replace(old_string, new_string)
|
||||||
|
|
||||||
|
# # 파일 이름 변경
|
||||||
|
# old_file_path = os.path.join(bar_folder, filename)
|
||||||
|
# new_file_path = os.path.join(bar_folder, new_filename)
|
||||||
|
|
||||||
|
# # 파일 이름 변경 실행
|
||||||
|
# os.rename(old_file_path, new_file_path)
|
||||||
|
# print(f'Renamed "{filename}" to "{new_filename}"')
|
||||||
|
|
||||||
|
|
||||||
|
image_path = 'C:/Users/pinb/Desktop/image/'
|
||||||
|
mask_path = 'C:/Users/pinb/Desktop/mask/'
|
||||||
|
|
||||||
|
#names = ['gold_ii',
|
||||||
|
# 'gold_ie',
|
||||||
|
# 'gold_io',
|
||||||
|
# 'gold_ee',
|
||||||
|
# 'gold_ei',
|
||||||
|
# 'gold_eo',
|
||||||
|
# 'gold_oi',
|
||||||
|
names = ['gold_oe',
|
||||||
|
'gold_oo']
|
||||||
|
# 'silver_ii',
|
||||||
|
# 'silver_ie',
|
||||||
|
# 'silver_io',
|
||||||
|
# 'silver_ee',
|
||||||
|
# 'silver_ei',
|
||||||
|
# 'silver_eo',
|
||||||
|
# 'silver_oi',
|
||||||
|
# 'silver_oe',
|
||||||
|
# 'silver_oo']
|
||||||
|
|
||||||
|
|
||||||
|
for name in names:
|
||||||
|
image_forder = image_path + name
|
||||||
|
# mask_forder = mask_path + name
|
||||||
|
# mask_origin = mask_path + name + '_mask.png'
|
||||||
|
for dir in os.listdir(image_forder):
|
||||||
|
image_bar_folder = os.path.join(image_forder, dir)
|
||||||
|
# mask_bar_folder = os.path.join(mask_forder, dir)
|
||||||
|
# if not os.path.exists(mask_bar_folder):
|
||||||
|
# os.makedirs(mask_bar_folder)
|
||||||
|
for file in os.listdir(image_bar_folder):
|
||||||
|
# filename = os.path.splitext(os.path.basename(file))[0] + '_mask.png'
|
||||||
|
# new_filename = os.path.join(mask_bar_folder, filename)
|
||||||
|
# shutil.copy2(mask_origin, new_filename)
|
||||||
|
# print(f'Copied "{mask_origin}" to "{new_filename}"')
|
||||||
|
|
||||||
|
new_filename = os.path.join(image_bar_folder, file)
|
||||||
|
png_filename = os.path.splitext(os.path.basename(file))[0] + '.png'
|
||||||
|
new_png_file = os.path.join(image_bar_folder, png_filename)
|
||||||
|
# with Image.open(new_filename) as img:
|
||||||
|
# # PNG로 저장
|
||||||
|
# img.save(new_png_file, 'PNG')
|
||||||
|
# img.close()
|
||||||
|
# os.remove(new_filename)
|
||||||
|
# print(f'Converted "{new_filename}" to "{new_png_file}"')
|
||||||
|
try:
|
||||||
|
split = os.path.splitext(os.path.basename(file))[1]
|
||||||
|
if split == '.bmp':
|
||||||
|
img = cv2.imread(new_filename, cv2.IMREAD_GRAYSCALE)
|
||||||
|
cv2.imwrite(new_png_file, img)
|
||||||
|
os.remove(new_filename)
|
||||||
|
print(f'Converted "{new_filename}" to "{new_png_file}"')
|
||||||
|
except:
|
||||||
|
os.remove(new_filename)
|
||||||
|
pass
|