h-siyuan commited on
Commit
993311e
1 Parent(s): 037d4c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -24
app.py CHANGED
@@ -11,8 +11,6 @@ import ast
11
  import os
12
  import numpy as np
13
  from huggingface_hub import hf_hub_download, list_repo_files
14
- import boto3
15
- from botocore.exceptions import NoCredentialsError
16
 
17
  # Define constants
18
  DESCRIPTION = "[ShowUI Demo](https://huggingface.co/showlab/ShowUI-2B)"
@@ -66,22 +64,6 @@ def array_to_image_path(image_array, session_id):
66
  img.save(filename)
67
  return os.path.abspath(filename)
68
 
69
- def upload_to_s3(file_name, bucket, object_name=None):
70
- """Upload a file to an S3 bucket."""
71
- if object_name is None:
72
- object_name = file_name
73
-
74
- s3 = boto3.client('s3')
75
-
76
- try:
77
- s3.upload_file(file_name, bucket, object_name)
78
- # print(f"successfully upload {file_name}")
79
- return True
80
- except FileNotFoundError:
81
- return False
82
- except NoCredentialsError:
83
- return False
84
-
85
  def crop_image(image_path, click_xy, crop_factor=0.5):
86
  """Crop the image around the click point."""
87
  image = Image.open(image_path)
@@ -175,10 +157,6 @@ def save_and_upload_data(image, query, session_id, is_example_image, votes=None)
175
 
176
  with open(local_file_name, "w") as f:
177
  json.dump(data, f)
178
-
179
- # Upload JSON and image to S3
180
- upload_to_s3(local_file_name, 'altair.storage', object_name=f"ootb/{local_file_name}")
181
- upload_to_s3(image_file_name, 'altair.storage', object_name=f"ootb/{image_file_name}")
182
 
183
  return data
184
 
@@ -199,8 +177,6 @@ def update_vote(vote_type, session_id, is_example_image):
199
 
200
  with open(local_file_name, "w") as f:
201
  json.dump(data, f)
202
-
203
- upload_to_s3(local_file_name, 'altair.storage', object_name=f"ootb/{local_file_name}")
204
 
205
  return f"Thank you for your {vote_type}!"
206
 
 
11
  import os
12
  import numpy as np
13
  from huggingface_hub import hf_hub_download, list_repo_files
 
 
14
 
15
  # Define constants
16
  DESCRIPTION = "[ShowUI Demo](https://huggingface.co/showlab/ShowUI-2B)"
 
64
  img.save(filename)
65
  return os.path.abspath(filename)
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  def crop_image(image_path, click_xy, crop_factor=0.5):
68
  """Crop the image around the click point."""
69
  image = Image.open(image_path)
 
157
 
158
  with open(local_file_name, "w") as f:
159
  json.dump(data, f)
 
 
 
 
160
 
161
  return data
162
 
 
177
 
178
  with open(local_file_name, "w") as f:
179
  json.dump(data, f)
 
 
180
 
181
  return f"Thank you for your {vote_type}!"
182