Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,30 +52,6 @@ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
|
| 52 |
torch_dtype = torch.bfloat16
|
| 53 |
|
| 54 |
|
| 55 |
-
repo_id = "ford442/SDXL-IP_ADAPTER"
|
| 56 |
-
subfolder = "image_encoder"
|
| 57 |
-
subfolder2 = "ip_adapter"
|
| 58 |
-
|
| 59 |
-
# Download the entire repository
|
| 60 |
-
local_repo_path = snapshot_download(repo_id=repo_id, repo_type="model")
|
| 61 |
-
|
| 62 |
-
# Construct the paths to the subfolders
|
| 63 |
-
local_folder = os.path.join(local_repo_path, subfolder)
|
| 64 |
-
local_folder2 = os.path.join(local_repo_path, subfolder2) # Path to the ip_adapter dir
|
| 65 |
-
|
| 66 |
-
print(f"Image encoder downloaded to: {local_folder}")
|
| 67 |
-
print(f"IP Adapter files downloaded to: {local_folder2}")
|
| 68 |
-
|
| 69 |
-
# Construct the path to the ip-adapter_sdxl.bin file
|
| 70 |
-
#ip_ckpt = os.path.join(local_folder2, "ip-adapter_sdxl.bin") # Correct path
|
| 71 |
-
ip_ckpt = os.path.join(local_folder2, "ip-adapter_sdxl_vit-h.bin") # Correct path
|
| 72 |
-
|
| 73 |
-
print(f"IP Adapter checkpoint path: {ip_ckpt}")
|
| 74 |
-
ip_model = IPAdapterXL(pipe, local_folder, ip_ckpt, device)
|
| 75 |
-
|
| 76 |
-
upscaler_2 = UpscaleWithModel.from_pretrained("Kim2091/ClearRealityV1").to(torch.device("cuda:0"))
|
| 77 |
-
|
| 78 |
-
|
| 79 |
checkpoint = "microsoft/Phi-3.5-mini-instruct"
|
| 80 |
#vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
| 81 |
vae = AutoencoderKL.from_pretrained("ford442/sdxl-vae-bf16")
|
|
@@ -111,6 +87,33 @@ tokenizer.tokenizer_legacy=False
|
|
| 111 |
model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map='balanced')
|
| 112 |
#model = torch.compile(model)
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
def filter_text(text,phraseC):
|
| 115 |
"""Filters out the text up to and including 'Rewritten Prompt:'."""
|
| 116 |
phrase = "Rewritten Prompt:"
|
|
|
|
| 52 |
torch_dtype = torch.bfloat16
|
| 53 |
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
checkpoint = "microsoft/Phi-3.5-mini-instruct"
|
| 56 |
#vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
| 57 |
vae = AutoencoderKL.from_pretrained("ford442/sdxl-vae-bf16")
|
|
|
|
| 87 |
model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map='balanced')
|
| 88 |
#model = torch.compile(model)
|
| 89 |
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
repo_id = "ford442/SDXL-IP_ADAPTER"
|
| 93 |
+
subfolder = "image_encoder"
|
| 94 |
+
subfolder2 = "ip_adapter"
|
| 95 |
+
|
| 96 |
+
# Download the entire repository
|
| 97 |
+
local_repo_path = snapshot_download(repo_id=repo_id, repo_type="model")
|
| 98 |
+
|
| 99 |
+
# Construct the paths to the subfolders
|
| 100 |
+
local_folder = os.path.join(local_repo_path, subfolder)
|
| 101 |
+
local_folder2 = os.path.join(local_repo_path, subfolder2) # Path to the ip_adapter dir
|
| 102 |
+
|
| 103 |
+
print(f"Image encoder downloaded to: {local_folder}")
|
| 104 |
+
print(f"IP Adapter files downloaded to: {local_folder2}")
|
| 105 |
+
|
| 106 |
+
# Construct the path to the ip-adapter_sdxl.bin file
|
| 107 |
+
#ip_ckpt = os.path.join(local_folder2, "ip-adapter_sdxl.bin") # Correct path
|
| 108 |
+
ip_ckpt = os.path.join(local_folder2, "ip-adapter_sdxl_vit-h.bin") # Correct path
|
| 109 |
+
|
| 110 |
+
print(f"IP Adapter checkpoint path: {ip_ckpt}")
|
| 111 |
+
ip_model = IPAdapterXL(pipe, local_folder, ip_ckpt, device)
|
| 112 |
+
|
| 113 |
+
upscaler_2 = UpscaleWithModel.from_pretrained("Kim2091/ClearRealityV1").to(torch.device("cuda:0"))
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
def filter_text(text,phraseC):
|
| 118 |
"""Filters out the text up to and including 'Rewritten Prompt:'."""
|
| 119 |
phrase = "Rewritten Prompt:"
|