Spaces:
Running
on
Zero
Running
on
Zero
fix typo
Browse files
app.py
CHANGED
@@ -854,26 +854,26 @@ def ncut_run(
|
|
854 |
|
855 |
def _ncut_run(*args, **kwargs):
|
856 |
n_ret = kwargs.pop("n_ret", 1)
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
|
861 |
-
|
862 |
|
863 |
-
|
864 |
-
|
865 |
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
ret = ncut_run(*args, **kwargs)
|
875 |
-
ret = list(ret)[:n_ret] + [ret[-1]]
|
876 |
-
return ret
|
877 |
|
878 |
if USE_HUGGINGFACE_ZEROGPU:
|
879 |
@spaces.GPU(duration=30)
|
|
|
854 |
|
855 |
def _ncut_run(*args, **kwargs):
|
856 |
n_ret = kwargs.pop("n_ret", 1)
|
857 |
+
try:
|
858 |
+
if torch.cuda.is_available():
|
859 |
+
torch.cuda.empty_cache()
|
860 |
|
861 |
+
ret = ncut_run(*args, **kwargs)
|
862 |
|
863 |
+
if torch.cuda.is_available():
|
864 |
+
torch.cuda.empty_cache()
|
865 |
|
866 |
+
ret = list(ret)[:n_ret] + [ret[-1]]
|
867 |
+
return ret
|
868 |
+
except Exception as e:
|
869 |
+
gr.Error(str(e))
|
870 |
+
if torch.cuda.is_available():
|
871 |
+
torch.cuda.empty_cache()
|
872 |
+
return *(None for _ in range(n_ret)), "Error: " + str(e)
|
873 |
+
|
874 |
+
# ret = ncut_run(*args, **kwargs)
|
875 |
+
# ret = list(ret)[:n_ret] + [ret[-1]]
|
876 |
+
# return ret
|
877 |
|
878 |
if USE_HUGGINGFACE_ZEROGPU:
|
879 |
@spaces.GPU(duration=30)
|