Update app.py
Browse files
app.py
CHANGED
@@ -75,13 +75,13 @@ def upload_to_s3(file_name, bucket, object_name=None):
|
|
75 |
|
76 |
try:
|
77 |
s3.upload_file(file_name, bucket, object_name)
|
78 |
-
print(f"Uploaded {file_name} to {bucket}/{object_name}.")
|
79 |
return True
|
80 |
except FileNotFoundError:
|
81 |
-
print(f"The file {file_name} was not found.")
|
82 |
return False
|
83 |
except NoCredentialsError:
|
84 |
-
print("Credentials not available.")
|
85 |
return False
|
86 |
|
87 |
@spaces.GPU
|
@@ -129,7 +129,7 @@ def run_showui(image, query, session_id):
|
|
129 |
def save_and_upload_data(image_path, query, session_id, is_example_image, votes=None):
|
130 |
"""Save the data to a JSON file and upload to S3."""
|
131 |
if is_example_image:
|
132 |
-
print("Example image used. Skipping upload.")
|
133 |
return
|
134 |
|
135 |
votes = votes or {"upvotes": 0, "downvotes": 0}
|
@@ -153,7 +153,7 @@ def save_and_upload_data(image_path, query, session_id, is_example_image, votes=
|
|
153 |
def update_vote(vote_type, session_id, is_example_image):
|
154 |
"""Update the vote count and re-upload the JSON file."""
|
155 |
if is_example_image:
|
156 |
-
print("Example image used. Skipping vote update.")
|
157 |
return "Example image used. No vote recorded."
|
158 |
|
159 |
local_file_name = f"{session_id}.json"
|
@@ -250,6 +250,7 @@ def build_demo(embed_mode, concurrency_count=1):
|
|
250 |
raise ValueError("No image provided. Please upload an image before submitting.")
|
251 |
|
252 |
session_id = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
|
253 |
is_example_image = isinstance(image, str) and image.startswith("./examples/")
|
254 |
|
255 |
result_image, click_coords, image_path = run_showui(image, query, session_id)
|
|
|
75 |
|
76 |
try:
|
77 |
s3.upload_file(file_name, bucket, object_name)
|
78 |
+
# print(f"Uploaded {file_name} to {bucket}/{object_name}.")
|
79 |
return True
|
80 |
except FileNotFoundError:
|
81 |
+
# print(f"The file {file_name} was not found.")
|
82 |
return False
|
83 |
except NoCredentialsError:
|
84 |
+
# print("Credentials not available.")
|
85 |
return False
|
86 |
|
87 |
@spaces.GPU
|
|
|
129 |
def save_and_upload_data(image_path, query, session_id, is_example_image, votes=None):
|
130 |
"""Save the data to a JSON file and upload to S3."""
|
131 |
if is_example_image:
|
132 |
+
# print("Example image used. Skipping upload.")
|
133 |
return
|
134 |
|
135 |
votes = votes or {"upvotes": 0, "downvotes": 0}
|
|
|
153 |
def update_vote(vote_type, session_id, is_example_image):
|
154 |
"""Update the vote count and re-upload the JSON file."""
|
155 |
if is_example_image:
|
156 |
+
# print("Example image used. Skipping vote update.")
|
157 |
return "Example image used. No vote recorded."
|
158 |
|
159 |
local_file_name = f"{session_id}.json"
|
|
|
250 |
raise ValueError("No image provided. Please upload an image before submitting.")
|
251 |
|
252 |
session_id = datetime.now().strftime("%Y%m%d_%H%M%S")
|
253 |
+
print("image_path:", image)
|
254 |
is_example_image = isinstance(image, str) and image.startswith("./examples/")
|
255 |
|
256 |
result_image, click_coords, image_path = run_showui(image, query, session_id)
|