daidedou commited on
Commit
cddf12c
·
1 Parent(s): cc5f630

Adapt to ZeroGPU?

Browse files
Files changed (2) hide show
  1. app.py +3 -1
  2. zero_shot.py +1 -1
app.py CHANGED
@@ -43,6 +43,7 @@ def _safe_ext(path: str) -> str:
43
  return ext
44
  return os.path.splitext(path)[1].lower()
45
 
 
46
  def convert_and_show(mesh_file):
47
  os.makedirs("tmp/glbs", exist_ok=True)
48
  if mesh_file is None:
@@ -53,6 +54,7 @@ def convert_and_show(mesh_file):
53
  mesh.export(f_name)
54
  return f_name
55
 
 
56
  def convert_and_show_twice(mesh_file_1, mesh_file_2):
57
  return convert_and_show(mesh_file_1), convert_and_show(mesh_file_2)
58
 
@@ -184,9 +186,9 @@ def init_clicked(mesh1_path, mesh2_path,
184
  matcher.reconf(cfg)
185
  if not mesh1_path or not mesh2_path:
186
  raise gr.Error("Please upload both meshes.")
187
- matcher._init()
188
  global datadicts
189
  datadicts = Datadicts(mesh1_path, mesh2_path)
 
190
  shape_dict, target_dict = convert_dict(datadicts.shape_dict, 'cuda'), convert_dict(datadicts.target_dict, 'cuda')
191
  fmap_model_cuda = matcher.fmap_model.cuda()
192
  diff_model_cuda = matcher.diffusion_model
 
43
  return ext
44
  return os.path.splitext(path)[1].lower()
45
 
46
+ @spaces.GPU
47
  def convert_and_show(mesh_file):
48
  os.makedirs("tmp/glbs", exist_ok=True)
49
  if mesh_file is None:
 
54
  mesh.export(f_name)
55
  return f_name
56
 
57
+ @spaces.GPU
58
  def convert_and_show_twice(mesh_file_1, mesh_file_2):
59
  return convert_and_show(mesh_file_1), convert_and_show(mesh_file_2)
60
 
 
186
  matcher.reconf(cfg)
187
  if not mesh1_path or not mesh2_path:
188
  raise gr.Error("Please upload both meshes.")
 
189
  global datadicts
190
  datadicts = Datadicts(mesh1_path, mesh2_path)
191
+ matcher._init()
192
  shape_dict, target_dict = convert_dict(datadicts.shape_dict, 'cuda'), convert_dict(datadicts.target_dict, 'cuda')
193
  fmap_model_cuda = matcher.fmap_model.cuda()
194
  diff_model_cuda = matcher.diffusion_model
zero_shot.py CHANGED
@@ -66,7 +66,7 @@ class Tee:
66
 
67
  class DiffModel:
68
 
69
- def __init__(self, cfg, device="cuda:0"):
70
  if cfg["train_dir"] == "pretrained":
71
  url = "https://huggingface.co/daidedou/diffumatch_model/resolve/main/network-snapshot-041216.pkl"
72
  network_pkl = ensure_pretrained_file(url, "pretrained")
 
66
 
67
  class DiffModel:
68
 
69
+ def __init__(self, cfg, device="cpu"):
70
  if cfg["train_dir"] == "pretrained":
71
  url = "https://huggingface.co/daidedou/diffumatch_model/resolve/main/network-snapshot-041216.pkl"
72
  network_pkl = ensure_pretrained_file(url, "pretrained")