Spaces:
Running
on
Zero
Running
on
Zero
Kunpeng Song
commited on
Commit
·
750254c
1
Parent(s):
08b087c
fix zero
Browse files
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
app.py
CHANGED
@@ -6,7 +6,7 @@ import numpy as np
|
|
6 |
import torch
|
7 |
from pytorch_lightning import seed_everything
|
8 |
from model_lib.utils import parse_args
|
9 |
-
|
10 |
os.environ["CUDA_VISIBLE_DEVICES"]="0"
|
11 |
|
12 |
title = "MoMA"
|
@@ -15,22 +15,14 @@ device = torch.device('cuda')
|
|
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 |
|
36 |
gr.Interface(
|
|
|
6 |
import torch
|
7 |
from pytorch_lightning import seed_everything
|
8 |
from model_lib.utils import parse_args
|
9 |
+
from model_lib.modules import MoMA_main_modal
|
10 |
os.environ["CUDA_VISIBLE_DEVICES"]="0"
|
11 |
|
12 |
title = "MoMA"
|
|
|
15 |
seed_everything(0)
|
16 |
args = parse_args()
|
17 |
|
18 |
+
model = MoMA_main_modal(args).to(device, dtype=torch.float16)
|
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 |
+
generated_image = model.generate_images(rgb, subject, prompt, strength=strength, seed=seed)
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return generated_image
|
27 |
|
28 |
gr.Interface(
|