ford442 commited on
Commit
2d545c7
·
verified ·
1 Parent(s): 3d598af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -2
app.py CHANGED
@@ -84,6 +84,36 @@ def find_cuda_directories(search_paths=None):
84
  #import hidet
85
  #print(dir(hidet))
86
  #import torch_tensorrt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  import random
89
  import uuid
@@ -435,14 +465,14 @@ def generate_30(
435
  rv_image = pipe(**batch_options).images[0]
436
  sd_image_path = f"rv_B_{timestamp}.png"
437
  rv_image.save(sd_image_path,optimize=False,compress_level=0)
438
- pyx.upload_to_ftp(sd_image_path)
439
  torch.set_float32_matmul_precision("medium")
440
  with torch.no_grad():
441
  upscale = upscaler(rv_image, tiling=True, tile_width=256, tile_height=256)
442
  downscale1 = upscale.resize((upscale.width // 4, upscale.height // 4), Image.LANCZOS)
443
  downscale_path = f"rv50_upscale_{timestamp}.png"
444
  downscale1.save(downscale_path,optimize=False,compress_level=0)
445
- pyx.upload_to_ftp(downscale_path)
446
  unique_name = str(uuid.uuid4()) + ".png"
447
  os.symlink(sd_image_path, unique_name)
448
  return [unique_name]
 
84
  #import hidet
85
  #print(dir(hidet))
86
  #import torch_tensorrt
87
+ import pythran
88
+
89
+ with open("pyt.py", "w") as f:
90
+ f.write("""
91
+ import paramiko
92
+ import os
93
+
94
+ FTP_HOST = os.getenv("FTP_HOST")
95
+ FTP_USER = os.getenv("FTP_USER")
96
+ FTP_PASS = os.getenv("FTP_PASS")
97
+ FTP_DIR = os.getenv("FTP_DIR")
98
+
99
+ def upload_to_ftp(filename):
100
+ try:
101
+ transport = paramiko.Transport((FTP_HOST, 22))
102
+ destination_path=FTP_DIR+filename
103
+ transport.connect(username = FTP_USER, password = FTP_PASS)
104
+ sftp = paramiko.SFTPClient.from_transport(transport)
105
+ sftp.put(filename, destination_path)
106
+ sftp.close()
107
+ transport.close()
108
+ print(f"Uploaded {filename} to FTP server")
109
+ except Exception as e:
110
+ print(f"FTP upload error: {e}")
111
+
112
+ """)
113
+
114
+ os.environ['DISTUTILS_USE_SDK'] = '1' # Force setuptools (distutils) to use the installed SDK.
115
+ subprocess.run(['pythran', './pyt.py'])
116
+ import pyt
117
 
118
  import random
119
  import uuid
 
465
  rv_image = pipe(**batch_options).images[0]
466
  sd_image_path = f"rv_B_{timestamp}.png"
467
  rv_image.save(sd_image_path,optimize=False,compress_level=0)
468
+ pyt.upload_to_ftp(sd_image_path)
469
  torch.set_float32_matmul_precision("medium")
470
  with torch.no_grad():
471
  upscale = upscaler(rv_image, tiling=True, tile_width=256, tile_height=256)
472
  downscale1 = upscale.resize((upscale.width // 4, upscale.height // 4), Image.LANCZOS)
473
  downscale_path = f"rv50_upscale_{timestamp}.png"
474
  downscale1.save(downscale_path,optimize=False,compress_level=0)
475
+ pyt.upload_to_ftp(downscale_path)
476
  unique_name = str(uuid.uuid4()) + ".png"
477
  os.symlink(sd_image_path, unique_name)
478
  return [unique_name]