• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account settings Log out
  • Favorite
  • Project
  • All
Loading...
  • Log in
  • Sign up
yjyoon / Raindrop_Detection star
  • Project homeH
  • CodeC
  • IssueI
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB
  • Files
  • Commit
  • Branches
Raindrop_Detectionbinary mask map test.py
Download as .zip file
File name
Commit message
Commit date
data
data cleaning
2023-07-12
model
small fix for return type of networks
2023-07-24
tools
dataloader refactoring
2023-07-13
.gitignore
data cleaning
2023-07-12
README.md
readme update
2023-06-21
batchmix.png
theorizing train code for GAN
2023-06-22
binary mask map test.py
data cleaning
2023-07-12
datasetmananger.py
theorizing about dataset management
2023-06-23
inference.py
configuring saving method and inference method for model
2023-07-11
main.py
Hello YONA
2023-06-21
train.py
dataloader refactoring
2023-07-13
yjyoon 2023-07-12 fdc2bde data cleaning UNIX
Raw Open in browser Change history
import concurrent.futures import numpy as np import cv2 import glob def shift_img(img, x, y): M = np.float32([[1, 0, x], [0, 1, y]]) shifted = cv2.warpAffine(img, M, (img.shape[1], img.shape[0])) return shifted def binary_diff_mask(clean, dirty, threshold=0.3): # this parts corrects gamma, and always remember, sRGB values are not in linear scale with lights intensity, clean = np.power(clean, 2.2) dirty = np.power(dirty, 2.2) averaged_per_pixel = np.abs(((dirty) / (clean+1)) - 1 ) # print(averaged_per_pixel) diff = (np.abs(dirty - clean) * 0.8 + (dirty / clean -1)) * 0.2 / 2 # bin_diff = (diff > threshold).astype(np.uint8) return ((dirty / clean -1 ) > threshold ).astype(np.uint8) clean = glob.glob("data/source/Oxford_raindrop_dataset/clean/*.png") clean = sorted(clean) dirty = glob.glob("data/source/Oxford_raindrop_dataset/dirty/*.png") dirty = sorted(dirty) clean_img = cv2.imread(clean[0]) dirty_img = cv2.imread(dirty[0]) # binary_diff_mask_img = binary_diff_mask(dirty_img/255, clean_img/255, threshold=0.05) k = 10 def process(i, j): print(i) clean_img_copy = shift_img(clean_img, (i-k)/4, (j-k)/4) binary_diff_mask_img = binary_diff_mask(dirty_img / 255, clean_img_copy / 255, threshold=0.2) if not cv2.imwrite(f"test/test_img_x{(i-k)/4}-y{(j-k)/4}.png", binary_diff_mask_img*255): raise Exception("image is not saved") # this thing does not throw error when error happens and just silently executes.... what? with concurrent.futures.ProcessPoolExecutor() as executor: for i in range(k*2): for j in range(k*2): executor.submit(process, i, j) cv2.imwrite(f"test/original.png", dirty_img) cv2.imwrite(f"test/original_c.png", clean_img)

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
Sign in with github login with Google Sign in with Google
Reset password | Sign up