Upload folder using huggingface_hub
Browse files- app.py +0 -2
- inference.py +1 -0
app.py
CHANGED
@@ -16,8 +16,6 @@ else: device = 'cpu'
|
|
16 |
print('DEVICE:', device)
|
17 |
if device == 'cuda': print('CUDA DEVICE:', torch.cuda.get_device_name())
|
18 |
|
19 |
-
torch.backends.cuda.matmul.allow_tf32 = False
|
20 |
-
|
21 |
model = VGG_19().to(device).eval()
|
22 |
for param in model.parameters():
|
23 |
param.requires_grad = False
|
|
|
16 |
print('DEVICE:', device)
|
17 |
if device == 'cuda': print('CUDA DEVICE:', torch.cuda.get_device_name())
|
18 |
|
|
|
|
|
19 |
model = VGG_19().to(device).eval()
|
20 |
for param in model.parameters():
|
21 |
param.requires_grad = False
|
inference.py
CHANGED
@@ -42,6 +42,7 @@ def inference(
|
|
42 |
generated_features = model(generated_image)
|
43 |
total_loss = _compute_loss(generated_features, content_features, style_features, alpha, beta)
|
44 |
total_loss.backward()
|
|
|
45 |
return total_loss
|
46 |
|
47 |
for _ in tqdm(range(iterations), desc='The magic is happening ✨'):
|
|
|
42 |
generated_features = model(generated_image)
|
43 |
total_loss = _compute_loss(generated_features, content_features, style_features, alpha, beta)
|
44 |
total_loss.backward()
|
45 |
+
torch.nn.utils.clip_grad_norm_([generated_image], max_norm=1.0) # clip gradients
|
46 |
return total_loss
|
47 |
|
48 |
for _ in tqdm(range(iterations), desc='The magic is happening ✨'):
|