-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes to get inference and training working with reorganized files
- Loading branch information
Showing
27 changed files
with
60 additions
and
1,122 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,25 @@ | ||
""" | ||
NVIDIA from [email protected] | ||
""" | ||
import albumentations as A | ||
import colorsys | ||
import glob | ||
import io | ||
import json | ||
import math | ||
from math import acos | ||
from math import sqrt | ||
from math import pi | ||
import numpy as np | ||
import torch | ||
|
||
import os | ||
|
||
from os.path import exists, basename, join | ||
from PIL import Image, ImageDraw, ImageEnhance, ImageFont | ||
import torch | ||
import torch.nn as nn | ||
import torch.nn.parallel | ||
|
||
import torch.utils.data | ||
|
||
import torchvision.transforms as transforms | ||
|
||
import torch.utils.data as data | ||
import glob | ||
import os | ||
import io | ||
|
||
from PIL import Image | ||
from PIL import ImageDraw | ||
from PIL import ImageEnhance | ||
|
||
from math import acos | ||
from math import sqrt | ||
from math import pi | ||
|
||
from os.path import exists, basename | ||
import json | ||
from os.path import join | ||
import torchvision.transforms as transforms | ||
|
||
import albumentations as A | ||
|
||
|
||
def default_loader(path): | ||
|
@@ -74,8 +62,6 @@ def py_ang(A, B=(1, 0)): | |
return 360 - inner | ||
|
||
|
||
import colorsys, math | ||
|
||
|
||
def append_dot(extensions): | ||
res = [] | ||
|
@@ -858,7 +844,6 @@ def save_image(tensor, filename, nrow=4, padding=2, mean=None, std=None, save=Tr | |
Saves a given Tensor into an image file. | ||
If given a mini-batch tensor, will save the tensor as a grid of images. | ||
""" | ||
from PIL import Image | ||
|
||
tensor = tensor.cpu() | ||
grid = make_grid(tensor, nrow=nrow, padding=10, pad_value=1) | ||
|
@@ -889,10 +874,6 @@ def save_image(tensor, filename, nrow=4, padding=2, mean=None, std=None, save=Tr | |
return im, grid | ||
|
||
|
||
from PIL import ImageDraw, Image, ImageFont | ||
import json | ||
|
||
|
||
class Draw(object): | ||
"""Drawing helper class to visualize the neural network output""" | ||
|
||
|
@@ -943,3 +924,18 @@ def draw_cube(self, points, color=(0, 255, 0)): | |
self.draw_text(points[i], str(i), (255, 0, 0)) | ||
|
||
|
||
def get_image_grid(tensor, nrow=3, padding=2, mean=None, std=None): | ||
""" | ||
Saves a given Tensor into an image file. | ||
If given a mini-batch tensor, will save the tensor as a grid of images. | ||
""" | ||
|
||
# tensor = tensor.cpu() | ||
grid = make_grid(tensor, nrow=nrow, padding=padding, pad_value=1) | ||
if not mean is None: | ||
# ndarr = grid.mul(std).add(mean).mul(255).byte().transpose(0,2).transpose(0,1).numpy() | ||
ndarr = grid.mul(std).add(mean).mul(255).byte().transpose(0, 2).transpose(0, 1).numpy() | ||
else: | ||
ndarr = grid.mul(0.5).add(0.5).mul(255).byte().transpose(0, 2).transpose(0, 1).numpy() | ||
im = Image.fromarray(ndarr) | ||
return im |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
torch==2.1.2 | ||
torch>=2.1.0 | ||
torchvision | ||
tensorboardX | ||
boto3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
Empty file.
Empty file.
Oops, something went wrong.