Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ from PIL import Image
|
|
7 |
from scipy.interpolate import Rbf
|
8 |
|
9 |
# Load MiDaS depth estimation model
|
10 |
-
midas_model = torch.hub.load("intel-isl/MiDaS", "
|
11 |
midas_model.eval()
|
12 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
13 |
midas_model.to(device)
|
@@ -73,6 +73,9 @@ def blend_design(cloth_img, design_img):
|
|
73 |
return Image.fromarray(cloth_np)
|
74 |
|
75 |
def main(cloth, design):
|
|
|
|
|
|
|
76 |
return blend_design(cloth, design)
|
77 |
|
78 |
iface = gr.Interface(
|
@@ -84,4 +87,4 @@ iface = gr.Interface(
|
|
84 |
)
|
85 |
|
86 |
if __name__ == "__main__":
|
87 |
-
iface.launch()
|
|
|
7 |
from scipy.interpolate import Rbf
|
8 |
|
9 |
# Load MiDaS depth estimation model
|
10 |
+
midas_model = torch.hub.load("intel-isl/MiDaS", "DPT_Hybrid")
|
11 |
midas_model.eval()
|
12 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
13 |
midas_model.to(device)
|
|
|
73 |
return Image.fromarray(cloth_np)
|
74 |
|
75 |
def main(cloth, design):
|
76 |
+
global midas_model
|
77 |
+
if midas_model is None:
|
78 |
+
midas_model = torch.hub.load("intel-isl/MiDaS", "MiDaS_small").to(device).eval()
|
79 |
return blend_design(cloth, design)
|
80 |
|
81 |
iface = gr.Interface(
|
|
|
87 |
)
|
88 |
|
89 |
if __name__ == "__main__":
|
90 |
+
iface.launch(share=True, debug=True, queue=True)
|