Texttra commited on
Commit
9cd9948
·
verified ·
1 Parent(s): d22fba2

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -6
handler.py CHANGED
@@ -4,7 +4,6 @@ from diffusers import DiffusionPipeline
4
  from compel import Compel
5
  from io import BytesIO
6
  import base64
7
- import os
8
 
9
  class EndpointHandler:
10
  def __init__(self, path: str = ""):
@@ -12,12 +11,12 @@ class EndpointHandler:
12
  self.pipe = DiffusionPipeline.from_pretrained(
13
  "black-forest-labs/FLUX.1-dev",
14
  torch_dtype=torch.float16,
15
- use_auth_token=True
16
  )
17
 
18
- lora_path = os.path.join(path, "c1t3_v1.safetensors")
19
- print(f"Loading LoRA weights from: {lora_path}")
20
- self.pipe.load_lora_weights(lora_path)
21
 
22
  if torch.cuda.is_available():
23
  self.pipe.to("cuda")
@@ -53,4 +52,4 @@ class EndpointHandler:
53
  base64_image = base64.b64encode(buffer.getvalue()).decode("utf-8")
54
  print("Returning image.")
55
 
56
- return {"image": base64_image}
 
4
  from compel import Compel
5
  from io import BytesIO
6
  import base64
 
7
 
8
  class EndpointHandler:
9
  def __init__(self, path: str = ""):
 
11
  self.pipe = DiffusionPipeline.from_pretrained(
12
  "black-forest-labs/FLUX.1-dev",
13
  torch_dtype=torch.float16,
14
+ use_auth_token=True # Safe since base model is gated
15
  )
16
 
17
+ # Load LoRA directly from Hugging Face Hub
18
+ print("Loading LoRA weights from: Texttra/Cityscape_Studio")
19
+ self.pipe.load_lora_weights("Texttra/Cityscape_Studio", weight_name="c1t3_v1.safetensors")
20
 
21
  if torch.cuda.is_available():
22
  self.pipe.to("cuda")
 
52
  base64_image = base64.b64encode(buffer.getvalue()).decode("utf-8")
53
  print("Returning image.")
54
 
55
+ return {"image": base64_image}