Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils and dataset implemented #54

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Notebook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Funcion para crear directorios, es necesario e abspath?
##### se agregó a utils
import os

def create_dir(child_dir_str):

try:
pardir = os.path.abspath('static/')
original_umask = os.umask(0o000)
os.makedirs(pardir, exist_ok=True)
child_dir = os.path.join(pardir,child_dir_str)
child_dir = os.path.abspath('static/')
os.makedirs(child_dir, exist_ok=True)
finally:
os.umask(original_umask)
print('static folder created:', os.path.isdir(pardir))
print('img folder created: ', os.path.isdir(child_dir))

#create_dir('img')

#######################################################
1 change: 1 addition & 0 deletions ShuffleMNIST
Submodule ShuffleMNIST added at e4aa4d
Binary file added __pycache__/config.cpython-39.pyc
Binary file not shown.
Empty file added core/__init__.py
Empty file.
Binary file added core/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added core/__pycache__/anchors.cpython-39.pyc
Binary file not shown.
Binary file added core/__pycache__/dataset.cpython-39.pyc
Binary file not shown.
Binary file added core/__pycache__/model.cpython-39.pyc
Binary file not shown.
Binary file added core/__pycache__/resnet.cpython-39.pyc
Binary file not shown.
Binary file added core/__pycache__/utils.cpython-39.pyc
Binary file not shown.
Empty file modified core/anchors.py
100644 → 100755
Empty file.
9 changes: 6 additions & 3 deletions core/dataset.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import scipy.misc
#import scipy.misc
import imageio
import os
from PIL import Image
from torchvision import transforms
Expand All @@ -25,11 +26,12 @@ def __init__(self, root, is_train=True, data_len=None):
train_file_list = [x for i, x in zip(train_test_list, img_name_list) if i]
test_file_list = [x for i, x in zip(train_test_list, img_name_list) if not i]
if self.is_train:
self.train_img = [scipy.misc.imread(os.path.join(self.root, 'images', train_file)) for train_file in
#se cambió scipy.misc.imread por imageio.imread
self.train_img = [imageio.imread(os.path.join(self.root, 'images', train_file)) for train_file in
train_file_list[:data_len]]
self.train_label = [x for i, x in zip(train_test_list, label_list) if i][:data_len]
if not self.is_train:
self.test_img = [scipy.misc.imread(os.path.join(self.root, 'images', test_file)) for test_file in
self.test_img = [imageio.imread(os.path.join(self.root, 'images', test_file)) for test_file in
test_file_list[:data_len]]
self.test_label = [x for i, x in zip(train_test_list, label_list) if not i][:data_len]

Expand All @@ -53,6 +55,7 @@ def __getitem__(self, index):
img = transforms.Resize((600, 600), Image.BILINEAR)(img)
img = transforms.CenterCrop(INPUT_SIZE)(img)
img = transforms.ToTensor()(img)

img = transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])(img)

return img, target
Expand Down
Empty file modified core/model.py
100644 → 100755
Empty file.
Empty file modified core/resnet.py
100644 → 100755
Empty file.
27 changes: 27 additions & 0 deletions core/utils.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@
import time
import logging

import time

def timer(func):
def wrapper(*args, **kwargs):
start = time.time()
rv = func(*args, **kwargs)
total = time.time() - start
print(f'Total: {total}')
return rv
return wrapper


_, term_width = os.popen('stty size', 'r').read().split()
#term_width = 80
term_width = int(term_width)

TOTAL_BAR_LENGTH = 40.
Expand Down Expand Up @@ -100,5 +113,19 @@ def init_log(output_dir):
logging.getLogger('').addHandler(console)
return logging

#se agrega para crear las carpetas con los permisos correspondientes
def create_dir(dir_str):

try:
pardir = os.path.abspath(f'{dir_str}')
original_umask = os.umask(0o000)
os.makedirs(pardir,exist_ok=True)

finally:
os.umask(original_umask)
print(f'{dir_str} folder created:', os.path.isdir(pardir))

return os.path.abspath('./save_dir')

if __name__ == '__main__':
pass
Loading