Spaces:
Running
Running
Commit
·
be1cb60
1
Parent(s):
a775993
updates
Browse files
app.py
CHANGED
|
@@ -253,9 +253,8 @@ def load_gallery(converted_files, uploaded_file):
|
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
-
# @st.cache_data
|
| 257 |
def handle_image_upload_and_gallery_hf(uploaded_files):
|
| 258 |
-
|
| 259 |
if uploaded_files:
|
| 260 |
|
| 261 |
# Clear input image gallery and input list
|
|
@@ -264,11 +263,11 @@ def handle_image_upload_and_gallery_hf(uploaded_files):
|
|
| 264 |
ind_small = 0
|
| 265 |
for uploaded_file in uploaded_files:
|
| 266 |
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
|
| 273 |
|
| 274 |
# Determine the file type
|
|
@@ -319,10 +318,9 @@ def handle_image_upload_and_gallery_hf(uploaded_files):
|
|
| 319 |
images_to_display = st.session_state['input_list_small']
|
| 320 |
show_gallery_small_hf(images_to_display)
|
| 321 |
|
| 322 |
-
|
| 323 |
|
| 324 |
|
| 325 |
-
# @st.cache_data
|
| 326 |
def handle_image_upload_and_gallery():
|
| 327 |
|
| 328 |
if st.session_state['view_local_gallery'] and st.session_state['input_list_small'] and (st.session_state['dir_images_local_TEMP'] == st.session_state.config['leafmachine']['project']['dir_images_local']):
|
|
@@ -371,9 +369,6 @@ def handle_image_upload_and_gallery():
|
|
| 371 |
|
| 372 |
|
| 373 |
def content_input_images(col_left, col_right):
|
| 374 |
-
SAFE = SafetyCheck(st.session_state['is_hf'])
|
| 375 |
-
is_violation = False
|
| 376 |
-
|
| 377 |
st.write('---')
|
| 378 |
# col1, col2 = st.columns([2,8])
|
| 379 |
with col_left:
|
|
@@ -396,17 +391,7 @@ def content_input_images(col_left, col_right):
|
|
| 396 |
|
| 397 |
with col_right:
|
| 398 |
if st.session_state.is_hf:
|
| 399 |
-
|
| 400 |
-
is_violation = False
|
| 401 |
-
|
| 402 |
-
for uploaded_file in uploaded_files:
|
| 403 |
-
if SAFE.check_for_inappropriate_content(uploaded_file):
|
| 404 |
-
clear_image_uploads()
|
| 405 |
-
report_violation(uploaded_file.name, is_hf=st.session_state['is_hf'])
|
| 406 |
-
st.error("Warning: You uploaded an image that violates our terms of service.")
|
| 407 |
-
is_violation = True
|
| 408 |
-
if not is_violation:
|
| 409 |
-
handle_image_upload_and_gallery_hf(uploaded_files)
|
| 410 |
|
| 411 |
else:
|
| 412 |
st.session_state['view_local_gallery'] = st.toggle("View Image Gallery",)
|
|
|
|
| 253 |
|
| 254 |
|
| 255 |
|
|
|
|
| 256 |
def handle_image_upload_and_gallery_hf(uploaded_files):
|
| 257 |
+
SAFE = SafetyCheck(st.session_state['is_hf'])
|
| 258 |
if uploaded_files:
|
| 259 |
|
| 260 |
# Clear input image gallery and input list
|
|
|
|
| 263 |
ind_small = 0
|
| 264 |
for uploaded_file in uploaded_files:
|
| 265 |
|
| 266 |
+
if SAFE.check_for_inappropriate_content(uploaded_file):
|
| 267 |
+
clear_image_uploads()
|
| 268 |
+
report_violation(uploaded_file.name, is_hf=st.session_state['is_hf'])
|
| 269 |
+
st.error("Warning: You uploaded an image that violates our terms of service.")
|
| 270 |
+
return True
|
| 271 |
|
| 272 |
|
| 273 |
# Determine the file type
|
|
|
|
| 318 |
images_to_display = st.session_state['input_list_small']
|
| 319 |
show_gallery_small_hf(images_to_display)
|
| 320 |
|
| 321 |
+
return False
|
| 322 |
|
| 323 |
|
|
|
|
| 324 |
def handle_image_upload_and_gallery():
|
| 325 |
|
| 326 |
if st.session_state['view_local_gallery'] and st.session_state['input_list_small'] and (st.session_state['dir_images_local_TEMP'] == st.session_state.config['leafmachine']['project']['dir_images_local']):
|
|
|
|
| 369 |
|
| 370 |
|
| 371 |
def content_input_images(col_left, col_right):
|
|
|
|
|
|
|
|
|
|
| 372 |
st.write('---')
|
| 373 |
# col1, col2 = st.columns([2,8])
|
| 374 |
with col_left:
|
|
|
|
| 391 |
|
| 392 |
with col_right:
|
| 393 |
if st.session_state.is_hf:
|
| 394 |
+
result = handle_image_upload_and_gallery_hf(uploaded_files)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
|
| 396 |
else:
|
| 397 |
st.session_state['view_local_gallery'] = st.toggle("View Image Gallery",)
|