Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,31 @@
|
|
| 1 |
-
import
|
| 2 |
-
from diffusers import StableDiffusionXLPipeline
|
| 3 |
from huggingface_hub import HfApi, HfFolder, upload_folder
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
# πΉ Base model your LoRA was trained on
|
| 6 |
base_model = "stabilityai/stable-diffusion-xl-base-1.0"
|
| 7 |
-
|
| 8 |
-
# πΉ Your LoRA model on Hugging Face
|
| 9 |
lora_model_id = "CoolKrishh/Comic-SDXL-LoRA"
|
| 10 |
-
|
| 11 |
-
# πΉ Output directory for the merged pipeline
|
| 12 |
output_dir = "comic-sdxl-full"
|
| 13 |
|
| 14 |
print("β¬οΈ Loading base model...")
|
| 15 |
pipe = StableDiffusionXLPipeline.from_pretrained(base_model, torch_dtype=torch.float16)
|
| 16 |
-
|
| 17 |
-
print("π Attaching LoRA weights...")
|
| 18 |
pipe.load_lora_weights(lora_model_id)
|
| 19 |
|
| 20 |
print("πΎ Saving merged pipeline...")
|
| 21 |
pipe.save_pretrained(output_dir)
|
| 22 |
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
token = HfFolder.get_token()
|
| 28 |
|
| 29 |
-
|
|
|
|
| 30 |
|
| 31 |
print("βοΈ Uploading to Hugging Face Hub...")
|
| 32 |
-
api.create_repo(repo_id=repo_id, repo_type="model", private=False, exist_ok=True)
|
| 33 |
upload_folder(folder_path=output_dir, repo_id=repo_id, repo_type="model", token=token)
|
| 34 |
|
| 35 |
-
print(f"π Uploaded
|
|
|
|
| 1 |
+
import os
|
|
|
|
| 2 |
from huggingface_hub import HfApi, HfFolder, upload_folder
|
| 3 |
+
from diffusers import StableDiffusionXLPipeline
|
| 4 |
+
import torch
|
| 5 |
|
|
|
|
| 6 |
base_model = "stabilityai/stable-diffusion-xl-base-1.0"
|
|
|
|
|
|
|
| 7 |
lora_model_id = "CoolKrishh/Comic-SDXL-LoRA"
|
|
|
|
|
|
|
| 8 |
output_dir = "comic-sdxl-full"
|
| 9 |
|
| 10 |
print("β¬οΈ Loading base model...")
|
| 11 |
pipe = StableDiffusionXLPipeline.from_pretrained(base_model, torch_dtype=torch.float16)
|
| 12 |
+
print("π Loading LoRA weights...")
|
|
|
|
| 13 |
pipe.load_lora_weights(lora_model_id)
|
| 14 |
|
| 15 |
print("πΎ Saving merged pipeline...")
|
| 16 |
pipe.save_pretrained(output_dir)
|
| 17 |
|
| 18 |
+
# β
Use token from environment
|
| 19 |
+
token = os.getenv("HF_TOKEN")
|
| 20 |
|
| 21 |
+
if not token:
|
| 22 |
+
raise ValueError("β No HF_TOKEN found. Add it in your Space secrets.")
|
|
|
|
| 23 |
|
| 24 |
+
api = HfApi()
|
| 25 |
+
repo_id = "CoolKrishh/Comic-SDXL-Full"
|
| 26 |
|
| 27 |
print("βοΈ Uploading to Hugging Face Hub...")
|
| 28 |
+
api.create_repo(repo_id=repo_id, repo_type="model", private=False, exist_ok=True, token=token)
|
| 29 |
upload_folder(folder_path=output_dir, repo_id=repo_id, repo_type="model", token=token)
|
| 30 |
|
| 31 |
+
print(f"π Uploaded successfully to https://huggingface.co/{repo_id}")
|