prithivMLmods commited on
Commit
14fd229
1 Parent(s): 7f7caf8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -6,17 +6,23 @@ from diffusers import DiffusionPipeline
6
  import torch
7
  from PIL import Image
8
 
 
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
10
  model_repo_id = "stabilityai/stable-diffusion-3.5-large-turbo"
11
 
12
- if torch.cuda.is_available():
13
- torch_dtype = torch.bfloat16
14
- else:
15
- torch_dtype = torch.float32
16
 
 
17
  pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
18
  pipe = pipe.to(device)
19
 
 
 
 
 
 
 
20
  MAX_SEED = np.iinfo(np.int32).max
21
  MAX_IMAGE_SIZE = 1024
22
 
@@ -93,7 +99,7 @@ def infer(
93
  "width": width,
94
  "height": height,
95
  "generator": generator,
96
- "num_images_per_prompt": num_images, # Ensure multiple images are generated
97
  }
98
 
99
  torch.cuda.empty_cache() # Clear GPU memory
 
6
  import torch
7
  from PIL import Image
8
 
9
+ # Device configuration
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
11
  model_repo_id = "stabilityai/stable-diffusion-3.5-large-turbo"
12
 
13
+ # Set data type based on device availability
14
+ torch_dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32
 
 
15
 
16
+ # Load the pipeline
17
  pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
18
  pipe = pipe.to(device)
19
 
20
+ # Load LoRA weights
21
+ pipe.load_lora_weights("prithivMLmods/SD3.5-4Step-Large-Turbo-HyperRealistic-LoRA", weight_name="SD3.5-4Step-Large-Turbo-HyperRealistic-LoRA.safetensors")
22
+ trigger_word = "hyper realistic" # Specify trigger word for LoRA
23
+ pipe.fuse_lora(lora_scale=1.0)
24
+
25
+ # Constants
26
  MAX_SEED = np.iinfo(np.int32).max
27
  MAX_IMAGE_SIZE = 1024
28
 
 
99
  "width": width,
100
  "height": height,
101
  "generator": generator,
102
+ "num_images_per_prompt": num_images,
103
  }
104
 
105
  torch.cuda.empty_cache() # Clear GPU memory