Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,5 @@
|
|
1 |
import spaces # If using Hugging Face Spaces
|
2 |
import os
|
3 |
-
import torch
|
4 |
-
import gradio as gr
|
5 |
-
|
6 |
# ## GGUF MOD: Unused environment variables for PyTorch have been removed.
|
7 |
# ## GGUF MOD: ctransformers handles its own memory and GPU management.
|
8 |
os.putenv('PYTORCH_NVML_BASED_CUDA_CHECK','1')
|
@@ -14,11 +11,16 @@ os.putenv('PYTORCH_NVML_BASED_CUDA_CHECK','1')
|
|
14 |
# os.environ['PYTORCH_CUDA_ALLOC_CONF'] = ','.join(alloc_conf_parts)
|
15 |
# os.environ["SAFETENSORS_FAST_GPU"] = "1"
|
16 |
os.putenv('HF_HUB_ENABLE_HF_TRANSFER','1')
|
|
|
|
|
|
|
|
|
17 |
|
18 |
# ## GGUF MOD: Import AutoModelForCausalLM from ctransformers instead of transformers.
|
19 |
# ## GGUF MOD: BitsAndBytesConfig is no longer needed.
|
20 |
from ctransformers import AutoModelForCausalLM
|
21 |
from transformers import AutoTokenizer
|
|
|
22 |
|
23 |
# ## GGUF MOD: PyTorch backend settings are not used by ctransformers.
|
24 |
torch.backends.cuda.matmul.allow_tf32 = True
|
@@ -46,6 +48,9 @@ print("Loading GGUF model...")
|
|
46 |
# leading to much faster inference. Adjust this number based on your VRAM.
|
47 |
# - hf=True: This tells ctransformers to download from the Hugging Face Hub.
|
48 |
|
|
|
|
|
|
|
49 |
def loadModel():
|
50 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
51 |
model = AutoModelForCausalLM.from_pretrained(
|
@@ -58,10 +63,7 @@ def loadModel():
|
|
58 |
)
|
59 |
return model
|
60 |
|
61 |
-
|
62 |
-
def device_wake():
|
63 |
-
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
64 |
-
device_wake()
|
65 |
|
66 |
model = loadModel()
|
67 |
print("GGUF Model loaded successfully.")
|
|
|
1 |
import spaces # If using Hugging Face Spaces
|
2 |
import os
|
|
|
|
|
|
|
3 |
# ## GGUF MOD: Unused environment variables for PyTorch have been removed.
|
4 |
# ## GGUF MOD: ctransformers handles its own memory and GPU management.
|
5 |
os.putenv('PYTORCH_NVML_BASED_CUDA_CHECK','1')
|
|
|
11 |
# os.environ['PYTORCH_CUDA_ALLOC_CONF'] = ','.join(alloc_conf_parts)
|
12 |
# os.environ["SAFETENSORS_FAST_GPU"] = "1"
|
13 |
os.putenv('HF_HUB_ENABLE_HF_TRANSFER','1')
|
14 |
+
import torch
|
15 |
+
import gradio as gr
|
16 |
+
|
17 |
+
|
18 |
|
19 |
# ## GGUF MOD: Import AutoModelForCausalLM from ctransformers instead of transformers.
|
20 |
# ## GGUF MOD: BitsAndBytesConfig is no longer needed.
|
21 |
from ctransformers import AutoModelForCausalLM
|
22 |
from transformers import AutoTokenizer
|
23 |
+
from image_gen_aux import UpscaleWithModel
|
24 |
|
25 |
# ## GGUF MOD: PyTorch backend settings are not used by ctransformers.
|
26 |
torch.backends.cuda.matmul.allow_tf32 = True
|
|
|
48 |
# leading to much faster inference. Adjust this number based on your VRAM.
|
49 |
# - hf=True: This tells ctransformers to download from the Hugging Face Hub.
|
50 |
|
51 |
+
upscaler = UpscaleWithModel.from_pretrained("Kim2091/ClearRealityV1").to(torch.device('cuda'))
|
52 |
+
upscaler.to(torch.device('cpu'))
|
53 |
+
|
54 |
def loadModel():
|
55 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
56 |
model = AutoModelForCausalLM.from_pretrained(
|
|
|
63 |
)
|
64 |
return model
|
65 |
|
66 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
|
|
|
|
|
|
67 |
|
68 |
model = loadModel()
|
69 |
print("GGUF Model loaded successfully.")
|