linoyts HF Staff commited on
Commit
b971c5b
·
verified ·
1 Parent(s): 8417867

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -33
app.py CHANGED
@@ -22,42 +22,19 @@ transformer = FluxTransformer2DModel.from_single_file(kontext_path, torch_dtype=
22
  pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", transformer=transformer, torch_dtype=torch.bfloat16).to("cuda")
23
 
24
  # Load LoRA data (you'll need to create this JSON file or modify to load your LoRAs)
25
- try:
26
- with open("flux_loras.json", "r") as file:
27
- data = json.load(file)
28
- flux_loras_raw = [
29
- {
30
- "image": item["image"],
31
- "title": item["title"],
32
- "repo": item["repo"],
33
- "trigger_word": item.get("trigger_word", ""),
34
- "weights": item.get("weights", "pytorch_lora_weights.safetensors"),
35
- "likes": item.get("likes", 0),
36
- "downloads": item.get("downloads", 0),
37
- }
38
- for item in data
39
- ]
40
- except FileNotFoundError:
41
- # Default LoRAs if JSON file doesn't exist
42
  flux_loras_raw = [
43
  {
44
- "image": "https://via.placeholder.com/300x300?text=LoRA+1",
45
- "title": "Example LoRA 1",
46
- "repo": "example/lora1",
47
- "trigger_word": "style1",
48
- "weights": "pytorch_lora_weights.safetensors",
49
- "likes": 100,
50
- "downloads": 500,
51
- },
52
- {
53
- "image": "https://via.placeholder.com/300x300?text=LoRA+2",
54
- "title": "Example LoRA 2",
55
- "repo": "example/lora2",
56
- "trigger_word": "style2",
57
- "weights": "pytorch_lora_weights.safetensors",
58
- "likes": 80,
59
- "downloads": 300,
60
  }
 
61
  ]
62
 
63
  # Global variables for LoRA management
 
22
  pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", transformer=transformer, torch_dtype=torch.bfloat16).to("cuda")
23
 
24
  # Load LoRA data (you'll need to create this JSON file or modify to load your LoRAs)
25
+
26
+ with open("flux_loras.json", "r") as file:
27
+ data = json.load(file)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  flux_loras_raw = [
29
  {
30
+ "image": item["image"],
31
+ "title": item["title"],
32
+ "repo": item["repo"],
33
+ "trigger_word": item.get("trigger_word", ""),
34
+ "trigger_position": item.get("trigger_position", "prepend"),
35
+ "weights": item.get("weights", "pytorch_lora_weights.safetensors"),
 
 
 
 
 
 
 
 
 
 
36
  }
37
+ for item in data
38
  ]
39
 
40
  # Global variables for LoRA management