Spaces:
Running
on
Zero
Running
on
Zero
Create civitai_integration.py
Browse files- civitai_integration.py +19 -0
civitai_integration.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
|
3 |
+
def update_gallery_with_civitai_loras(civitai_results, loras_state):
|
4 |
+
"""Aktualisiert die Galerie mit Civitai-LoRAs."""
|
5 |
+
new_loras = []
|
6 |
+
for lora in civitai_results:
|
7 |
+
new_loras.append({
|
8 |
+
"title": lora["name"],
|
9 |
+
"repo": lora["repo"],
|
10 |
+
"image": lora["image"], # URL des Vorschaubildes
|
11 |
+
"trigger_word": lora.get("trigger_word", "") # Optional
|
12 |
+
})
|
13 |
+
loras_state.extend(new_loras)
|
14 |
+
return loras_state, [(item["image"], item["title"]) for item in loras_state]
|
15 |
+
|
16 |
+
def save_loras_to_json(loras_state, json_file='loras.json'):
|
17 |
+
"""Speichert LoRAs in der JSON-Datei."""
|
18 |
+
with open(json_file, 'w') as f:
|
19 |
+
json.dump(loras_state, f)
|