ritutweets46 Aditibaheti commited on
Commit
d006030
1 Parent(s): c2633fb

- xyz (ad7a35ebef2cb9175905548b97f4e066b7f9982d)


Co-authored-by: Aditi Baheti <Aditibaheti@users.noreply.huggingface.co>

Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -3,15 +3,21 @@ import numpy as np
3
  import random
4
  from diffusers import DiffusionPipeline
5
  import torch
 
 
6
 
7
  device = "cuda" if torch.cuda.is_available() else "cpu"
8
 
 
 
 
 
9
  # Path to your model repository and safetensors weights
10
  base_model_repo = "stabilityai/stable-diffusion-3-medium-diffusers"
11
  lora_weights_path = "./pytorch_lora_weights.safetensors"
12
 
13
  # Load the base model
14
- pipeline = DiffusionPipeline.from_pretrained(base_model_repo, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32)
15
  pipeline.load_lora_weights(lora_weights_path)
16
  pipeline.enable_sequential_cpu_offload()
17
  pipeline = pipeline.to(device)
 
3
  import random
4
  from diffusers import DiffusionPipeline
5
  import torch
6
+ from huggingface_hub import login
7
+ import os
8
 
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
10
 
11
+ # Set your Hugging Face token
12
+ HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN", "your_huggingface_token")
13
+ login(token=HUGGINGFACE_TOKEN)
14
+
15
  # Path to your model repository and safetensors weights
16
  base_model_repo = "stabilityai/stable-diffusion-3-medium-diffusers"
17
  lora_weights_path = "./pytorch_lora_weights.safetensors"
18
 
19
  # Load the base model
20
+ pipeline = DiffusionPipeline.from_pretrained(base_model_repo, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, use_auth_token=HUGGINGFACE_TOKEN)
21
  pipeline.load_lora_weights(lora_weights_path)
22
  pipeline.enable_sequential_cpu_offload()
23
  pipeline = pipeline.to(device)