Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -51,7 +51,8 @@ from multiprocessing import Process,Queue,set_start_method,get_context
|
|
| 51 |
class ModelFailure:
|
| 52 |
pass
|
| 53 |
|
| 54 |
-
gemma_path = "
|
|
|
|
| 55 |
#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
|
| 56 |
# Adapted from pipelines.StableDiffusionXLPipeline.encode_prompt
|
| 57 |
def encode_prompt(prompt_batch, text_encoder, tokenizer, proportion_empty_prompts, is_train=True):
|
|
@@ -118,16 +119,16 @@ def model_main(args, master_port, rank, request_queue, response_queue, mp_barrie
|
|
| 118 |
dtype = {"bf16": torch.bfloat16, "fp16": torch.float16, "fp32": torch.float32}[args.precision]
|
| 119 |
|
| 120 |
text_encoder = AutoModel.from_pretrained(
|
| 121 |
-
|
| 122 |
).eval()
|
| 123 |
cap_feat_dim = text_encoder.config.hidden_size
|
| 124 |
if args.num_gpus > 1:
|
| 125 |
raise NotImplementedError("Inference with >1 GPUs not yet supported")
|
| 126 |
|
| 127 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
| 128 |
tokenizer.padding_side = "right"
|
| 129 |
|
| 130 |
-
vae = AutoencoderKL.from_pretrained(
|
| 131 |
|
| 132 |
print(f"Creating DiT: {train_args.model}")
|
| 133 |
|
|
|
|
| 51 |
class ModelFailure:
|
| 52 |
pass
|
| 53 |
|
| 54 |
+
gemma_path = "/home/user/app/checkpoints/text_encoder"
|
| 55 |
+
flux_path = "/home/user/app/checkpoints/vae"
|
| 56 |
#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
|
| 57 |
# Adapted from pipelines.StableDiffusionXLPipeline.encode_prompt
|
| 58 |
def encode_prompt(prompt_batch, text_encoder, tokenizer, proportion_empty_prompts, is_train=True):
|
|
|
|
| 119 |
dtype = {"bf16": torch.bfloat16, "fp16": torch.float16, "fp32": torch.float32}[args.precision]
|
| 120 |
|
| 121 |
text_encoder = AutoModel.from_pretrained(
|
| 122 |
+
gemma_path, torch_dtype=dtype, device_map="cuda", token=hf_token
|
| 123 |
).eval()
|
| 124 |
cap_feat_dim = text_encoder.config.hidden_size
|
| 125 |
if args.num_gpus > 1:
|
| 126 |
raise NotImplementedError("Inference with >1 GPUs not yet supported")
|
| 127 |
|
| 128 |
+
tokenizer = AutoTokenizer.from_pretrained(gemma_path, token=hf_token)
|
| 129 |
tokenizer.padding_side = "right"
|
| 130 |
|
| 131 |
+
vae = AutoencoderKL.from_pretrained(flux_path, subfolder="vae", token=hf_token).cuda()
|
| 132 |
|
| 133 |
print(f"Creating DiT: {train_args.model}")
|
| 134 |
|