Kunpeng Song commited on
Commit
08b087c
1 Parent(s): f9b5427
Files changed (2) hide show
  1. .DS_Store +0 -0
  2. app.py +6 -4
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
app.py CHANGED
@@ -15,19 +15,21 @@ device = torch.device('cuda')
15
  seed_everything(0)
16
  args = parse_args()
17
 
18
- model = None
19
 
20
  @spaces.GPU
21
  def inference(rgb, subject, prompt, strength, seed):
22
  global model
 
 
23
  seed = int(seed) if seed else 0
24
  seed = seed if not seed == 0 else np.random.randint(0,1000)
25
 
26
- if model is None:
27
  from model_lib.modules import MoMA_main_modal
28
- model = MoMA_main_modal(args).to(device, dtype=torch.float16)
29
 
30
- generated_image = model.generate_images(rgb, subject, prompt, strength=strength, seed=seed)
31
 
32
  return generated_image
33
 
 
15
  seed_everything(0)
16
  args = parse_args()
17
 
18
+ model = []
19
 
20
  @spaces.GPU
21
  def inference(rgb, subject, prompt, strength, seed):
22
  global model
23
+ print(f"model length: {len(model)}")
24
+
25
  seed = int(seed) if seed else 0
26
  seed = seed if not seed == 0 else np.random.randint(0,1000)
27
 
28
+ if len(model) == 0:
29
  from model_lib.modules import MoMA_main_modal
30
+ model += [MoMA_main_modal(args).to(device, dtype=torch.float16)]
31
 
32
+ generated_image = model[0].generate_images(rgb, subject, prompt, strength=strength, seed=seed)
33
 
34
  return generated_image
35