gaur3009 commited on
Commit
d438d47
1 Parent(s): 39758aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -24,16 +24,25 @@ def reduce_seeds(seed):
24
  group_size = 100 # Cyclic group of size 100
25
  return seed % group_size
26
 
27
- # Fourier-based optimization
28
  def fft_convolution(image):
 
 
 
29
  # Convert to frequency domain using FFT
30
- freq_image = fftn(image)
31
- # Apply some transformation in the frequency domain (e.g., filtering, smoothing)
32
- # This is a placeholder; you can implement any frequency domain operation here
33
- transformed_freq_image = freq_image * np.exp(-np.abs(freq_image)) # Example operation
 
 
34
  # Convert back to spatial domain using inverse FFT
35
  transformed_image = ifftn(transformed_freq_image).real
36
- return transformed_image
 
 
 
 
37
 
38
  def infer(prompt_part1, color, dress_type, design, prompt_part5, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
39
  prompt = f"{prompt_part1} {color} colored plain {dress_type} with {design} design, {prompt_part5}"
 
24
  group_size = 100 # Cyclic group of size 100
25
  return seed % group_size
26
 
27
+ # Fourier-based optimization with proper tensor conversion
28
  def fft_convolution(image):
29
+ # Convert the image to a PyTorch tensor
30
+ tensor_image = torch.tensor(image).permute(2, 0, 1).float() # Convert to tensor and adjust channels
31
+
32
  # Convert to frequency domain using FFT
33
+ freq_image = fftn(tensor_image)
34
+
35
+ # Apply some transformation in the frequency domain (example: filtering, smoothing)
36
+ # This is a placeholder; implement any frequency domain operation here
37
+ transformed_freq_image = freq_image * torch.exp(-torch.abs(freq_image)) # Example operation
38
+
39
  # Convert back to spatial domain using inverse FFT
40
  transformed_image = ifftn(transformed_freq_image).real
41
+
42
+ # Convert back to NumPy array and adjust channels back to original shape
43
+ result_image = transformed_image.permute(1, 2, 0).numpy()
44
+
45
+ return result_image
46
 
47
  def infer(prompt_part1, color, dress_type, design, prompt_part5, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
48
  prompt = f"{prompt_part1} {color} colored plain {dress_type} with {design} design, {prompt_part5}"