wusize commited on
Commit
ea40ef0
·
verified ·
1 Parent(s): 866b6f4

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. .idea/workspace.xml +1 -1
  2. app.py +8 -1
.idea/workspace.xml CHANGED
@@ -54,7 +54,7 @@
54
  <option name="number" value="Default" />
55
  <option name="presentableId" value="Default" />
56
  <updated>1760056680813</updated>
57
- <workItem from="1760056681869" duration="2999000" />
58
  </task>
59
  <servers />
60
  </component>
 
54
  <option name="number" value="Default" />
55
  <option name="presentableId" value="Default" />
56
  <updated>1760056680813</updated>
57
+ <workItem from="1760056681869" duration="3537000" />
58
  </task>
59
  <servers />
60
  </component>
app.py CHANGED
@@ -50,12 +50,19 @@ def center_crop(image):
50
  ##### load model
51
  config = "configs/pipelines/stage_2_base.py"
52
  config = Config.fromfile(config)
53
- model = BUILDER.build(config.model).cuda().bfloat16().eval()
54
  checkpoint_path = "checkpoints/Puffin-Base.pth"
55
  checkpoint = torch.load(checkpoint_path, map_location='cpu')
56
  _ = model.load_state_dict(checkpoint, strict=False)
57
  _ = model.vae.load_state_dict(torch.load('checkpoints/vae.pth', map_location='cpu'), strict=True)
58
 
 
 
 
 
 
 
 
59
  def fig_to_image(fig):
60
  buf = io.BytesIO()
61
  fig.savefig(buf, format='png', bbox_inches='tight', pad_inches=0)
 
50
  ##### load model
51
  config = "configs/pipelines/stage_2_base.py"
52
  config = Config.fromfile(config)
53
+ model = BUILDER.build(config.model).eval()
54
  checkpoint_path = "checkpoints/Puffin-Base.pth"
55
  checkpoint = torch.load(checkpoint_path, map_location='cpu')
56
  _ = model.load_state_dict(checkpoint, strict=False)
57
  _ = model.vae.load_state_dict(torch.load('checkpoints/vae.pth', map_location='cpu'), strict=True)
58
 
59
+
60
+ if torch.cuda.is_available():
61
+ harmon_model = model.to(torch.bfloat16).cuda()
62
+ else:
63
+ harmon_model = model.to(torch.float32)
64
+
65
+
66
  def fig_to_image(fig):
67
  buf = io.BytesIO()
68
  fig.savefig(buf, format='png', bbox_inches='tight', pad_inches=0)