Skip to content

Commit

Permalink
Merge pull request #2 from Dilydigre/acmo0-patch-1
Browse files Browse the repository at this point in the history
Change random image generation
  • Loading branch information
acmo0 committed May 31, 2024
2 parents 1515c59 + f01d170 commit 2522d62
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/models/UNET_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
class UNETModel:

def __init__(self, PATH):
self.gaussian_noise = GaussianNoise(1)
self.gaussian_noise = GaussianNoise(25)
self.unet = UNet()
self.model_PATH=PATH
self.unet.load_state_dict(torch.load(self.model_PATH)['model_state_dict']) #load le fichier de la VM de save/modele1 dans le UNET
self.unet.eval()
# On crée ensuite les deux fonctions nécessaires à la liaison entre l'AI et l'API

def generate_without_prompt(self):
#tensor 3 512 512 avec tous les coefficients à 0
input_tensor = torch.zeros(1,3,512,512)
noise_image = self.gaussian_noise(input_tensor) #image bruitée
noise_image = torch.tensor(np.random.rand(1, 3, 512, 512).astype('float32')) #image bruitée
unet_image = self.unet(noise_image) #image bruitée passée à travers le U-Net
resized_image = torch.reshape(unet_image, (512, 512, 3)) # on reshape l'image avec torch.reshape
normalized_image = torch.clamp(resized_image, 0, 1)*255 # on normalise avec torch.clamp pour avoir des valeurs entre 0 et 255
Expand Down

0 comments on commit 2522d62

Please sign in to comment.