Spaces:
Running
on
Zero
Running
on
Zero
Kunpeng Song
commited on
Commit
·
f25fd61
1
Parent(s):
18976e3
fix zero
Browse files
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
app.py
CHANGED
@@ -15,13 +15,22 @@ device = torch.device('cuda')
|
|
15 |
seed_everything(0)
|
16 |
args = parse_args()
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@spaces.GPU
|
22 |
def inference(rgb, subject, prompt, strength, seed):
|
23 |
seed = int(seed) if seed else 0
|
24 |
seed = seed if not seed == 0 else np.random.randint(0,1000)
|
|
|
|
|
|
|
|
|
25 |
generated_image = model.generate_images(rgb, subject, prompt, strength=strength, seed=seed)
|
26 |
return generated_image
|
27 |
|
|
|
15 |
seed_everything(0)
|
16 |
args = parse_args()
|
17 |
|
18 |
+
model = None
|
19 |
+
|
20 |
+
@spaces.GPU
|
21 |
+
def load_model(model):
|
22 |
+
from model_lib.modules import MoMA_main_modal
|
23 |
+
model = MoMA_main_modal(args).to(device, dtype=torch.float16)
|
24 |
+
return model
|
25 |
|
26 |
@spaces.GPU
|
27 |
def inference(rgb, subject, prompt, strength, seed):
|
28 |
seed = int(seed) if seed else 0
|
29 |
seed = seed if not seed == 0 else np.random.randint(0,1000)
|
30 |
+
|
31 |
+
if model is None:
|
32 |
+
model = load_model(model)
|
33 |
+
|
34 |
generated_image = model.generate_images(rgb, subject, prompt, strength=strength, seed=seed)
|
35 |
return generated_image
|
36 |
|