Lisandro commited on
Commit
5ef00f9
·
1 Parent(s): 8135193

Refactor app.py to load LoRA configurations from an external JSON file and add loras.json with initial data

Browse files
Files changed (2) hide show
  1. app.py +15 -74
  2. loras.json +105 -0
app.py CHANGED
@@ -15,80 +15,21 @@ import math
15
  import numpy as np
16
  import traceback
17
 
18
- # Load LoRAs from JSON
19
- loras = [
20
- {
21
- "repo": "lichorosario/dott-3000-qwen-image-lora",
22
- "image": "https://huggingface.co/lichorosario/dott-qwen-image-lora/resolve/main/samples/martha.png",
23
- "trigger_word": "",
24
- "trigger_position": "",
25
- "aspect": "landscape",
26
- "title": "Day of the Tentacle"
27
- },
28
- {
29
- "repo": "lichorosario/samhtr-qwen-image-lora",
30
- "image": "https://huggingface.co/lichorosario/samhtr-qwen-image-lora/resolve/main/images/example_irn8g38y0.png",
31
- "trigger_word": "",
32
- "trigger_position": "",
33
- "aspect": "landscape",
34
- "title": "Sam and Max hit the road"
35
- },
36
- {
37
- "repo": "lichorosario/rtmi-qwen-image-lora",
38
- "image": "https://huggingface.co/lichorosario/rtmi-qwen-image-lora/resolve/main/images/lara.png",
39
- "trigger_word": "",
40
- "trigger_position": "",
41
- "aspect": "landscape",
42
- "title": "Return to Monkey Island"
43
- },
44
- {
45
- "repo": "lichorosario/lobato-qwen-image-lora",
46
- "image": "https://huggingface.co/lichorosario/lobato-qwen-image-lora/resolve/main/images/milei.png",
47
- "trigger_word": "",
48
- "trigger_position": "",
49
- "aspect": "landscape",
50
- "title": "Pablo Lobato"
51
- },
52
- {
53
- "repo": "lichorosario/tosti-qwen-image-lora",
54
- "image": "https://huggingface.co/lichorosario/tosti-qwen-image-lora/resolve/main/images/example_85rpareuq.png",
55
- "trigger_word": "",
56
- "aspect": "square",
57
- "title": "Tosti"
58
- },
59
- {
60
- "repo": "lichorosario/taxidermist-qwen-image-lora",
61
- "image": "https://huggingface.co/lichorosario/taxidermist-qwen-image-lora/resolve/main/images/1.png",
62
- "trigger_word": "",
63
- "trigger_position": "",
64
- "aspect": "portrait",
65
- "title": "The Bad Taxidermist"
66
- },
67
- {
68
- "repo": "lichorosario/casivaras-qwen-image-lora",
69
- "image": "https://huggingface.co/lichorosario/casivaras-qwen-image-lora/resolve/main/images/perros.jpeg",
70
- "trigger_word": "",
71
- "trigger_position": "",
72
- "aspect": "portrait",
73
- "title": "Casivaras"
74
- },
75
- {
76
- "repo": "lichorosario/piccoli-fig-qwen-image-lora",
77
- "image": "https://huggingface.co/lichorosario/piccoli-fig-qwen-image-lora/resolve/main/images/1.png",
78
- "trigger_word": "",
79
- "trigger_position": "",
80
- "aspect": "landscape",
81
- "title": "Piccoli Figurativo"
82
- },
83
- {
84
- "repo": "lichorosario/piccoli-abstracto-qwen-image-lora",
85
- "image": "https://huggingface.co/lichorosario/piccoli-abstracto-lora/resolve/main/images/3.png",
86
- "trigger_word": "",
87
- "trigger_position": "",
88
- "aspect": "square",
89
- "title": "Piccoli Abstracto"
90
- }
91
- ]
92
 
93
  # Initialize the base model
94
  dtype = torch.bfloat16
 
15
  import numpy as np
16
  import traceback
17
 
18
+ # Load LoRAs from JSON file
19
+ def load_loras_from_file():
20
+ """Load LoRA configurations from external JSON file."""
21
+ try:
22
+ with open('loras.json', 'r', encoding='utf-8') as f:
23
+ return json.load(f)
24
+ except FileNotFoundError:
25
+ print("Warning: loras.json file not found. Using empty list.")
26
+ return []
27
+ except json.JSONDecodeError as e:
28
+ print(f"Error parsing loras.json: {e}")
29
+ return []
30
+
31
+ # Load the LoRAs
32
+ loras = load_loras_from_file()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  # Initialize the base model
35
  dtype = torch.bfloat16
loras.json ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "repo": "lichorosario/dott-3000-qwen-image-lora",
4
+ "image": "https://huggingface.co/lichorosario/dott-qwen-image-lora/resolve/main/samples/martha.png",
5
+ "trigger_word": "",
6
+ "trigger_position": "",
7
+ "aspect": "landscape",
8
+ "title": "Day of the Tentacle"
9
+ },
10
+ {
11
+ "repo": "lichorosario/samhtr-qwen-image-lora",
12
+ "image": "https://huggingface.co/lichorosario/samhtr-qwen-image-lora/resolve/main/images/example_irn8g38y0.png",
13
+ "trigger_word": "",
14
+ "trigger_position": "",
15
+ "aspect": "landscape",
16
+ "title": "Sam and Max hit the road"
17
+ },
18
+ {
19
+ "repo": "lichorosario/rtmi-qwen-image-lora",
20
+ "image": "https://huggingface.co/lichorosario/rtmi-qwen-image-lora/resolve/main/images/lara.png",
21
+ "trigger_word": "",
22
+ "trigger_position": "",
23
+ "aspect": "landscape",
24
+ "title": "Return to Monkey Island"
25
+ },
26
+ {
27
+ "repo": "lichorosario/totaldrama-qwen-image-lora",
28
+ "image": "https://huggingface.co/lichorosario/totaldrama-qwen-image-lora/resolve/main/images/1.webp",
29
+ "trigger_word": "",
30
+ "trigger_position": "",
31
+ "aspect": "square",
32
+ "title": "Total Drama"
33
+ },
34
+ {
35
+ "repo": "lichorosario/lobato-qwen-image-lora",
36
+ "image": "https://huggingface.co/lichorosario/lobato-qwen-image-lora/resolve/main/images/milei.png",
37
+ "trigger_word": "",
38
+ "trigger_position": "",
39
+ "aspect": "landscape",
40
+ "title": "Pablo Lobato"
41
+ },
42
+ {
43
+ "repo": "lichorosario/tosti-qwen-image-lora",
44
+ "image": "https://huggingface.co/lichorosario/tosti-qwen-image-lora/resolve/main/images/example_85rpareuq.png",
45
+ "trigger_word": "",
46
+ "aspect": "square",
47
+ "title": "Tosti"
48
+ },
49
+ {
50
+ "repo": "lichorosario/blbfsh-qwen-image-lora",
51
+ "image": "https://huggingface.co/lichorosario/blbfsh-qwen-image-lora/resolve/main/images/2.png",
52
+ "trigger_word": "BLBFSH",
53
+ "trigger_position": "",
54
+ "aspect": "square",
55
+ "title": "Blobfish"
56
+ }
57
+ {
58
+ "repo": "lichorosario/taxidermist-qwen-image-lora",
59
+ "image": "https://huggingface.co/lichorosario/taxidermist-qwen-image-lora/resolve/main/images/1.png",
60
+ "trigger_word": "",
61
+ "trigger_position": "",
62
+ "aspect": "square",
63
+ "title": "The Bad Taxidermist"
64
+ },
65
+ {
66
+ "repo": "lichorosario/casivaras-qwen-image-lora",
67
+ "image": "https://huggingface.co/lichorosario/casivaras-qwen-image-lora/resolve/main/images/perros.jpeg",
68
+ "trigger_word": "",
69
+ "trigger_position": "",
70
+ "aspect": "portrait",
71
+ "title": "Casivaras"
72
+ },
73
+ {
74
+ "repo": "lichorosario/piccoli-fig-qwen-image-lora",
75
+ "image": "https://huggingface.co/lichorosario/piccoli-fig-qwen-image-lora/resolve/main/images/1.png",
76
+ "trigger_word": "",
77
+ "trigger_position": "",
78
+ "aspect": "landscape",
79
+ "title": "Piccoli Figurativo"
80
+ },
81
+ {
82
+ "repo": "lichorosario/piccoli-abstracto-qwen-image-lora",
83
+ "image": "https://huggingface.co/lichorosario/piccoli-abstracto-lora/resolve/main/images/3.png",
84
+ "trigger_word": "abstract painting",
85
+ "trigger_position": "",
86
+ "aspect": "square",
87
+ "title": "Piccoli Abstracto"
88
+ },
89
+ {
90
+ "repo": "lichorosario/puzzolo-qwen-image-lora",
91
+ "image": "https://huggingface.co/lichorosario/puzzolo-qwen-image-lora/resolve/main/images/6.png",
92
+ "trigger_word": "",
93
+ "trigger_position": "",
94
+ "aspect": "square",
95
+ "title": "Puzzolo"
96
+ },
97
+ {
98
+ "repo": "lichorosario/china-qwen-image-lora-lora",
99
+ "image": "",
100
+ "trigger_word": "CHNZRRLL",
101
+ "trigger_position": "",
102
+ "aspect": "square",
103
+ "title": "China Zorrilla"
104
+ }
105
+ ]