Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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(
|
31 |
-
|
32 |
-
#
|
33 |
-
|
|
|
|
|
34 |
# Convert back to spatial domain using inverse FFT
|
35 |
transformed_image = ifftn(transformed_freq_image).real
|
36 |
-
|
|
|
|
|
|
|
|
|
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}"
|