ksort commited on
Commit
6dc341c
1 Parent(s): b2a20c6

Update ssh

Browse files
Files changed (1) hide show
  1. serve/upload.py +7 -10
serve/upload.py CHANGED
@@ -26,17 +26,14 @@ def get_image_from_url(image_url):
26
 
27
  def get_random_mscoco_prompt():
28
  global sftp_client
29
- files = sftp_client.listdir(SSH_MSCOCO)
30
- txt_files = [file for file in files if file.endswith('.txt')]
31
 
32
- selected_files = random.sample(txt_files, 1) # get one prompt
33
-
34
- for file in selected_files:
35
- remote_file_path = os.path.join(SSH_MSCOCO, file)
36
- with sftp_client.file(remote_file_path, 'r') as f:
37
- content = f.read().decode('utf-8')
38
- print(f"Content of {file}:")
39
- print("\n")
40
  return content
41
 
42
 
 
26
 
27
  def get_random_mscoco_prompt():
28
  global sftp_client
29
+ num = random.randint(0, 2999)
30
+ file = "{}.txt".format(num)
31
 
32
+ remote_file_path = os.path.join(SSH_MSCOCO, file)
33
+ with sftp_client.file(remote_file_path, 'r') as f:
34
+ content = f.read().decode('utf-8')
35
+ print(f"Content of {file}:")
36
+ print("\n")
 
 
 
37
  return content
38
 
39