Jordan Legg commited on
Commit
d027eec
β€’
1 Parent(s): f37eddd
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -62,10 +62,6 @@ def infer(prompt, init_image=None, seed=42, randomize_seed=False, width=1024, he
62
  image = result.images[0]
63
  print(f"Generated image shape: {image.size}")
64
 
65
- # Inspect the output and log relevant details
66
- print("Logging detailed information for text2img:")
67
- # Log intermediate latent information if accessible
68
-
69
  print("Logging complete.")
70
  except Exception as e:
71
  print(f"Pipeline call failed with error: {e}")
@@ -95,13 +91,16 @@ def infer(prompt, init_image=None, seed=42, randomize_seed=False, width=1024, he
95
 
96
  try:
97
  print("Calling the transformer with latents")
98
- # Initialize timestep variable
99
- timestep = torch.tensor([num_inference_steps], device=device, dtype=dtype)
100
- _ = pipe.transformer(latents, timestep=timestep)
 
 
 
101
  print("Transformer call succeeded")
102
  except Exception as e:
103
- print(f"Transformer call failed with error: {e}")
104
- raise
105
 
106
  try:
107
  print("Calling the diffusion pipeline with latents")
@@ -116,11 +115,12 @@ def infer(prompt, init_image=None, seed=42, randomize_seed=False, width=1024, he
116
  ).images[0]
117
  except Exception as e:
118
  print(f"Pipeline call with latents failed with error: {e}")
119
- raise
120
 
121
  print("Inference complete")
122
  return image, seed
123
 
 
124
  # Define example prompts
125
  examples = [
126
  "a tiny astronaut hatching from an egg on the moon",
 
62
  image = result.images[0]
63
  print(f"Generated image shape: {image.size}")
64
 
 
 
 
 
65
  print("Logging complete.")
66
  except Exception as e:
67
  print(f"Pipeline call failed with error: {e}")
 
91
 
92
  try:
93
  print("Calling the transformer with latents")
94
+ # Check if timestep is required and initialize it if necessary
95
+ if 'timesteps' in pipe.transformer.forward.__code__.co_varnames:
96
+ timestep = torch.tensor([num_inference_steps], device=device, dtype=dtype)
97
+ _ = pipe.transformer(latents, timesteps=timestep)
98
+ else:
99
+ _ = pipe.transformer(latents)
100
  print("Transformer call succeeded")
101
  except Exception as e:
102
+ print(f"Transformer call failed with error: {e}. Skipping transformer step.")
103
+ return "Transformer call failed, skipping the step."
104
 
105
  try:
106
  print("Calling the diffusion pipeline with latents")
 
115
  ).images[0]
116
  except Exception as e:
117
  print(f"Pipeline call with latents failed with error: {e}")
118
+ return f"Pipeline call with latents failed: {e}"
119
 
120
  print("Inference complete")
121
  return image, seed
122
 
123
+
124
  # Define example prompts
125
  examples = [
126
  "a tiny astronaut hatching from an egg on the moon",