Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,6 @@ import subprocess
|
|
9 |
from tqdm import tqdm
|
10 |
import requests
|
11 |
|
12 |
-
# Assuming spaces is a valid module
|
13 |
-
import spaces
|
14 |
-
|
15 |
def download_file(url, filename):
|
16 |
response = requests.get(url, stream=True)
|
17 |
total_size = int(response.headers.get('content-length', 0))
|
@@ -30,9 +27,8 @@ def download_file(url, filename):
|
|
30 |
def setup_environment():
|
31 |
if not os.path.exists("CCSR"):
|
32 |
print("Cloning CCSR repository...")
|
33 |
-
subprocess.run(["git", "clone", "-b", "dev", "https://github.com/camenduru/CCSR.git"])
|
34 |
|
35 |
-
os.chdir("CCSR")
|
36 |
sys.path.append(os.getcwd())
|
37 |
|
38 |
os.makedirs("weights", exist_ok=True)
|
@@ -47,11 +43,11 @@ def setup_environment():
|
|
47 |
|
48 |
setup_environment()
|
49 |
|
50 |
-
# Importing from the
|
51 |
-
from
|
52 |
-
from
|
53 |
-
from
|
54 |
-
from
|
55 |
|
56 |
config = OmegaConf.load("configs/model/ccsr_stage2.yaml")
|
57 |
model = instantiate_from_config(config)
|
@@ -60,7 +56,6 @@ load_state_dict(model, ckpt, strict=True)
|
|
60 |
model.freeze()
|
61 |
model.to("cuda")
|
62 |
|
63 |
-
@spaces.GPU # Decorate the inference function with @spaces.GPU
|
64 |
@torch.no_grad()
|
65 |
def process(image, steps, t_max, t_min, color_fix_type):
|
66 |
image = Image.open(image).convert("RGB")
|
|
|
9 |
from tqdm import tqdm
|
10 |
import requests
|
11 |
|
|
|
|
|
|
|
12 |
def download_file(url, filename):
|
13 |
response = requests.get(url, stream=True)
|
14 |
total_size = int(response.headers.get('content-length', 0))
|
|
|
27 |
def setup_environment():
|
28 |
if not os.path.exists("CCSR"):
|
29 |
print("Cloning CCSR repository...")
|
30 |
+
subprocess.run(["git", "clone", "-b", "dev", "https://github.com/camenduru/CCSR.git", "."])
|
31 |
|
|
|
32 |
sys.path.append(os.getcwd())
|
33 |
|
34 |
os.makedirs("weights", exist_ok=True)
|
|
|
43 |
|
44 |
setup_environment()
|
45 |
|
46 |
+
# Importing from the current directory
|
47 |
+
from ldm.xformers_state import disable_xformers
|
48 |
+
from model.q_sampler import SpacedSampler
|
49 |
+
from model.ccsr_stage1 import ControlLDM
|
50 |
+
from utils.common import instantiate_from_config, load_state_dict
|
51 |
|
52 |
config = OmegaConf.load("configs/model/ccsr_stage2.yaml")
|
53 |
model = instantiate_from_config(config)
|
|
|
56 |
model.freeze()
|
57 |
model.to("cuda")
|
58 |
|
|
|
59 |
@torch.no_grad()
|
60 |
def process(image, steps, t_max, t_min, color_fix_type):
|
61 |
image = Image.open(image).convert("RGB")
|