Spaces:
Running
Running
Commit
•
8d92190
1
Parent(s):
e4e751d
Update app.py
Browse files
app.py
CHANGED
@@ -34,11 +34,19 @@ def extract_info(json_data):
|
|
34 |
if model_version["baseModel"] in ["SDXL 1.0", "SDXL 0.9"]:
|
35 |
for file in model_version["files"]:
|
36 |
if file["primary"]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
info = {
|
38 |
-
"urls_to_download":
|
39 |
-
{"url": file["downloadUrl"], "filename": file["name"], "type": "weightName"},
|
40 |
-
{"url": model_version["images"][0]["url"], "filename": os.path.basename(model_version["images"][0]["url"]), "type": "imageName"}
|
41 |
-
],
|
42 |
"id": model_version["id"],
|
43 |
"modelId": model_version["modelId"],
|
44 |
"name": json_data["name"],
|
@@ -98,9 +106,9 @@ tags:
|
|
98 |
- lora
|
99 |
- diffusers
|
100 |
base_model: stabilityai/stable-diffusion-xl-base-1.0
|
101 |
-
instance_prompt: {info[
|
102 |
widget:
|
103 |
-
- text: {info[
|
104 |
---
|
105 |
|
106 |
# {info["name"]}
|
@@ -110,7 +118,13 @@ widget:
|
|
110 |
![Image]({downloaded_files["imageName"][0]})
|
111 |
|
112 |
{info["description"]}
|
|
|
113 |
"""
|
|
|
|
|
|
|
|
|
|
|
114 |
readme_content += content + "\n"
|
115 |
|
116 |
with open(f"{folder}/README.md", "w") as file:
|
|
|
34 |
if model_version["baseModel"] in ["SDXL 1.0", "SDXL 0.9"]:
|
35 |
for file in model_version["files"]:
|
36 |
if file["primary"]:
|
37 |
+
# Start by adding the primary file to the list
|
38 |
+
urls_to_download = [{"url": file["downloadUrl"], "filename": file["name"], "type": "weightName"}]
|
39 |
+
|
40 |
+
# Then append all image URLs to the list
|
41 |
+
for image in model_version["images"]:
|
42 |
+
urls_to_download.append({
|
43 |
+
"url": image["url"],
|
44 |
+
"filename": os.path.basename(image["url"]),
|
45 |
+
"type": "imageName"
|
46 |
+
})
|
47 |
+
|
48 |
info = {
|
49 |
+
"urls_to_download": urls_to_download,
|
|
|
|
|
|
|
50 |
"id": model_version["id"],
|
51 |
"modelId": model_version["modelId"],
|
52 |
"name": json_data["name"],
|
|
|
106 |
- lora
|
107 |
- diffusers
|
108 |
base_model: stabilityai/stable-diffusion-xl-base-1.0
|
109 |
+
instance_prompt: {info['trainedWords'][0] if 'trainedWords' in info and len(info['trainedWords']) > 0 else ''}
|
110 |
widget:
|
111 |
+
- text: {info['trainedWords'][0] if 'trainedWords' in info and len(info['trainedWords']) > 0 else ''}
|
112 |
---
|
113 |
|
114 |
# {info["name"]}
|
|
|
118 |
![Image]({downloaded_files["imageName"][0]})
|
119 |
|
120 |
{info["description"]}
|
121 |
+
|
122 |
"""
|
123 |
+
for index, image in enumerate(downloaded_files["imageName"]):
|
124 |
+
if(index == 1):
|
125 |
+
content += content + f"## Image examples for the model:\n{![Image]({image})}"
|
126 |
+
elif(index > 1):
|
127 |
+
content += content + f"\n{![Image]({image})}"
|
128 |
readme_content += content + "\n"
|
129 |
|
130 |
with open(f"{folder}/README.md", "w") as file:
|