JiayiGuo821 commited on
Commit
a2590fc
1 Parent(s): d8ecbfe
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -222,6 +222,7 @@ def remove_decoupled_file(path, exta='.mp4', extb='.json'):
222
  [os.remove(osp.join(path, tagi+exta)) for tagi in tag_a_extra]
223
  [os.remove(osp.join(path, tagi+extb)) for tagi in tag_b_extra]
224
 
 
225
  @torch.no_grad()
226
  def t2i_core(model, xt, emb, nemb, step=30, cfg_scale=7.5, return_list=False):
227
  from nulltxtinv_wrapper import diffusion_step, latent2image
@@ -319,6 +320,7 @@ class wrapper(object):
319
  # main #
320
  ########
321
 
 
322
  def ddiminv(self, img, cfgdict):
323
  txt, step, cfg_scale = cfgdict['txt'], cfgdict['step'], cfgdict['cfg_scale']
324
  from nulltxtinv_wrapper import NullInversion
@@ -333,6 +335,7 @@ class wrapper(object):
333
  'xt': xt, 'emb': emb, 'nemb': nemb,}
334
  return data
335
 
 
336
  def nullinv_or_loadcache(self, img, cfgdict, force_reinvert=False):
337
  hash = hash_pilim(img) + "--" + hash_cfgdict(cfgdict)
338
  cdir = self.cache_inverse_folder
@@ -373,6 +376,7 @@ class wrapper(object):
373
  'xt' : xt, 'emb' : emb, 'nemb' : nemb,}
374
  return data
375
 
 
376
  def nullinvdual_or_loadcachedual(self, img0, img1, cfgdict, force_reinvert=False):
377
  hash = hash_pilim(img0) + "--" + hash_pilim(img1) + "--" + hash_cfgdict(cfgdict)
378
  cdir = self.cache_inverse_folder
@@ -437,6 +441,7 @@ class wrapper(object):
437
  'xt' : xt1, 'emb' : emb1, 'nemb' : nemb,}
438
  return data0, data1
439
 
 
440
  def image_inversion(
441
  self, img, txt,
442
  cfg_scale, step,
@@ -463,6 +468,7 @@ class wrapper(object):
463
 
464
  return img_inv
465
 
 
466
  def image_editing(
467
  self, img, txt_0, txt_1,
468
  cfg_scale, step, thresh,
@@ -486,6 +492,7 @@ class wrapper(object):
486
 
487
  return img_edited
488
 
 
489
  def general_interpolation(
490
  self, xset0, xset1,
491
  cfg_scale, step, tlist,):
 
222
  [os.remove(osp.join(path, tagi+exta)) for tagi in tag_a_extra]
223
  [os.remove(osp.join(path, tagi+extb)) for tagi in tag_b_extra]
224
 
225
+ @spaces.GPU()
226
  @torch.no_grad()
227
  def t2i_core(model, xt, emb, nemb, step=30, cfg_scale=7.5, return_list=False):
228
  from nulltxtinv_wrapper import diffusion_step, latent2image
 
320
  # main #
321
  ########
322
 
323
+ @spaces.GPU()
324
  def ddiminv(self, img, cfgdict):
325
  txt, step, cfg_scale = cfgdict['txt'], cfgdict['step'], cfgdict['cfg_scale']
326
  from nulltxtinv_wrapper import NullInversion
 
335
  'xt': xt, 'emb': emb, 'nemb': nemb,}
336
  return data
337
 
338
+ @spaces.GPU()
339
  def nullinv_or_loadcache(self, img, cfgdict, force_reinvert=False):
340
  hash = hash_pilim(img) + "--" + hash_cfgdict(cfgdict)
341
  cdir = self.cache_inverse_folder
 
376
  'xt' : xt, 'emb' : emb, 'nemb' : nemb,}
377
  return data
378
 
379
+ @spaces.GPU()
380
  def nullinvdual_or_loadcachedual(self, img0, img1, cfgdict, force_reinvert=False):
381
  hash = hash_pilim(img0) + "--" + hash_pilim(img1) + "--" + hash_cfgdict(cfgdict)
382
  cdir = self.cache_inverse_folder
 
441
  'xt' : xt1, 'emb' : emb1, 'nemb' : nemb,}
442
  return data0, data1
443
 
444
+ @spaces.GPU()
445
  def image_inversion(
446
  self, img, txt,
447
  cfg_scale, step,
 
468
 
469
  return img_inv
470
 
471
+ @spaces.GPU()
472
  def image_editing(
473
  self, img, txt_0, txt_1,
474
  cfg_scale, step, thresh,
 
492
 
493
  return img_edited
494
 
495
+ @spaces.GPU()
496
  def general_interpolation(
497
  self, xset0, xset1,
498
  cfg_scale, step, tlist,):