lazarusrolando commited on
Commit
c997032
·
verified ·
1 Parent(s): 7c33751

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -14,7 +14,12 @@ if torch.cuda.is_available():
14
  else:
15
  torch_dtype = torch.float32
16
 
17
- pipe = DiffusionPipeline.from_pretrained(model_repo_id, dtype=torch_dtype, trust_remote_code=True)
 
 
 
 
 
18
  pipe = pipe.to(device)
19
 
20
  MAX_SEED = np.iinfo(np.int32).max
@@ -36,7 +41,7 @@ def infer(
36
  if randomize_seed:
37
  seed = random.randint(0, MAX_SEED)
38
 
39
- generator = torch.Generator().manual_seed(seed)
40
 
41
  image = pipe(
42
  prompt=prompt,
@@ -105,7 +110,7 @@ with gr.Blocks(css=css) as demo:
105
  minimum=256,
106
  maximum=MAX_IMAGE_SIZE,
107
  step=32,
108
- value=1024, # Replace with defaults that work for your model
109
  )
110
 
111
  height = gr.Slider(
 
14
  else:
15
  torch_dtype = torch.float32
16
 
17
+ pipe = DiffusionPipeline.from_pretrained(
18
+ model_repo_id,
19
+ torch_dtype=torch.float16
20
+ )
21
+
22
+ pipe.enable_model_cpu_offload()
23
  pipe = pipe.to(device)
24
 
25
  MAX_SEED = np.iinfo(np.int32).max
 
41
  if randomize_seed:
42
  seed = random.randint(0, MAX_SEED)
43
 
44
+ generator = torch.Generator(device=device).manual_seed(seed)
45
 
46
  image = pipe(
47
  prompt=prompt,
 
110
  minimum=256,
111
  maximum=MAX_IMAGE_SIZE,
112
  step=32,
113
+ value=512, # Replace with defaults that work for your model
114
  )
115
 
116
  height = gr.Slider(