gokaygokay commited on
Commit
eb17cd6
·
1 Parent(s): 3b546bc

fix output

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -173,8 +173,13 @@ def generate_image(prompt, negative_prompt, width, height, steps, cfg, seed):
173
  image_tensor = get_value_at_index(vaedecode_79, 0)
174
  # Convert from [0,1] to [0,255] range and ensure it's in the right format
175
  image_np = (image_tensor.cpu().numpy() * 255).astype(np.uint8)
176
- # Reshape from (batch, channel, height, width) to (height, width, channel)
177
- image_np = np.transpose(image_np[0], (1, 2, 0))
 
 
 
 
 
178
  # Convert to PIL Image
179
  image = Image.fromarray(image_np)
180
  return image
 
173
  image_tensor = get_value_at_index(vaedecode_79, 0)
174
  # Convert from [0,1] to [0,255] range and ensure it's in the right format
175
  image_np = (image_tensor.cpu().numpy() * 255).astype(np.uint8)
176
+
177
+ # Ensure we have the right shape (height, width, channels)
178
+ if len(image_np.shape) == 4: # (batch, channel, height, width)
179
+ image_np = image_np[0] # Remove batch dimension
180
+ if len(image_np.shape) == 3: # (channel, height, width)
181
+ image_np = np.transpose(image_np, (1, 2, 0)) # Convert to (height, width, channel)
182
+
183
  # Convert to PIL Image
184
  image = Image.fromarray(image_np)
185
  return image