lionelgarnier commited on
Commit
2434ffa
·
1 Parent(s): 0d131d4

try something

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -116,8 +116,8 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_in
116
 
117
  generator = torch.Generator("cuda").manual_seed(seed) # Explicitly use CUDA generator
118
 
119
- with torch.autocast('cuda'):
120
- output = pipe(
121
  prompt=prompt,
122
  width=width,
123
  height=height,
@@ -128,13 +128,13 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_in
128
  )
129
 
130
  # Ensure the image is properly normalized and converted
131
- image = output.images[0]
132
- if isinstance(image, torch.Tensor):
133
- image = (image.clamp(-1, 1) + 1) / 2
134
- image = (image * 255).round().clamp(0, 255).to(torch.uint8).cpu().numpy()
135
- image = Image.fromarray(image)
136
 
137
- torch.cuda.empty_cache()
138
  return image, seed
139
  except Exception as e:
140
  print(f"Error in infer: {str(e)}")
 
116
 
117
  generator = torch.Generator("cuda").manual_seed(seed) # Explicitly use CUDA generator
118
 
119
+ # with torch.autocast('cuda'):
120
+ output = pipe(
121
  prompt=prompt,
122
  width=width,
123
  height=height,
 
128
  )
129
 
130
  # Ensure the image is properly normalized and converted
131
+ image = output.images[0]
132
+ # if isinstance(image, torch.Tensor):
133
+ # image = (image.clamp(-1, 1) + 1) / 2
134
+ # image = (image * 255).round().clamp(0, 255).to(torch.uint8).cpu().numpy()
135
+ # image = Image.fromarray(image)
136
 
137
+ #torch.cuda.empty_cache()
138
  return image, seed
139
  except Exception as e:
140
  print(f"Error in infer: {str(e)}")