ohayonguy
commited on
Commit
·
e0edc6d
1
Parent(s):
a8b5960
trying to fix cuda init
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import os
|
2 |
-
|
|
|
3 |
import cv2
|
4 |
import gradio as gr
|
5 |
import torch
|
@@ -13,8 +14,7 @@ from lightning_models.mmse_rectified_flow import MMSERectifiedFlow
|
|
13 |
|
14 |
torch.set_grad_enabled(False)
|
15 |
|
16 |
-
|
17 |
-
os.environ['SPACES_ZERO_GPU'] = "1"
|
18 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
19 |
|
20 |
if not os.path.exists('pretrained_models'):
|
@@ -89,8 +89,6 @@ def inference(img, aligned, scale):
|
|
89 |
if scale > 4:
|
90 |
scale = 4 # avoid too large scale value
|
91 |
try:
|
92 |
-
|
93 |
-
extension = os.path.splitext(os.path.basename(str(img)))[1]
|
94 |
img = cv2.imread(img, cv2.IMREAD_UNCHANGED)
|
95 |
if len(img.shape) == 3 and img.shape[2] == 4:
|
96 |
img_mode = 'RGBA'
|
|
|
1 |
import os
|
2 |
+
if os.getenv('SPACES_ZERO_GPU') == "true":
|
3 |
+
os.environ['SPACES_ZERO_GPU'] = "1"
|
4 |
import cv2
|
5 |
import gradio as gr
|
6 |
import torch
|
|
|
14 |
|
15 |
torch.set_grad_enabled(False)
|
16 |
|
17 |
+
|
|
|
18 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
19 |
|
20 |
if not os.path.exists('pretrained_models'):
|
|
|
89 |
if scale > 4:
|
90 |
scale = 4 # avoid too large scale value
|
91 |
try:
|
|
|
|
|
92 |
img = cv2.imread(img, cv2.IMREAD_UNCHANGED)
|
93 |
if len(img.shape) == 3 and img.shape[2] == 4:
|
94 |
img_mode = 'RGBA'
|