Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -8,12 +8,13 @@ from PIL import Image
|
|
8 |
# os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
9 |
os.environ["SAFETENSORS_FAST_GPU"] = "1"
|
10 |
os.putenv("HF_HUB_ENABLE_HF_TRANSFER","1")
|
11 |
-
|
12 |
-
|
13 |
|
14 |
# Create the gr.State component *outside* the gr.Blocks context
|
15 |
|
16 |
-
|
|
|
17 |
def init_predictor(task_type: str):
|
18 |
from skyreelsinfer import TaskType
|
19 |
from skyreelsinfer.offload import OffloadConfig
|
@@ -32,7 +33,7 @@ def init_predictor(task_type: str):
|
|
32 |
),
|
33 |
use_multiprocessing=False,
|
34 |
)
|
35 |
-
return
|
36 |
|
37 |
except (RepositoryNotFoundError, RevisionNotFoundError, EntryNotFoundError) as e:
|
38 |
return f"Error: Model not found. Details: {e}", None
|
|
|
8 |
# os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
9 |
os.environ["SAFETENSORS_FAST_GPU"] = "1"
|
10 |
os.putenv("HF_HUB_ENABLE_HF_TRANSFER","1")
|
11 |
+
import torch
|
12 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
13 |
|
14 |
# Create the gr.State component *outside* the gr.Blocks context
|
15 |
|
16 |
+
predictor = gr.State(None)
|
17 |
+
|
18 |
def init_predictor(task_type: str):
|
19 |
from skyreelsinfer import TaskType
|
20 |
from skyreelsinfer.offload import OffloadConfig
|
|
|
33 |
),
|
34 |
use_multiprocessing=False,
|
35 |
)
|
36 |
+
return predictor
|
37 |
|
38 |
except (RepositoryNotFoundError, RevisionNotFoundError, EntryNotFoundError) as e:
|
39 |
return f"Error: Model not found. Details: {e}", None
|