Kush26 commited on
Commit
8ef4c99
·
verified ·
1 Parent(s): a6aaf54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -12,7 +12,7 @@ import os
12
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
13
  print(f"Using device: {device}")
14
 
15
- imsize = 512
16
  beta = 1e5 # Style weight multiplier
17
 
18
  # Define the style layers and their weights
@@ -52,7 +52,7 @@ except Exception as e:
52
 
53
  # --- Helper Functions ---
54
 
55
- def image_loader(image: Image.Image, size=512, device=torch.device("cpu")):
56
  """Loads a PIL Image, resizes, converts to tensor, and normalizes."""
57
  # VGG19 mean and std
58
  normalize = T.Normalize(mean=[0.485, 0.456, 0.406],
@@ -134,7 +134,7 @@ def stylize_image(content_image: Image.Image):
134
  optimizer = optim.Adam([generated_img], lr=lr)
135
 
136
  # 4. Run optimization loop
137
- inference_steps = 500 # Number of optimization steps for inference
138
 
139
  for step in range(1, inference_steps + 1):
140
  # Get features for the generated image
 
12
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
13
  print(f"Using device: {device}")
14
 
15
+ imsize = 256
16
  beta = 1e5 # Style weight multiplier
17
 
18
  # Define the style layers and their weights
 
52
 
53
  # --- Helper Functions ---
54
 
55
+ def image_loader(image: Image.Image, size=256, device=torch.device("cpu")):
56
  """Loads a PIL Image, resizes, converts to tensor, and normalizes."""
57
  # VGG19 mean and std
58
  normalize = T.Normalize(mean=[0.485, 0.456, 0.406],
 
134
  optimizer = optim.Adam([generated_img], lr=lr)
135
 
136
  # 4. Run optimization loop
137
+ inference_steps = 200 # Number of optimization steps for inference
138
 
139
  for step in range(1, inference_steps + 1):
140
  # Get features for the generated image