id
int64
0
458k
file_name
stringlengths
4
119
file_path
stringlengths
14
227
content
stringlengths
24
9.96M
size
int64
24
9.96M
language
stringclasses
1 value
extension
stringclasses
14 values
total_lines
int64
1
219k
avg_line_length
float64
2.52
4.63M
max_line_length
int64
5
9.91M
alphanum_fraction
float64
0
1
repo_name
stringlengths
7
101
repo_stars
int64
100
139k
repo_forks
int64
0
26.4k
repo_open_issues
int64
0
2.27k
repo_license
stringclasses
12 values
repo_extraction_date
stringclasses
433 values
2,284,900
setup.py
dajuric_dark/dark-1/setup.py
from setuptools import setup setup( name="dark", description="", version="1.0", packages=["dark"], package_dir={"dark": "dark"}, install_requires = [] )
182
Python
.py
9
16
33
0.598837
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,901
eval.py
dajuric_dark/dark-1/samples/1.0-Func-derivation/torch/eval.py
import os os.environ["KMP_DUPLICATE_LIB_OK"] = "True" import torch import matplotlib.pyplot as plt def calc_points(range = (-15, 15)): x = torch.linspace(range[0], range[1], 50).reshape(1, -1) x = torch.tensor(x, requires_grad=True) fx = torch.add(torch.mul(2, torch.pow(x, 2)), 5) #2*x^2 + 5 #fx ...
761
Python
.py
21
32.285714
105
0.621585
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,902
eval.py
dajuric_dark/dark-1/samples/1.0-Func-derivation/dark/eval.py
import dark import matplotlib.pyplot as plt def calc_points(x): x = dark.Parameter(x) fx = dark.add(dark.mul(2, dark.pow(x, 2)), 5) #2*x^2 + 5 #fx = dark.div(dark.mul(dark.tanh(x), dark.pow(x, 2)), dark.sqrt(x)) #(tanh(x) * x^2) / sqrt(x) fx.backward() #calc gradient return x.data, \ ...
805
Python
.py
22
32.590909
127
0.625
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,903
util.py
dajuric_dark/dark-1/samples/1.1-Func-optimization/torch/util.py
import numpy as np import matplotlib.pyplot as plt ax = None def plot(eval_func, range, x_param): global ax if ax is None: plt.ion() plt.show() X_curve = np.linspace(range[0], range[1], 100).reshape(-1, 1) Y_curve = eval_func(X_curve).reshape(-1, 1) plt.plot(X_c...
434
Python
.py
14
25.214286
64
0.637056
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,904
train.py
dajuric_dark/dark-1/samples/1.1-Func-optimization/torch/train.py
import os os.environ["KMP_DUPLICATE_LIB_OK"] = "True" import torch from util import * def eval_func(x): fx = torch.add(torch.mul(2, torch.pow(x, 2)), 5) #2*x^2 + 5 return fx x = torch.tensor(10.0, requires_grad=True) for _ in range(15): print(f"Value of x is: {x.data.item():2.1f}") fx = eval_fu...
537
Python
.py
16
29.3125
71
0.634578
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,905
util.py
dajuric_dark/dark-1/samples/1.1-Func-optimization/dark/util.py
import numpy as np import matplotlib.pyplot as plt ax = None def plot(eval_func, range, x_param): global ax if ax is None: plt.ion() plt.show() X_curve = np.linspace(range[0], range[1], 100) Y_curve = [eval_func(x) for x in X_curve] plt.plot(X_curve, Y_curve, co...
414
Python
.py
14
23.5
49
0.637838
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,906
train.py
dajuric_dark/dark-1/samples/1.1-Func-optimization/dark/train.py
import os os.environ["USE_CPU"] = "True" import dark from util import * def eval_func(x): fx = dark.add(dark.mul(2, dark.pow(x, 2)), 5) #2*x^2 + 5 return fx x = dark.Parameter(10.0) for _ in range(15): print(f"Value of x is: {x.data:2.1f}") fx = eval_func(x) fx.backward() #calc gradient ...
480
Python
.py
16
25.75
61
0.617257
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,907
autodiff.py
dajuric_dark/dark-1/dark/core/autodiff.py
class Node(): op = None inputs = [] data = None requires_grad = True _grad = None def __init__(self, val): self.data = val def backward(self): if self.grad is None: self.grad = 1 order = self._topological_sort() for node in order: ...
2,414
Python
.py
82
19.804878
46
0.528495
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,908
operations.py
dajuric_dark/dark-1/dark/core/operations.py
from .autodiff import Operation import math as m # ------ scalar ------ class AbsoluteValue(Operation): def forward(self, x): return x if x >= 0 else -x def backward(self, dldy, y, x): gz = (x > 0) lz = ~gz return [dldy * gz - dldy * lz] class Add(Operation): def forward...
2,740
Python
.py
101
21.059406
43
0.571986
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,909
setup.py
dajuric_dark/dark-7/setup.py
from setuptools import setup setup( name="dark", description="", version="7.0", packages=["dark"], package_dir={"dark": "dark"}, install_requires = [] )
182
Python
.py
9
16
33
0.598837
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,910
process_db.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/db/process_db.py
import os, shutil import cv2 from rich.progress import track import mediapipe as mp from glob import glob mp_face_detection = mp.solutions.face_detection script_dir = os.path.dirname(os.path.realpath(__file__)) def get_bbox(det): normalized_bb = det.location_data.relative_bounding_box x = min(max(normalized_b...
2,752
Python
.py
69
33.869565
96
0.62315
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,911
config.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/torch/config.py
import torch import albumentations as A from albumentations.pytorch import ToTensorV2 import cv2 import os script_dir = os.path.dirname(os.path.realpath(__file__)) DB_PATH = f"{script_dir}/../db/" MODEL_PATH = f"{script_dir}/model.pt" C = 1 TEST_SIZE = 0.1 IM_SIZE = 128 ANCHORS = [ [(0.28, 0.22), (0.38, 0.48), ...
1,538
Python
.py
46
29.152174
94
0.643537
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,912
test.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/torch/test.py
from config import * from model import BlazeFace as YoloNet from utils import * import torch import cv2 from glob import glob import random sAnchors = get_scaled_anchors() def predict(model, im): im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB) im = test_transforms(image=im, bboxes=[])["image"] im = im.unsqueeze...
995
Python
.py
32
25.5625
72
0.627513
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,913
utils.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/torch/utils.py
import torch import numpy as np import cv2 from rich.progress import BarColumn, Progress, TextColumn, TimeRemainingColumn, TaskProgressColumn from config import * def iou(boxesA, boxesB): boxA_x1 = boxesA[..., 0:1] - boxesA[..., 2:3] / 2 boxA_y1 = boxesA[..., 1:2] - boxesA[..., 3:4] / 2 boxA_x2 = boxesA[.....
4,530
Python
.py
110
31.718182
101
0.53461
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,914
train.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/torch/train.py
from torch.optim import * from torch.optim.lr_scheduler import * from config import * from dataset import * from model import BlazeFace as YoloNet from loss import * from utils import * from dataset import * import os sAnchors = get_scaled_anchors().to(device) def train_loop(dLoader: DataLoader, model: YoloNet, loss_...
2,370
Python
.py
62
31.774194
97
0.622213
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,915
model-blaze-full.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/torch/model-blaze-full.py
import torch import torch.nn as nn import torch.nn.functional as F from config import * # https://github.com/deepcam-cn/yolov5-face/blob/master/models/common.py def autopad(k, p=None): # kernel, padding # Pad to 'same' if p is None: p = k // 2 if isinstance(k, int) else [x // 2 for x in k] # auto-pa...
6,586
Python
.py
140
36.535714
137
0.605054
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,916
loss.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/torch/loss.py
import torch import torch.nn as nn from config import * from utils import * class YoloLoss(nn.Module): def __init__(self): super().__init__() self.mse = nn.MSELoss() self.bce = nn.BCEWithLogitsLoss() self.entropy = nn.CrossEntropyLoss() self.sigmoid = nn.Sigmoid() s...
2,172
Python
.py
50
34.4
121
0.476894
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,917
dataset.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/torch/dataset.py
import torch import numpy as np from torch.utils.data import Dataset, DataLoader from PIL import Image from config import * from utils import * import glob import random class YoloDataset(Dataset): def __init__(self, im_folder, imT=None): super().__init__() self.lblFiles = sorted(glob.glob(f"{im_fo...
3,425
Python
.py
84
31.416667
85
0.572217
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,918
model.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/torch/model.py
import torch import torch.nn as nn import torch.nn.functional as F from config import * # https://github.com/deepcam-cn/yolov5-face/blob/master/models/common.py # https://vincentblog.xyz/posts/face-detection-for-low-end-hardware-using-the-blaze-face-architecture class Conv(nn.Module): def __init__(self, c_in, c_o...
4,245
Python
.py
109
28.688073
108
0.550772
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,919
config.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/dark/config.py
import dark.tensor as dt import albumentations as A import cv2 import os import numpy as np script_dir = os.path.dirname(os.path.realpath(__file__)) DB_PATH = f"{script_dir}/../db/" MODEL_PATH = f"{script_dir}/model.pt" C = 1 TEST_SIZE = 0.1 IM_SIZE = 128 ANCHORS = [ [(0.28, 0.22), (0.38, 0.48), (0.9, 0.78)], ...
1,820
Python
.py
53
29.226415
94
0.609195
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,920
test.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/dark/test.py
import dark from config import * from model import BlazeFace as YoloNet from utils import * import cv2 from glob import glob import random import pickle sAnchors = get_scaled_anchors() def predict(model, im): im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB) im = test_transforms(image=im, bboxes=[])["image"] im =...
1,043
Python
.py
31
28.354839
132
0.638384
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,921
utils.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/dark/utils.py
import dark.tensor as dt import numpy as np import cv2 from rich.progress import BarColumn, Progress, TextColumn, TimeRemainingColumn, TaskProgressColumn from config import * def iou(boxesA, boxesB): boxA_x1 = boxesA[..., 0:1] - boxesA[..., 2:3] / 2 boxA_y1 = boxesA[..., 1:2] - boxesA[..., 3:4] / 2 boxA_x2...
4,464
Python
.py
108
31.861111
98
0.533958
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,922
train.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/dark/train.py
import dark from dark.optim import * from config import * from dataset import * from model import BlazeFace as YoloNet from loss import * from utils import * from dataset import * import os sAnchors = get_scaled_anchors() def train_loop(dLoader: DataLoader, model: YoloNet, loss_fn: YoloLoss, optimizer: Optimizer): ...
1,998
Python
.py
56
29.214286
97
0.617387
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,923
loss.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/dark/loss.py
import dark import dark.nn as nn from config import * from utils import * class YoloLoss(nn.Module): def __init__(self): super().__init__() self.mse = nn.MSELoss() self.bce = nn.BCEWithLogitsLoss() self.entropy = nn.CrossEntropyLoss() self.sigmoid = nn.Sigmoid() sel...
3,368
Python
.py
75
30.44
86
0.454147
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,924
dataset.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/dark/dataset.py
from dark.utils.data import Dataset, DataLoader import numpy as np from PIL import Image from config import * from utils import * import glob class YoloDataset(Dataset): def __init__(self, im_folder, imT=None): super().__init__() self.lblFiles = sorted(glob.glob(f"{im_folder}/**/*.txt", recursive=T...
3,333
Python
.py
81
31.530864
82
0.564943
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,925
model.py
dajuric_dark/dark-7/samples/7.0-YOLOv3-detection/dark/model.py
import dark import dark.nn as nn from dark.nn.init import default_init_weights from config import * # https://github.com/deepcam-cn/yolov5-face/blob/master/models/common.py # https://vincentblog.xyz/posts/face-detection-for-low-end-hardware-using-the-blaze-face-architecture class Conv(nn.Module): def __init__(sel...
4,104
Python
.py
107
28.252336
101
0.549151
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,926
util.py
dajuric_dark/dark-7/samples/2.0-Func-logistic-regression/torch/util.py
import numpy as np import matplotlib.pyplot as plt ax = None def plot(X, Y, eval_func): global ax if ax is None: plt.ion() plt.show() ax = plt.figure().add_subplot(projection='3d') ax.cla() X_curve = np.meshgrid(np.linspace(0, 1, 25), np.linspace(0, 1, 25)...
555
Python
.py
17
26.352941
70
0.605578
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,927
train.py
dajuric_dark/dark-7/samples/2.0-Func-logistic-regression/torch/train.py
import os os.environ["KMP_DUPLICATE_LIB_OK"] = "True" import numpy as np import torch import matplotlib.pyplot as plt from util import * from dataset import * def sigmoid(x): den = torch.add(1, torch.exp(torch.neg(x))) return torch.div(1, den) def bce_loss(predictions, targets): lossA = torch.mul(targets...
1,249
Python
.py
34
33.117647
92
0.690058
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,928
dataset.py
dajuric_dark/dark-7/samples/2.0-Func-logistic-regression/torch/dataset.py
import random import torch def get_data(): X = []; Y = [] for i in range(100): x_1 = random.random() x_2 = random.random() y = 1 if x_1 < 0.5 else 0 #split X.append((x_1, x_2)) Y.append([y]) X = torch.tensor(X, dtype=torch.float64) Y = torch.tensor(Y,...
357
Python
.py
13
20.923077
44
0.548193
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,929
util.py
dajuric_dark/dark-7/samples/2.0-Func-logistic-regression/dark/util.py
import numpy as np import matplotlib.pyplot as plt ax = None def plot(X, Y, eval_func): global ax if ax is None: plt.ion() plt.show() ax = plt.figure().add_subplot(projection='3d') ax.cla() X_curve = np.meshgrid(np.linspace(0, 1, 25), np.linspace(0, 1, 25)...
555
Python
.py
17
26.352941
70
0.605578
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,930
train.py
dajuric_dark/dark-7/samples/2.0-Func-logistic-regression/dark/train.py
import os os.environ["USE_CPU"] = "True" import numpy as np import dark from dark import Parameter import matplotlib.pyplot as plt from util import * from dataset import * def sigmoid(x): den = dark.add(1, dark.exp(dark.neg(x))) return dark.div(1, den) def bce_loss(predictions, targets): lossA = dark.mul...
1,184
Python
.py
35
30.285714
89
0.682582
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,931
dataset.py
dajuric_dark/dark-7/samples/2.0-Func-logistic-regression/dark/dataset.py
import random import numpy as np def get_data(): X = []; Y = [] for i in range(100): x_1 = random.random() x_2 = random.random() y = 1 if x_1 < 0.5 else 0 #split X.append((x_1, x_2)) Y.append([y]) X = np.array(X); Y = np.array(Y) return X, Y
310
Python
.py
12
19.166667
40
0.503497
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,932
eval.py
dajuric_dark/dark-7/samples/1.0-Func-derivation/torch/eval.py
import os os.environ["KMP_DUPLICATE_LIB_OK"] = "True" import torch import matplotlib.pyplot as plt def calc_points(range = (-15, 15)): x = torch.linspace(range[0], range[1], 50).reshape(1, -1) x = torch.tensor(x, requires_grad=True) fx = torch.add(torch.mul(2, torch.pow(x, 2)), 5) #2*x^2 + 5 #fx ...
761
Python
.py
21
32.285714
105
0.621585
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,933
eval.py
dajuric_dark/dark-7/samples/1.0-Func-derivation/dark/eval.py
import os os.environ["USE_CPU"] = "True" import dark import dark.tensor as dt import matplotlib.pyplot as plt def calc_points(range = (-15, 15)): x = dt.linspace(range[0], range[1], 50).reshape(1, -1) x = dark.Parameter(x) fx = dark.add(dark.mul(2, dark.pow(x, 2)), 5) #2*x^2 + 5 #fx = dark.div(da...
743
Python
.py
22
29.954545
100
0.618513
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,934
util.py
dajuric_dark/dark-7/samples/5.0-ResNet-classification/torch/util.py
import numpy as np import cv2 import torch from config import * def _draw_label(im, correct, label): color = (0, 255, 0) if correct == 1 else (0, 0, 255) cv2.putText(im, label, (5, 25), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2) def save_samples(dataset, model, str_labels, filename, grid = (3, 5)): h, w = g...
1,175
Python
.py
28
32.535714
76
0.585077
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,935
config.py
dajuric_dark/dark-7/samples/5.0-ResNet-classification/torch/config.py
import os import torch IM_SIZE = 32 BATCH_SIZE = 128 CLASS_COUNT = 2 # 10 for full dataset EPOCHS = 5 device = 'cuda' if torch.cuda.is_available() else 'cpu' print(f"Running on: {device}") script_dir = os.path.dirname(os.path.realpath(__file__)) model_path = f"{script_dir}/model.pickle"
291
Python
.py
10
27.8
56
0.730216
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,936
train.py
dajuric_dark/dark-7/samples/5.0-ResNet-classification/torch/train.py
import os import torch import torch.nn as nn from torch.optim import * from rich.progress import track from model import Resnet9, get_net from dataset import get_loaders from config import * from util import save_samples def train_loop(dataloader, model, loss_fn, optimizer): model.train() size = len(dataloader...
2,294
Python
.py
59
32.491525
126
0.610231
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,937
dataset.py
dajuric_dark/dark-7/samples/5.0-ResNet-classification/torch/dataset.py
from torch.utils.data import DataLoader from torchvision.datasets import ImageFolder from torchvision.transforms import * from config import * def get_loaders(): def label_transform(l): one_hot = torch.zeros(CLASS_COUNT, dtype=torch.float32) one_hot[l] = 1 return one_hot trTransforms =...
858
Python
.py
25
28.32
84
0.667874
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,938
model.py
dajuric_dark/dark-7/samples/5.0-ResNet-classification/torch/model.py
import torch import torch.nn as nn import os from config import * class ConvBlock(nn.Module): def __init__(self, in_channels, out_channels, pool_no=-1): super().__init__() list = [ nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=1), nn.BatchNorm2d(out_channels)...
1,766
Python
.py
50
26.3
76
0.574275
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,939
util.py
dajuric_dark/dark-7/samples/5.0-ResNet-classification/dark/util.py
import numpy as np import cv2 import dark.tensor as dt def _draw_label(im, correct, label): color = (0, 255, 0) if correct == 1 else (0, 0, 255) cv2.putText(im, label, (5, 25), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2) def save_samples(dataset, model, str_labels, filename, grid = (3, 5)): h, w = grid i...
1,113
Python
.py
26
33.230769
76
0.588462
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,940
config.py
dajuric_dark/dark-7/samples/5.0-ResNet-classification/dark/config.py
import os import dark.tensor as dt IM_SIZE = 32 BATCH_SIZE = 128 CLASS_COUNT = 2 # 10 for full dataset EPOCHS = 5 print(f"Running on: {'cuda' if dt.is_cuda() else 'cpu'}") script_dir = os.path.dirname(os.path.realpath(__file__)) model_path = f"{script_dir}/model.pickle"
272
Python
.py
9
29.111111
57
0.717557
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,941
train.py
dajuric_dark/dark-7/samples/5.0-ResNet-classification/dark/train.py
import dark import dark.nn as nn from dark.optim import * import dark.tensor as dt from rich.progress import track from model import Resnet9, get_net from dataset import get_loaders from config import * from util import save_samples def train_loop(dataloader, model, loss_fn, optimizer): model.train() size = le...
2,214
Python
.py
56
33.071429
107
0.615747
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,942
dataset.py
dajuric_dark/dark-7/samples/5.0-ResNet-classification/dark/dataset.py
from dark.utils.data import ImageFolder, DataLoader from dark.utils.transforms import * from config import * def get_loaders(): def label_transform(l): one_hot = dt.zeros(CLASS_COUNT, dtype=dt.float64) one_hot[l] = 1 return one_hot trTransforms = Compose( Resize(IM_SIZE, IM_SIZ...
830
Python
.py
24
28.375
84
0.655431
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,943
model.py
dajuric_dark/dark-7/samples/5.0-ResNet-classification/dark/model.py
import dark import dark.nn as nn import dark.tensor as dt from dark.nn.init import default_init_weights from config import * class ConvBlock(nn.Module): def __init__(self, in_channels, out_channels, pool_no=-1): super().__init__() list = [ nn.Conv2d(in_channels, out_channels, kernel_si...
1,860
Python
.py
51
27.509804
76
0.58864
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,944
util.py
dajuric_dark/dark-7/samples/4.0-NN-classification/torch/util.py
import numpy as np import cv2 import torch from config import * def _draw_label(im, correct): color = (0, 255, 0) if correct == 1 else (0, 0, 255) cv2.circle(im, (25, 25), 5, color, -1) def save_samples(dataset, model, filename, grid = (3, 5)): h, w = grid i = 0 image_rows = [] for r in r...
1,075
Python
.py
28
29.357143
72
0.568317
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,945
config.py
dajuric_dark/dark-7/samples/4.0-NN-classification/torch/config.py
import os import torch device = 'cuda' if torch.cuda.is_available() else 'cpu' print(f"Running on: {device}") script_dir = os.path.dirname(os.path.realpath(__file__)) model_path = f"{script_dir}/model.pth" IM_SIZE = 28 BATCH_SIZE = 32 CLASS_COUNT = 10 EPOCHS = 5
265
Python
.py
10
25.3
56
0.727273
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,946
test.py
dajuric_dark/dark-7/samples/4.0-NN-classification/torch/test.py
import numpy as np import cv2 import glob import matplotlib.pyplot as plt from model import MyNNBlock, MyNN #for deserialization from config import * def get_random_sample(): images = glob.glob(f"{script_dir}/../db/test/**/*.png") imPath = np.random.choice(images, 1)[0] im = cv2.imread(imPath) im = cv...
877
Python
.py
33
22.69697
59
0.640382
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,947
train.py
dajuric_dark/dark-7/samples/4.0-NN-classification/torch/train.py
import numpy as np import torch.nn as nn from torch.optim import * from config import * from rich.progress import track from model import MyNN, get_net from dataset import get_loaders from util import save_samples def train_loop(dataloader, model, loss_fn, optimizer): model.train() size = len(dataloader.datase...
2,256
Python
.py
58
32.396552
86
0.605166
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,948
dataset.py
dajuric_dark/dark-7/samples/4.0-NN-classification/torch/dataset.py
from torch.utils.data import DataLoader from torchvision.datasets import ImageFolder from torchvision.transforms import * from config import * def get_loaders(): def label_transform(l): one_hot = torch.zeros(CLASS_COUNT, dtype=torch.float32) one_hot[l] = 1 return one_hot trTransforms...
924
Python
.py
27
27.925926
84
0.655056
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,949
model.py
dajuric_dark/dark-7/samples/4.0-NN-classification/torch/model.py
import torch import torch.nn as nn import os from config import * class MyNNBlock(nn.Module): def __init__(self, in_dim, out_dim): super().__init__() self.linear = nn.Linear(in_dim, out_dim) self.activation = nn.ReLU() def forward(self, x): x = self.linear(x) x = self....
935
Python
.py
34
20.764706
53
0.572717
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,950
util.py
dajuric_dark/dark-7/samples/4.0-NN-classification/dark/util.py
import numpy as np import cv2 import dark.tensor as dt def _draw_label(im, correct): color = (0, 255, 0) if correct == 1 else (0, 0, 255) cv2.circle(im, (25, 25), 5, color, -1) def save_samples(dataset, model, filename, grid = (3, 5)): h, w = grid i = 0 image_rows = [] for r in range(h): ...
1,013
Python
.py
26
29.807692
72
0.570978
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,951
config.py
dajuric_dark/dark-7/samples/4.0-NN-classification/dark/config.py
import os import dark.tensor as dt print(f"Running on: {'cuda' if dt.is_cuda() else 'cpu'}") script_dir = os.path.dirname(os.path.realpath(__file__)) model_path = f"{script_dir}/model.pickle" IM_SIZE = 28 BATCH_SIZE = 32 CLASS_COUNT = 10 EPOCHS = 5
250
Python
.py
9
26.666667
57
0.716667
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,952
test.py
dajuric_dark/dark-7/samples/4.0-NN-classification/dark/test.py
import numpy as np import cv2 import glob import matplotlib.pyplot as plt import dark from model import MyNNBlock, MyNN #for deserialization from config import * def get_random_sample(): images = glob.glob(f"{script_dir}/../db/test/**/*.png") imPath = np.random.choice(images, 1)[0] im = cv2.imread(imPath)...
860
Python
.py
33
22.30303
59
0.643902
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,953
train.py
dajuric_dark/dark-7/samples/4.0-NN-classification/dark/train.py
import numpy as np import dark.tensor as dt import dark import dark.nn as nn from dark.optim import * from dark.utils.transforms import * from config import * from rich.progress import track from model import MyNN, get_net from dataset import get_loaders from util import save_samples def train_loop(dataloader, model, ...
2,319
Python
.py
60
32.4
87
0.614177
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,954
dataset.py
dajuric_dark/dark-7/samples/4.0-NN-classification/dark/dataset.py
from dark.utils.data import ImageFolder, DataLoader from dark.utils.transforms import * from config import * def get_loaders(): def label_transform(l): one_hot = np.zeros(CLASS_COUNT, dtype=np.float32) one_hot[l] = 1 return one_hot trTransforms = Compose( Resize(IM_SIZE, IM_S...
874
Python
.py
26
27.115385
84
0.64566
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,955
model.py
dajuric_dark/dark-7/samples/4.0-NN-classification/dark/model.py
import dark import dark.nn as nn from dark.nn.init import default_init_weights import os import pickle from config import * class MyNNBlock(nn.Module): def __init__(self, in_dim, out_dim): super().__init__() self.linear = nn.Linear(in_dim, out_dim) self.activation = nn.ReLU() def forw...
1,006
Python
.py
36
21.444444
53
0.593096
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,956
modelD.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/torch/modelD.py
from torch.nn import * from config import * from util import init_weights import os class Discriminator(Module): def __init__(self, ndf, nc): super().__init__() self.nn = Sequential( #input: nc x 64 x 64 Conv2d(nc, ndf, kernel_size=4, stride=2, padding=1), ...
1,291
Python
.py
38
24.394737
73
0.530844
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,957
util.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/torch/util.py
import torch import torch.nn as nn import cv2 def init_weights(m): if isinstance(m, nn.Conv2d) or isinstance(m, nn.ConvTranspose2d): nn.init.normal_(m.weight.data, 0.0, 0.02) nn.init.zeros_(m.bias.data) if isinstance(m, nn.BatchNorm2d): nn.init.normal_(m.weight.data, 1.0, 0.02) ...
959
Python
.py
26
26.923077
69
0.586047
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,958
config.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/torch/config.py
import torch import os device = "cuda" if torch.cuda.is_available() else "cpu" script_dir = os.path.dirname(os.path.realpath(__file__)) modelD_path = f"{script_dir}/modelD.pth" modelG_path = f"{script_dir}/modelG.pth" nz = 100 BATCH_SIZE = 40 EPOCHS = 15
256
Python
.py
9
27.333333
56
0.731707
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,959
train.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/torch/train.py
import torch from torch.utils.data import DataLoader from torch.nn import Module, BCEWithLogitsLoss from torch.optim import Optimizer, Adam from modelD import Discriminator, get_netD from modelG import Generator, get_netG from dataset import get_loader from util import save_samples from rich.progress import track from...
2,586
Python
.py
65
33.338462
73
0.66653
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,960
modelG.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/torch/modelG.py
import torch from torch.nn import * from config import * from util import init_weights import os class Generator(Module): def __init__(self, nz, ngf, nc): super().__init__() self.nn = Sequential( # input: Z ConvTranspose2d(nz, ngf * 8, kernel_size=4, stride=1, paddi...
1,392
Python
.py
42
23.690476
82
0.529367
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,961
dataset.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/torch/dataset.py
from torch.utils.data import DataLoader from torchvision.datasets import ImageFolder from torchvision.transforms import * from config import * def get_loader(): tr = Compose([ Resize((64, 64)), ToTensor(), Normalize(0.5, 0.5) ]) dataset = ImageFolder(f"{script_dir}/../db/", transfo...
428
Python
.py
13
28.384615
78
0.699758
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,962
modelD.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/dark/modelD.py
import dark from dark.nn import * import os from util import init_weights from config import * class Discriminator(Module): def __init__(self, ndf, nc): super().__init__() self.nn = Sequential( #input: nc x 64 x 64 Conv2d(nc, ndf, kernel_size=4, stride=2, padding=1)...
1,271
Python
.py
38
24.105263
73
0.534653
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,963
util.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/dark/util.py
import dark.tensor as dt import dark.nn as nn from dark.nn.init import default_init_weights import cv2 def init_weights(m): default_init_weights(m) if isinstance(m, nn.Conv2d) or isinstance(m, nn.ConvTranspose2d): m.weights.data = dt.random.normal(0.0, 0.02, m.weights.data.shape) m.bias.data =...
1,102
Python
.py
28
29.857143
74
0.611
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,964
config.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/dark/config.py
import dark.tensor as dt import os print(f"Running on: {'cuda' if dt.is_cuda() else 'cpu'}") script_dir = os.path.dirname(os.path.realpath(__file__)) modelD_path = f"{script_dir}/modelD.pickle" modelG_path = f"{script_dir}/modelG.pickle" nz = 100 BATCH_SIZE = 40 EPOCHS = 15
276
Python
.py
9
29.555556
57
0.721805
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,965
train.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/dark/train.py
import dark import dark.tensor as dt from dark.nn import Module, BCEWithLogitsLoss from dark.optim import Optimizer, Adam from dark.utils.data import DataLoader from modelD import Discriminator, get_netD from modelG import Generator, get_netG from dataset import get_loader from util import save_samples from rich.progr...
2,523
Python
.py
65
32.323077
80
0.667372
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,966
modelG.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/dark/modelG.py
import dark from dark.nn import * import os from util import init_weights from config import * class Generator(Module): def __init__(self, nz, ngf, nc): super().__init__() self.nn = Sequential( # input: Z ConvTranspose2d(nz, ngf * 8, kernel_size=4, stride=1, padding...
1,358
Python
.py
41
23.682927
82
0.528958
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,967
dataset.py
dajuric_dark/dark-7/samples/6.0-GAN-image_gen/dark/dataset.py
from dark.utils.data import ImageFolder, DataLoader from dark.utils.transforms import * from config import * def get_loader(): tr = Compose( Resize(64, 64), Normalize(0.5, 0.5), ToTensorV2(), ) dataset = ImageFolder(f"{script_dir}/../db/", imgT=tr) data_loader = DataLoader(data...
389
Python
.py
12
27.666667
79
0.675532
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,968
process_db.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/db/process_db.py
import os import cv2 from glob import glob from rich.progress import track script_dir = os.path.dirname(os.path.realpath(__file__)) def resize(img_folder): im_files = sorted(glob(f"{img_folder}/*.*")) for im_file in track(im_files, "Resizing..."): im = cv2.imread(im_file) im = cv2.resize(im, ...
904
Python
.py
22
35.5
81
0.622426
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,969
util.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/torch/util.py
import cv2 import torch from config import * def save_samples(dataset, model, filename, count = 5): image_rows = [] for i in range(count): im, true_mask = dataset[i] im = torch.unsqueeze(im, 0).type(torch.float32) pred_mask = model(im.to(device)).detach().cpu() pred_mask = tor...
847
Python
.py
18
40.444444
121
0.623786
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,970
config.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/torch/config.py
import os import torch import albumentations as A import albumentations.pytorch.transforms as AT IM_SIZE = 64 BATCH_SIZE = 24 EPOCHS = 3 device = "cuda" if torch.cuda.is_available() else "cpu" print(f"Using: {device}") script_dir = os.path.dirname(os.path.realpath(__file__)) model_path = f"{script_dir}/model.pth" ...
554
Python
.py
22
22.636364
56
0.705323
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,971
train.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/torch/train.py
import torch.nn as nn from torch.optim import Adam from rich.progress import track from dataset import get_loaders from model import UNet, get_net from util import save_samples from config import * def train_loop(dataloader, model, loss_fn, optimizer): model.train() size = len(dataloader.dataset) for batc...
1,848
Python
.py
49
31.081633
87
0.608032
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,972
dataset.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/torch/dataset.py
import torch from torch.utils.data import Dataset, DataLoader from config import * from glob import glob from pathlib import Path import cv2 class CarvanaDataset(Dataset): def __init__(self, im_folder, transform=None): self.im_files = sorted(glob(f"{im_folder}/*.jpg")) self.transform = transform ...
1,327
Python
.py
33
33.272727
78
0.648163
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,973
model.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/torch/model.py
import torch import torch.nn as nn import os from config import * class UNet(nn.Module): def __init__(self, in_channels, out_channels): super().__init__() features = [32, 64, 128, 256] # down self.down_blocks = nn.ModuleList() self.down_reducs = nn.ModuleList() for ...
2,188
Python
.py
65
24.276923
90
0.545759
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,974
util.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/dark/util.py
import dark.tensor as dt import cv2 def save_samples(dataset, model, filename, count = 5): image_rows = [] for i in range(count): im, true_mask = dataset[i] im, true_mask = dt.asarray(im), dt.asarray(true_mask) im = dt.expand_dims(im, 0) pred_mask = model(im)....
899
Python
.py
19
39.263158
112
0.601399
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,975
config.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/dark/config.py
import os import dark.tensor as dt from dark.utils.transforms import * IM_SIZE = 64 BATCH_SIZE = 24 EPOCHS = 3 print(f"Running on: {'cuda' if dt.is_cuda() else 'cpu'}") script_dir = os.path.dirname(os.path.realpath(__file__)) model_path = f"{script_dir}/model.pth" trTransforms = Compose( Resize(IM_SIZE, IM_SIZE)...
545
Python
.py
22
22
57
0.680769
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,976
train.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/dark/train.py
import dark import dark.nn as nn from dark.optim import * from rich.progress import track from dataset import get_loaders from model import UNet, get_net from util import save_samples from config import * def train_loop(dataloader, model, loss_fn, optimizer): model.train() size = len(dataloader.dataset) f...
1,761
Python
.py
48
30.25
87
0.61392
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,977
dataset.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/dark/dataset.py
from dark.utils.data import Dataset, DataLoader import numpy as np import random from datetime import datetime import cv2 from config import * from glob import glob from pathlib import Path import cv2 class CarvanaDataset(Dataset): def __init__(self, im_folder, transform=None): self.im_files = sorted(glob(...
1,727
Python
.py
45
31.666667
78
0.641396
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,978
model.py
dajuric_dark/dark-7/samples/6.1-UNet-segmentation/dark/model.py
import dark import dark.nn as nn from dark.nn.init import default_init_weights import os from config import * # adopted from: https://medium.com/analytics-vidhya/creating-a-very-simple-u-net-model-with-pytorch-for-semantic-segmentation-of-satellite-images-223aa216e705 class UNet(nn.Module): def __init__(self, in_c...
2,446
Python
.py
68
26.808824
158
0.575771
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,979
util.py
dajuric_dark/dark-7/samples/3.0-Func-NN-regression/torch/util.py
import torch import numpy as np import matplotlib.pyplot as plt ax = None def plot(X, Y, eval_func): global ax if ax is None: plt.ion() plt.show() ax = plt.figure().add_subplot(projection='3d') ax.cla() X_curve = torch.meshgrid(torch.linspace(0, 1, 25), to...
641
Python
.py
18
29.611111
88
0.625213
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,980
train.py
dajuric_dark/dark-7/samples/3.0-Func-NN-regression/torch/train.py
import os os.environ["KMP_DUPLICATE_LIB_OK"] = "True" import torch import torch.nn as nn import torch.optim as optim import matplotlib.pyplot as plt from model import get_net from util import * from dataset import * X, y = get_data() X = normalize_data(X); y = normalize_data(y) X = torch.tensor...
736
Python
.py
26
25.461538
84
0.67482
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,981
dataset.py
dajuric_dark/dark-7/samples/3.0-Func-NN-regression/torch/dataset.py
import random import numpy as np def get_data(): def f(x, y): return np.sin(np.sqrt(x ** 2 + y ** 2)) x = np.linspace(-6, 6, 30) y = np.linspace(-6, 6, 30) X, Y = np.meshgrid(x, y) Z = f(X, Y) X = X.reshape(-1, 1); Y = Y.reshape(-1, 1) data = np.concatenate((X, Y), axis=1) va...
523
Python
.py
18
24.222222
48
0.548387
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,982
model.py
dajuric_dark/dark-7/samples/3.0-Func-NN-regression/torch/model.py
import torch import torch.nn as nn class MyNNBlock(nn.Module): def __init__(self, in_dim, out_dim): super().__init__() self.linear = nn.Linear(in_dim, out_dim) self.activation = nn.LeakyReLU() def forward(self, x): x = self.linear(x) x = self.activation(x) retu...
762
Python
.py
27
21.074074
48
0.557559
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,983
util.py
dajuric_dark/dark-7/samples/3.0-Func-NN-regression/dark/util.py
import dark.tensor as dt import numpy as np import matplotlib.pyplot as plt ax = None def plot(X, Y, eval_func): global ax if ax is None: plt.ion() plt.show() ax = plt.figure().add_subplot(projection='3d') ax.cla() X_curve = np.meshgrid(np.linspace(0, 1, 2...
611
Python
.py
19
26.263158
70
0.616906
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,984
train.py
dajuric_dark/dark-7/samples/3.0-Func-NN-regression/dark/train.py
import os os.environ["USE_CPU"] = "True" import dark import dark.tensor as dt import dark.nn as nn import dark.optim as optim import matplotlib.pyplot as plt from model import get_net from util import * from dataset import * X, y = get_data() X = normalize_data(X); y = normalize_data(y) model = get_net() model.tra...
636
Python
.py
26
21.730769
46
0.69398
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,985
dataset.py
dajuric_dark/dark-7/samples/3.0-Func-NN-regression/dark/dataset.py
import random import numpy as np def get_data(): def f(x, y): return np.sin(np.sqrt(x ** 2 + y ** 2)) x = np.linspace(-6, 6, 30) y = np.linspace(-6, 6, 30) X, Y = np.meshgrid(x, y) Z = f(X, Y) X = X.reshape(-1, 1); Y = Y.reshape(-1, 1) data = np.concatenate((X, Y), axis=1) va...
523
Python
.py
18
24.222222
48
0.548387
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,986
model.py
dajuric_dark/dark-7/samples/3.0-Func-NN-regression/dark/model.py
import dark import dark.nn as nn from dark.nn.init import default_init_weights class MyNNBlock(nn.Module): def __init__(self, in_dim, out_dim): super().__init__() self.linear = nn.Linear(in_dim, out_dim) self.activation = nn.LeakyReLU() def forward(self, x): x = self.linear(x)...
841
Python
.py
29
22.172414
48
0.580726
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,987
process_db.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/db/process_db.py
import os from pathlib import Path import json import numpy as np import cv2 from rich.progress import track import mediapipe as mp mp_face_detection = mp.solutions.face_detection script_dir = os.path.dirname(os.path.realpath(__file__)) def read_keypoints(json_file): data = json.load(open(json_file, "r")) dat...
2,689
Python
.py
68
33.367647
95
0.624951
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,988
util.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/torch/util.py
import torch import cv2 import numpy as np def _draw_keypoints(im, keypoints, color): imH, imW, _ = im.shape for x, y in keypoints.reshape(-1, 2): x = int(x * imW) y = int(y * imH) cv2.circle(im, (x, y), 3, color, -1) def save_samples(dataset, model, filename, grid = (3, 5), device =...
1,077
Python
.py
28
29.392857
81
0.56182
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,989
config.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/torch/config.py
import os import torch device = "cuda" if torch.cuda.is_available() else "cpu" print(f"Using: {device}") script_dir = os.path.dirname(os.path.realpath(__file__)) model_path = f"{script_dir}/model.pth" IM_SIZE = 96 KEYPOINT_COUNT = 68 * 2 BATCH_SIZE = 64 EPOCHS = 15
268
Python
.py
10
25.6
56
0.722656
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,990
test_camera.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/torch/test_camera.py
import torch from model import Resnet18 import numpy as np import os import cv2 import mediapipe as mp mp_face_detection = mp.solutions.face_detection mp_drawing = mp.solutions.drawing_utils device = 'cuda' if torch.cuda.is_available() else 'cpu' script_dir = os.path.dirname(os.path.realpath(__file__)) model_path = f...
2,686
Python
.py
70
32.471429
95
0.613344
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,991
train.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/torch/train.py
import torch import torch.nn as nn from torchvision.transforms import * import torch.optim as optim from rich.progress import track from model import Resnet18, get_net from util import save_samples from dataset import get_loaders from config import * def train_loop(train_loader, model, criterion, optimizer): trai...
1,993
Python
.py
55
29.981818
97
0.620636
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,992
dataset.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/torch/dataset.py
from torch.utils.data import Dataset from torch.utils.data import DataLoader import json import numpy as np import cv2 import albumentations as A import albumentations.pytorch.transforms as AT from config import * import random from glob import glob class KeypointDataset(Dataset): def __init__(self, kp_files, tran...
2,239
Python
.py
56
32.982143
77
0.643893
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,993
model.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/torch/model.py
import torch import torch.nn as nn import os from config import * class Block(nn.Module): def __init__(self, in_ch, out_ch, stride=1): super(Block, self).__init__() self.downsample = self.get_identity_downsample(in_ch, out_ch) if stride != 1 else None self.conv1 = nn.Conv2d(in...
2,923
Python
.py
78
27.115385
94
0.571535
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,994
util.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/dark/util.py
import dark import cv2 import numpy as np def _draw_keypoints(im, keypoints, color): imH, imW, _ = im.shape for x, y in keypoints.reshape(-1, 2): x = int(x * imW) y = int(y * imH) cv2.circle(im, (x, y), 3, color, -1) def save_samples(dataset, model, filename, grid = (3, 5)): h, w...
1,034
Python
.py
28
27.857143
71
0.557851
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,995
config.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/dark/config.py
import os import dark.tensor as dt import dark.utils.transforms as T import dark.utils.point_transforms as P print(f"Running on: {'cuda' if dt.is_cuda() else 'cpu'}") script_dir = os.path.dirname(os.path.realpath(__file__)) model_path = f"{script_dir}/model.pth" IM_SIZE = 96 KEYPOINT_COUNT = 68 * 2 BATCH_SIZE = 64 EP...
929
Python
.py
34
24.264706
64
0.670045
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,996
test_camera.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/dark/test_camera.py
import dark import dark.tensor as dt from model import Resnet18 import numpy as np import os import cv2 import mediapipe as mp mp_face_detection = mp.solutions.face_detection mp_drawing = mp.solutions.drawing_utils print(f"Running on: {'cuda' if dt.is_cuda() else 'cpu'}") script_dir = os.path.dirname(os.path.realpath...
2,643
Python
.py
70
31.857143
95
0.609524
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,997
train.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/dark/train.py
from rich.progress import track import dark import dark.nn as nn import dark.optim as optim from model import Resnet18, get_net from util import save_samples from dataset import get_loaders from config import * def train_loop(train_loader, model, criterion, optimizer): train_loss = 0.0 model.train() for b...
1,950
Python
.py
52
30.884615
84
0.622854
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,998
dataset.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/dark/dataset.py
from dark.utils.data import Dataset, DataLoader from config import * import json import numpy as np import cv2 import random from datetime import datetime from glob import glob class KeypointDataset(Dataset): def __init__(self, kp_files, im_transform, kp_transform): self.kp_files = kp_files self.im...
2,574
Python
.py
65
32.707692
90
0.625554
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)
2,284,999
model.py
dajuric_dark/dark-7/samples/5.1-ResNet-regression/dark/model.py
import dark import dark.nn as nn from dark.nn.init import default_init_weights import os import pickle from config import * class Block(nn.Module): def __init__(self, in_ch, out_ch, stride=1): super(Block, self).__init__() self.downsample = self.get_identity_downsample(in_ch, out_ch) if stride...
3,042
Python
.py
81
27.518519
94
0.583006
dajuric/dark
8
0
0
GPL-3.0
9/5/2024, 10:47:43 PM (Europe/Amsterdam)