Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -107,9 +107,9 @@ import gc
|
|
107 |
import torch.nn.functional as F
|
108 |
from sageattention import sageattn
|
109 |
|
110 |
-
|
111 |
import pythran
|
112 |
-
|
113 |
with open("pyt.py", "w") as f:
|
114 |
f.write("""
|
115 |
import paramiko
|
@@ -135,12 +135,11 @@ def upload_to_ftp(filename):
|
|
135 |
print(f"FTP upload error: {e}")
|
136 |
|
137 |
""")
|
138 |
-
|
139 |
os.environ['DISTUTILS_USE_SDK'] = '1' # Force setuptools (distutils) to use the installed SDK.
|
140 |
-
subprocess.run(['pythran', './pyt.py', '-DUSE_XSIMD', '-fopenmp', '-march=native'])
|
141 |
import pyt
|
142 |
|
143 |
-
|
144 |
torch.backends.cuda.matmul.allow_tf32 = False
|
145 |
torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction = False
|
146 |
torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = False
|
@@ -468,14 +467,14 @@ def generate_30(
|
|
468 |
rv_image = pipe(**batch_options).images[0]
|
469 |
sd_image_path = f"rv_B_{timestamp}.png"
|
470 |
rv_image.save(sd_image_path,optimize=False,compress_level=0)
|
471 |
-
|
472 |
torch.set_float32_matmul_precision("medium")
|
473 |
with torch.no_grad():
|
474 |
upscale = upscaler(rv_image, tiling=True, tile_width=256, tile_height=256)
|
475 |
downscale1 = upscale.resize((upscale.width // 4, upscale.height // 4), Image.LANCZOS)
|
476 |
downscale_path = f"rv50_upscale_{timestamp}.png"
|
477 |
downscale1.save(downscale_path,optimize=False,compress_level=0)
|
478 |
-
|
479 |
unique_name = str(uuid.uuid4()) + ".png"
|
480 |
os.symlink(sd_image_path, unique_name)
|
481 |
return [unique_name]
|
|
|
107 |
import torch.nn.functional as F
|
108 |
from sageattention import sageattn
|
109 |
|
110 |
+
'''
|
111 |
import pythran
|
112 |
+
paramiko_include_dir = paramiko.get_include()
|
113 |
with open("pyt.py", "w") as f:
|
114 |
f.write("""
|
115 |
import paramiko
|
|
|
135 |
print(f"FTP upload error: {e}")
|
136 |
|
137 |
""")
|
138 |
+
'''
|
139 |
os.environ['DISTUTILS_USE_SDK'] = '1' # Force setuptools (distutils) to use the installed SDK.
|
140 |
+
subprocess.run(['pythran', './pyt.py', '-DUSE_XSIMD', '-fopenmp', '-march=native','-I' + paramiko_include_dir])
|
141 |
import pyt
|
142 |
|
|
|
143 |
torch.backends.cuda.matmul.allow_tf32 = False
|
144 |
torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction = False
|
145 |
torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = False
|
|
|
467 |
rv_image = pipe(**batch_options).images[0]
|
468 |
sd_image_path = f"rv_B_{timestamp}.png"
|
469 |
rv_image.save(sd_image_path,optimize=False,compress_level=0)
|
470 |
+
pyx.upload_to_ftp(sd_image_path)
|
471 |
torch.set_float32_matmul_precision("medium")
|
472 |
with torch.no_grad():
|
473 |
upscale = upscaler(rv_image, tiling=True, tile_width=256, tile_height=256)
|
474 |
downscale1 = upscale.resize((upscale.width // 4, upscale.height // 4), Image.LANCZOS)
|
475 |
downscale_path = f"rv50_upscale_{timestamp}.png"
|
476 |
downscale1.save(downscale_path,optimize=False,compress_level=0)
|
477 |
+
pyx.upload_to_ftp(downscale_path)
|
478 |
unique_name = str(uuid.uuid4()) + ".png"
|
479 |
os.symlink(sd_image_path, unique_name)
|
480 |
return [unique_name]
|