Spaces:
Running
on
A10G
Running
on
A10G
Lawrence-cj
commited on
Commit
·
21ea13a
1
Parent(s):
5ecd0a6
update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,9 @@
|
|
1 |
#!/usr/bin/env python
|
2 |
from __future__ import annotations
|
|
|
3 |
import os
|
4 |
-
import sys
|
5 |
-
from pathlib import Path
|
6 |
-
current_file_path = Path(__file__).resolve()
|
7 |
-
sys.path.insert(0, str(current_file_path.parent.parent))
|
8 |
import random
|
|
|
9 |
import gradio as gr
|
10 |
import numpy as np
|
11 |
import uuid
|
@@ -30,11 +28,9 @@ CACHE_EXAMPLES = torch.cuda.is_available() and os.getenv("CACHE_EXAMPLES", "1")
|
|
30 |
MAX_IMAGE_SIZE = int(os.getenv("MAX_IMAGE_SIZE", "2048"))
|
31 |
USE_TORCH_COMPILE = os.getenv("USE_TORCH_COMPILE", "0") == "1"
|
32 |
ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"
|
33 |
-
PORT = int(os.getenv("DEMO_PORT", "15432"))
|
34 |
|
35 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
36 |
|
37 |
-
|
38 |
style_list = [
|
39 |
{
|
40 |
"name": "(No style)",
|
@@ -94,6 +90,7 @@ STYLE_NAMES = list(styles.keys())
|
|
94 |
DEFAULT_STYLE_NAME = "(No style)"
|
95 |
NUM_IMAGES_PER_PROMPT = 1
|
96 |
|
|
|
97 |
def apply_style(style_name: str, positive: str, negative: str = "") -> Tuple[str, str]:
|
98 |
p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
|
99 |
if not negative:
|
@@ -128,10 +125,7 @@ if torch.cuda.is_available():
|
|
128 |
|
129 |
|
130 |
def save_image(img):
|
131 |
-
unique_name = str(uuid.uuid4()) +
|
132 |
-
save_path = os.path.join(f'output/online_demo_img/{datetime.now().date()}')
|
133 |
-
os.makedirs(save_path, exist_ok=True)
|
134 |
-
unique_name = os.path.join(save_path, unique_name)
|
135 |
img.save(unique_name)
|
136 |
return unique_name
|
137 |
|
@@ -192,7 +186,7 @@ examples = [
|
|
192 |
"The parametric hotel lobby is a sleek and modern space with plenty of natural light. The lobby is spacious and open with a variety of seating options. The front desk is a sleek white counter with a parametric design. The walls are a light blue color with parametric patterns. The floor is a light wood color with a parametric design. There are plenty of plants and flowers throughout the space. The overall effect is a calm and relaxing space. occlusion, moody, sunset, concept art, octane rendering, 8k, highly detailed, concept art, highly detailed, beautiful scenery, cinematic, beautiful light, hyperreal, octane render, hdr, long exposure, 8K, realistic, fog, moody, fire and explosions, smoke, 50mm f2.8",
|
193 |
]
|
194 |
|
195 |
-
with gr.Blocks(css="
|
196 |
gr.Markdown(DESCRIPTION)
|
197 |
gr.DuplicateButton(
|
198 |
value="Duplicate Space for private use",
|
|
|
1 |
#!/usr/bin/env python
|
2 |
from __future__ import annotations
|
3 |
+
|
4 |
import os
|
|
|
|
|
|
|
|
|
5 |
import random
|
6 |
+
import uuid
|
7 |
import gradio as gr
|
8 |
import numpy as np
|
9 |
import uuid
|
|
|
28 |
MAX_IMAGE_SIZE = int(os.getenv("MAX_IMAGE_SIZE", "2048"))
|
29 |
USE_TORCH_COMPILE = os.getenv("USE_TORCH_COMPILE", "0") == "1"
|
30 |
ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"
|
|
|
31 |
|
32 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
33 |
|
|
|
34 |
style_list = [
|
35 |
{
|
36 |
"name": "(No style)",
|
|
|
90 |
DEFAULT_STYLE_NAME = "(No style)"
|
91 |
NUM_IMAGES_PER_PROMPT = 1
|
92 |
|
93 |
+
|
94 |
def apply_style(style_name: str, positive: str, negative: str = "") -> Tuple[str, str]:
|
95 |
p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
|
96 |
if not negative:
|
|
|
125 |
|
126 |
|
127 |
def save_image(img):
|
128 |
+
unique_name = str(uuid.uuid4()) + ".png"
|
|
|
|
|
|
|
129 |
img.save(unique_name)
|
130 |
return unique_name
|
131 |
|
|
|
186 |
"The parametric hotel lobby is a sleek and modern space with plenty of natural light. The lobby is spacious and open with a variety of seating options. The front desk is a sleek white counter with a parametric design. The walls are a light blue color with parametric patterns. The floor is a light wood color with a parametric design. There are plenty of plants and flowers throughout the space. The overall effect is a calm and relaxing space. occlusion, moody, sunset, concept art, octane rendering, 8k, highly detailed, concept art, highly detailed, beautiful scenery, cinematic, beautiful light, hyperreal, octane render, hdr, long exposure, 8K, realistic, fog, moody, fire and explosions, smoke, 50mm f2.8",
|
187 |
]
|
188 |
|
189 |
+
with gr.Blocks(css="style.css") as demo:
|
190 |
gr.Markdown(DESCRIPTION)
|
191 |
gr.DuplicateButton(
|
192 |
value="Duplicate Space for private use",
|