Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,9 @@ if 'blur_option' not in st.session_state:
|
|
| 13 |
# Initialize Gradio client
|
| 14 |
client_nsfw = Client("https://ozoneasai-falconsai-nsfw-image-detection.hf.space/--replicas/0fyhj/")
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
# Initialize pagination
|
| 17 |
if 'page' not in st.session_state:
|
| 18 |
st.session_state.page = 1
|
|
@@ -118,8 +121,8 @@ def display_images(images):
|
|
| 118 |
st.experimental_rerun()
|
| 119 |
|
| 120 |
# Main part of the app
|
| 121 |
-
if
|
| 122 |
-
save_uploaded_files(
|
| 123 |
|
| 124 |
files_per_page = 20
|
| 125 |
num_pages = (len(file_paths) - 1) // files_per_page + 1
|
|
@@ -162,7 +165,7 @@ if st.button("CSVに保存"):
|
|
| 162 |
csv_writer = csv.writer(csv_file)
|
| 163 |
csv_writer.writerow(['ファイル名', 'NSFWの予測', 'Goodの値', '作成時間'])
|
| 164 |
for i, file_path in enumerate(file_paths):
|
| 165 |
-
gradio_nsfw_prediction = gradio_nsfw_predictions[i]
|
| 166 |
good_value = good_values[i]
|
| 167 |
timestamp = timestamps[i]
|
| 168 |
csv_writer.writerow([os.path.basename(file_path), gradio_nsfw_prediction, good_value, timestamp])
|
|
|
|
| 13 |
# Initialize Gradio client
|
| 14 |
client_nsfw = Client("https://ozoneasai-falconsai-nsfw-image-detection.hf.space/--replicas/0fyhj/")
|
| 15 |
|
| 16 |
+
# File uploader interface
|
| 17 |
+
uploaded_files = st.file_uploader("画像ファイルをアップロードしてください", type=["jpg", "jpeg", "png"], accept_multiple_files=True)
|
| 18 |
+
|
| 19 |
# Initialize pagination
|
| 20 |
if 'page' not in st.session_state:
|
| 21 |
st.session_state.page = 1
|
|
|
|
| 121 |
st.experimental_rerun()
|
| 122 |
|
| 123 |
# Main part of the app
|
| 124 |
+
if uploaded_files:
|
| 125 |
+
save_uploaded_files(uploaded_files)
|
| 126 |
|
| 127 |
files_per_page = 20
|
| 128 |
num_pages = (len(file_paths) - 1) // files_per_page + 1
|
|
|
|
| 165 |
csv_writer = csv.writer(csv_file)
|
| 166 |
csv_writer.writerow(['ファイル名', 'NSFWの予測', 'Goodの値', '作成時間'])
|
| 167 |
for i, file_path in enumerate(file_paths):
|
| 168 |
+
gradio_nsfw_prediction = gradio_nsfw_predictions[i][1] # Accessing the prediction result from the tuple
|
| 169 |
good_value = good_values[i]
|
| 170 |
timestamp = timestamps[i]
|
| 171 |
csv_writer.writerow([os.path.basename(file_path), gradio_nsfw_prediction, good_value, timestamp])
|