bo.l commited on
Commit
3ba81e2
·
1 Parent(s): 7eff547

update model

Browse files
Files changed (2) hide show
  1. app.py +5 -2
  2. requirements.txt +2 -1
app.py CHANGED
@@ -6,6 +6,8 @@ from kontext.pipeline_flux_kontext import FluxKontextPipeline
6
  from kontext.scheduling_flow_match_euler_discrete import FlowMatchEulerDiscreteScheduler
7
  from diffusers import FluxTransformer2DModel
8
  import torch
 
 
9
 
10
  def resize_by_bucket(images_pil, resolution=512):
11
  assert len(images_pil) > 0, "images_pil 不能为空"
@@ -49,8 +51,9 @@ flux_pipeline.vae.to(device).to(torch.bfloat16)
49
  flux_pipeline.text_encoder.to(device).to(torch.bfloat16)
50
  flux_pipeline.text_encoder_2.to(device).to(torch.bfloat16)
51
  flux_pipeline.scheduler.config.stochastic_sampling = False
52
- finetuned_path = "NoobDoge/Multi_Ref"
53
- flux_pipeline.transformer = FluxTransformer2DModel.from_pretrained(finetuned_path,subfolder='transformer', torch_dtype=torch.bfloat16)
 
54
  flux_pipeline.transformer.to(device).to(torch.bfloat16)
55
 
56
  MAX_SEED = np.iinfo(np.int32).max
 
6
  from kontext.scheduling_flow_match_euler_discrete import FlowMatchEulerDiscreteScheduler
7
  from diffusers import FluxTransformer2DModel
8
  import torch
9
+ from huggingface_hub import hf_hub_download
10
+ from safetensors.torch import load_file
11
 
12
  def resize_by_bucket(images_pil, resolution=512):
13
  assert len(images_pil) > 0, "images_pil 不能为空"
 
51
  flux_pipeline.text_encoder.to(device).to(torch.bfloat16)
52
  flux_pipeline.text_encoder_2.to(device).to(torch.bfloat16)
53
  flux_pipeline.scheduler.config.stochastic_sampling = False
54
+ ckpt_path = hf_hub_download("NoobDoge/Multi_Ref_Model", "full_ema_model.safetensors")
55
+ new_weight = load_file(ckpt_path)
56
+ flux_pipeline.transformer.load_state_dict(new_weight)
57
  flux_pipeline.transformer.to(device).to(torch.bfloat16)
58
 
59
  MAX_SEED = np.iinfo(np.int32).max
requirements.txt CHANGED
@@ -4,4 +4,5 @@ invisible_watermark
4
  torch
5
  transformers
6
  xformers
7
- sentencepiece
 
 
4
  torch
5
  transformers
6
  xformers
7
+ sentencepiece
8
+ safetensors