Skip to content

Commit

Permalink
Merge pull request #16 from Rexicon226/more-fixes
Browse files Browse the repository at this point in the history
reorganize and delete a lot of bloat
  • Loading branch information
Rexicon226 authored Mar 22, 2024
2 parents 3ba9efc + 21baedd commit 49b1aa4
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 450 deletions.
9 changes: 8 additions & 1 deletion CompositeEnvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from Terrain import generator
import matplotlib.pyplot as plt
from DNoise.dnoise import EncoderDecoder as ed
from Terrain.timing import FunctionTimer
import torch
from torch import nn

Expand Down Expand Up @@ -81,7 +82,14 @@ def dNoiseVis(self, inputpic):
inputpic = torch.tensor(inputpic, dtype=torch.float32).view(1, 1, 256, 256)
inputpic = inputpic.type(torch.cuda.FloatTensor)

de_noise_timer = FunctionTimer("De-Noising")
de_noise_timer.start()

de_noised_image = model(inputpic)

de_noise_timer.stop()
de_noise_timer.print()

loss = loss_fn(de_noised_image, inputpic)

loss = (1 - loss.item()) * 100
Expand Down Expand Up @@ -154,5 +162,4 @@ def thresholdDNoise(input, x):
masked = ev.generate()

vi = Visualizer("./DNoise/models/synthnav-model-0.pth", pic)

vi.dNoiseVis(masked)
14 changes: 7 additions & 7 deletions DNoise/array2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@
import threading
from Terrain import generator
import math
from Terrain import timers
from Terrain import timing
import os


def array2image(x, y, octaves, weight, seed: int = 0, iD: int = 0):
timer = timers.FunctionTimer("Clean - Generate")
timer = timer.FunctionTimer("Clean - Generate")
array = generator.generateClean(x, y, octaves, seed)
timer.stop()
bool_array = np.array(array, dtype=bool)
timer = timers.FunctionTimer("Clean - To Image")
timer = timer.FunctionTimer("Clean - To Image")
img = PIL.Image.fromarray(bool_array)
print(img)
timer.stop()
timer = timers.FunctionTimer("Clean - Image Save")
timer = timer.FunctionTimer("Clean - Image Save")
img.save("./val_images/clean/" + str(iD) + "_clean.jpeg", bits=1, optimize=True)
timer.stop()
timer = timers.FunctionTimer("Noisy - Generate")
timer = timer.FunctionTimer("Noisy - Generate")
array = generator.generateNoise(x, y, octaves, weight, seed)
timer.stop()
bool_array = np.array(array, dtype=bool)
timer = timers.FunctionTimer("Noisy - To Image")
timer = timer.FunctionTimer("Noisy - To Image")
img = PIL.Image.fromarray(bool_array)
timer.stop()
timer = timers.FunctionTimer("Noisy - Image Save")
timer = timer.FunctionTimer("Noisy - Image Save")
img.save("./val_images/noisy/" + str(iD) + "_noisy.jpeg", bits=1, optimize=True)
timer.stop()

Expand Down
1 change: 0 additions & 1 deletion DNoise/dnoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def main():
criterion = MAELoss()
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)

# noinspection PyTypeChecker
def create_synced_dictionary(folder_name):
sync_dir_inner = {}
for folder in os.walk(folder_name):
Expand Down
286 changes: 0 additions & 286 deletions DNoise/helper_functions.py

This file was deleted.

Loading

0 comments on commit 49b1aa4

Please sign in to comment.