Fixing preferences management to avoid data loss
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- app.py +128 -16
- config.py +3 -3
- data/Real-Cartoon/sample_0/{alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png → alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png} +2 -2
- data/Real-Cartoon/{sample_1/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png → sample_0/input_bg_bb.png} +2 -2
- data/Real-Cartoon/{sample_10/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png → sample_1/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png} +2 -2
- data/Real-Cartoon/{sample_11/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png → sample_1/input_bg_bb.png} +2 -2
- data/Real-Cartoon/sample_10/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_10/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_11/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_11/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_12/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_12/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_12/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_13/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_13/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_13/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_14/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_14/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_14/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_15/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_15/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_15/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_16/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_16/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_16/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_17/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_17/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_17/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_18/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_18/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_18/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_19/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_19/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_19/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_2/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_2/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_2/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_20/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_20/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_20/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_21/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_21/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_21/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_22/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_22/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_22/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_23/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
- data/Real-Cartoon/sample_23/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png +0 -3
- data/Real-Cartoon/sample_23/input_bg_bb.png +3 -0
- data/Real-Cartoon/sample_24/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png +3 -0
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import random
|
|
| 5 |
from datetime import datetime
|
| 6 |
from apscheduler.schedulers.background import BackgroundScheduler
|
| 7 |
from PIL import Image
|
|
|
|
| 8 |
|
| 9 |
import config
|
| 10 |
import utils
|
|
@@ -13,22 +14,87 @@ import utils
|
|
| 13 |
# Attempt to log in to Hugging Face Hub at startup
|
| 14 |
utils.login_hugging_face()
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
preferences_df = utils.load_preferences_from_hf_hub(config.HF_DATASET_REPO_ID, config.RESULTS_CSV_FILE)
|
|
|
|
| 18 |
if preferences_df is None:
|
|
|
|
| 19 |
if os.path.exists(config.RESULTS_CSV_FILE):
|
| 20 |
-
print(f"Loading preferences from local file: {config.RESULTS_CSV_FILE}")
|
| 21 |
try:
|
| 22 |
preferences_df = pd.read_csv(config.RESULTS_CSV_FILE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
except pd.errors.EmptyDataError:
|
| 24 |
-
print(f"Local
|
| 25 |
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS)
|
|
|
|
| 26 |
except Exception as e:
|
| 27 |
-
print(f"Error loading local {config.RESULTS_CSV_FILE}: {e}.
|
| 28 |
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS)
|
|
|
|
| 29 |
else:
|
| 30 |
-
print("
|
| 31 |
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# Scan for available data
|
| 34 |
ALL_SAMPLES_BY_DOMAIN = utils.scan_data_directory(config.DATA_FOLDER)
|
|
@@ -39,11 +105,32 @@ if not ALL_SAMPLES_BY_DOMAIN:
|
|
| 39 |
# --- Scheduler for Periodic Uploads ---
|
| 40 |
def scheduled_upload_job():
|
| 41 |
global preferences_df
|
| 42 |
-
print(f"Running scheduled job:
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
scheduler = BackgroundScheduler()
|
| 49 |
scheduler.add_job(scheduled_upload_job, 'interval', hours=config.PUSH_INTERVAL_HOURS)
|
|
@@ -175,15 +262,40 @@ def process_vote(choice_index, session_id, sample_queue, current_sample_index, c
|
|
| 175 |
preferred_model_key=preferred_model_key
|
| 176 |
)
|
| 177 |
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
current_sample_index += 1
|
| 185 |
if current_sample_index >= len(sample_queue):
|
| 186 |
-
|
|
|
|
| 187 |
final_msg = f"# 🎉 Session Complete! 🎉\n\n### All samples have been rated. Thank you for your participation!"
|
| 188 |
return preferences_df, current_sample_index, final_msg, None, None, None, [], [], True
|
| 189 |
|
|
|
|
| 5 |
from datetime import datetime
|
| 6 |
from apscheduler.schedulers.background import BackgroundScheduler
|
| 7 |
from PIL import Image
|
| 8 |
+
from filelock import FileLock # Added for file locking
|
| 9 |
|
| 10 |
import config
|
| 11 |
import utils
|
|
|
|
| 14 |
# Attempt to log in to Hugging Face Hub at startup
|
| 15 |
utils.login_hugging_face()
|
| 16 |
|
| 17 |
+
print(f"Attempting to load preferences from Hugging Face Hub, ensuring local {config.RESULTS_CSV_FILE} is synchronized.")
|
| 18 |
+
# We assume utils.load_preferences_from_hf_hub:
|
| 19 |
+
# 1. Downloads from Hub, overwrites local config.RESULTS_CSV_FILE.
|
| 20 |
+
# 2. If Hub file doesn't exist, local config.RESULTS_CSV_FILE becomes empty (or reflects this).
|
| 21 |
+
# 3. Returns the DataFrame loaded from the (now synchronized) local file.
|
| 22 |
+
# 4. Returns None on major failure (e.g. network, file not found on Hub).
|
| 23 |
preferences_df = utils.load_preferences_from_hf_hub(config.HF_DATASET_REPO_ID, config.RESULTS_CSV_FILE)
|
| 24 |
+
|
| 25 |
if preferences_df is None:
|
| 26 |
+
print(f"Failed to load from Hub or Hub is empty/file not found. Initializing/loading from {config.RESULTS_CSV_FILE} as a fallback.")
|
| 27 |
if os.path.exists(config.RESULTS_CSV_FILE):
|
|
|
|
| 28 |
try:
|
| 29 |
preferences_df = pd.read_csv(config.RESULTS_CSV_FILE)
|
| 30 |
+
if not preferences_df.empty and list(preferences_df.columns) != config.CSV_HEADERS:
|
| 31 |
+
print(f"Warning: Local CSV {config.RESULTS_CSV_FILE} columns ({list(preferences_df.columns)}) do not match expected headers ({config.CSV_HEADERS}). Re-initializing file and DataFrame.")
|
| 32 |
+
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS)
|
| 33 |
+
preferences_df.to_csv(config.RESULTS_CSV_FILE, index=False)
|
| 34 |
+
elif preferences_df.empty: # Loaded an empty DataFrame
|
| 35 |
+
# Check if the file itself had incorrect headers or was truly empty
|
| 36 |
+
current_headers = []
|
| 37 |
+
if os.path.getsize(config.RESULTS_CSV_FILE) > 0:
|
| 38 |
+
try:
|
| 39 |
+
current_headers = list(pd.read_csv(config.RESULTS_CSV_FILE, nrows=0).columns)
|
| 40 |
+
except Exception: # Handle cases where reading headers might fail
|
| 41 |
+
pass # Will be caught by re-initialization if headers are bad
|
| 42 |
+
if current_headers != config.CSV_HEADERS:
|
| 43 |
+
print(f"Local CSV {config.RESULTS_CSV_FILE} is empty or has incorrect headers. Re-initializing file and DataFrame with correct headers.")
|
| 44 |
+
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS)
|
| 45 |
+
preferences_df.to_csv(config.RESULTS_CSV_FILE, index=False)
|
| 46 |
+
else: # Empty dataframe, but headers in file are correct
|
| 47 |
+
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS) # Ensure in-memory df also has columns
|
| 48 |
+
|
| 49 |
except pd.errors.EmptyDataError:
|
| 50 |
+
print(f"Local CSV {config.RESULTS_CSV_FILE} is empty. Initializing file and DataFrame with headers.")
|
| 51 |
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS)
|
| 52 |
+
preferences_df.to_csv(config.RESULTS_CSV_FILE, index=False)
|
| 53 |
except Exception as e:
|
| 54 |
+
print(f"Error loading local {config.RESULTS_CSV_FILE}: {e}. Initializing file and DataFrame.")
|
| 55 |
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS)
|
| 56 |
+
preferences_df.to_csv(config.RESULTS_CSV_FILE, index=False)
|
| 57 |
else:
|
| 58 |
+
print(f"Local CSV {config.RESULTS_CSV_FILE} not found. Initializing file and DataFrame.")
|
| 59 |
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS)
|
| 60 |
+
preferences_df.to_csv(config.RESULTS_CSV_FILE, index=False)
|
| 61 |
+
else:
|
| 62 |
+
# Successfully loaded from Hub; local file config.RESULTS_CSV_FILE should be synchronized.
|
| 63 |
+
print(f"Successfully loaded preferences from Hugging Face Hub. Local copy at {config.RESULTS_CSV_FILE} should be up-to-date.")
|
| 64 |
+
if not preferences_df.empty and list(preferences_df.columns) != config.CSV_HEADERS:
|
| 65 |
+
print(f"CRITICAL: Data from Hub has incorrect columns {list(preferences_df.columns)}. Expected {config.CSV_HEADERS}. Re-initializing local file and DataFrame to empty to prevent corruption.")
|
| 66 |
+
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS)
|
| 67 |
+
preferences_df.to_csv(config.RESULTS_CSV_FILE, index=False)
|
| 68 |
+
elif preferences_df.empty:
|
| 69 |
+
# Hub data is empty. Ensure DataFrame in memory has correct columns.
|
| 70 |
+
# And ensure the local CSV (which should have been written by load_preferences_from_hf_hub) has correct headers.
|
| 71 |
+
if list(preferences_df.columns) != config.CSV_HEADERS:
|
| 72 |
+
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS) # Correct columns in memory
|
| 73 |
+
|
| 74 |
+
# Ensure the local file has correct headers if it's empty or its headers are wrong
|
| 75 |
+
needs_header_rewrite = True
|
| 76 |
+
if os.path.exists(config.RESULTS_CSV_FILE):
|
| 77 |
+
if os.path.getsize(config.RESULTS_CSV_FILE) == 0: # File is completely empty
|
| 78 |
+
needs_header_rewrite = True
|
| 79 |
+
else:
|
| 80 |
+
try:
|
| 81 |
+
local_headers = list(pd.read_csv(config.RESULTS_CSV_FILE, nrows=0).columns)
|
| 82 |
+
if local_headers == config.CSV_HEADERS:
|
| 83 |
+
needs_header_rewrite = False
|
| 84 |
+
except Exception: # Error reading headers, assume rewrite is needed
|
| 85 |
+
pass
|
| 86 |
+
if needs_header_rewrite:
|
| 87 |
+
print(f"Local file {config.RESULTS_CSV_FILE} (after Hub sync resulted in empty data) is empty or has incorrect headers. Writing/Re-writing headers.")
|
| 88 |
+
pd.DataFrame(columns=config.CSV_HEADERS).to_csv(config.RESULTS_CSV_FILE, index=False)
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
# Final safety net: ensure preferences_df is a DataFrame with correct columns.
|
| 92 |
+
if not isinstance(preferences_df, pd.DataFrame) or list(preferences_df.columns) != config.CSV_HEADERS:
|
| 93 |
+
print("Critical: preferences_df is not a valid DataFrame with correct headers after initialization. Resetting to empty with correct headers.")
|
| 94 |
+
preferences_df = pd.DataFrame(columns=config.CSV_HEADERS)
|
| 95 |
+
# Ensure the CSV file reflects this state
|
| 96 |
+
preferences_df.to_csv(config.RESULTS_CSV_FILE, index=False)
|
| 97 |
+
|
| 98 |
|
| 99 |
# Scan for available data
|
| 100 |
ALL_SAMPLES_BY_DOMAIN = utils.scan_data_directory(config.DATA_FOLDER)
|
|
|
|
| 105 |
# --- Scheduler for Periodic Uploads ---
|
| 106 |
def scheduled_upload_job():
|
| 107 |
global preferences_df
|
| 108 |
+
print(f"Running scheduled job: Preparing to upload preferences from {config.RESULTS_CSV_FILE} at {datetime.now()}")
|
| 109 |
+
|
| 110 |
+
lock_path = config.RESULTS_CSV_FILE + ".lock"
|
| 111 |
+
with FileLock(lock_path):
|
| 112 |
+
print(f"Acquired lock for scheduled upload: {lock_path}")
|
| 113 |
+
if os.path.exists(config.RESULTS_CSV_FILE):
|
| 114 |
+
try:
|
| 115 |
+
# Read the current state of the CSV file for upload
|
| 116 |
+
df_to_upload = pd.read_csv(config.RESULTS_CSV_FILE)
|
| 117 |
+
if not df_to_upload.empty:
|
| 118 |
+
utils.save_preferences_to_hf_hub(
|
| 119 |
+
df_to_upload, # df_to_upload is passed for the empty check inside save_preferences_to_hf_hub
|
| 120 |
+
config.HF_DATASET_REPO_ID,
|
| 121 |
+
config.RESULTS_CSV_FILE, # This is the target filename on the Hub
|
| 122 |
+
commit_message="Periodic background update"
|
| 123 |
+
)
|
| 124 |
+
print(f"Scheduled job: Attempted upload of data from {config.RESULTS_CSV_FILE}.")
|
| 125 |
+
else:
|
| 126 |
+
print(f"Scheduled job: Local preferences file {config.RESULTS_CSV_FILE} is empty. Nothing to upload.")
|
| 127 |
+
except pd.errors.EmptyDataError:
|
| 128 |
+
print(f"Scheduled job: Local preferences file {config.RESULTS_CSV_FILE} is empty (read as EmptyDataError). Nothing to upload.")
|
| 129 |
+
except Exception as e:
|
| 130 |
+
print(f"Scheduled job: Error reading or uploading {config.RESULTS_CSV_FILE}: {e}")
|
| 131 |
+
else:
|
| 132 |
+
print(f"Scheduled job: Local preferences file {config.RESULTS_CSV_FILE} does not exist. Nothing to upload.")
|
| 133 |
+
print(f"Released lock for scheduled upload: {lock_path}")
|
| 134 |
|
| 135 |
scheduler = BackgroundScheduler()
|
| 136 |
scheduler.add_job(scheduled_upload_job, 'interval', hours=config.PUSH_INTERVAL_HOURS)
|
|
|
|
| 262 |
preferred_model_key=preferred_model_key
|
| 263 |
)
|
| 264 |
|
| 265 |
+
# Append the new preference to the CSV file
|
| 266 |
+
if not preferences_df.empty:
|
| 267 |
+
new_preference_df = preferences_df.iloc[-1:] # Get the last row as a new DataFrame
|
| 268 |
+
|
| 269 |
+
lock_path = config.RESULTS_CSV_FILE + ".lock"
|
| 270 |
+
with FileLock(lock_path):
|
| 271 |
+
print(f"Acquired lock for vote processing: {lock_path}")
|
| 272 |
+
try:
|
| 273 |
+
file_exists_and_has_content = os.path.exists(config.RESULTS_CSV_FILE) and os.path.getsize(config.RESULTS_CSV_FILE) > 0
|
| 274 |
+
new_preference_df.to_csv(
|
| 275 |
+
config.RESULTS_CSV_FILE,
|
| 276 |
+
mode='a',
|
| 277 |
+
header=not file_exists_and_has_content, # Write header if file is new or empty
|
| 278 |
+
index=False
|
| 279 |
+
)
|
| 280 |
+
print(f"Appended new preference to {config.RESULTS_CSV_FILE}")
|
| 281 |
+
except Exception as e:
|
| 282 |
+
print(f"Error appending preference to local CSV {config.RESULTS_CSV_FILE}: {e}")
|
| 283 |
+
finally:
|
| 284 |
+
print(f"Released lock for vote processing: {lock_path}")
|
| 285 |
+
else:
|
| 286 |
+
print("Warning: preferences_df is empty after utils.record_preference. Cannot append to CSV.")
|
| 287 |
+
|
| 288 |
+
# Removed full CSV overwrite:
|
| 289 |
+
# try:
|
| 290 |
+
# preferences_df.to_csv(config.RESULTS_CSV_FILE, index=False)
|
| 291 |
+
# print(f"Preferences saved locally to {config.RESULTS_CSV_FILE}")
|
| 292 |
+
# except Exception as e:
|
| 293 |
+
# print(f"Error saving preferences locally: {e}")
|
| 294 |
|
| 295 |
current_sample_index += 1
|
| 296 |
if current_sample_index >= len(sample_queue):
|
| 297 |
+
# Removed session end upload:
|
| 298 |
+
# utils.save_preferences_to_hf_hub(preferences_df, config.HF_DATASET_REPO_ID, config.RESULTS_CSV_FILE, commit_message="Session end update")
|
| 299 |
final_msg = f"# 🎉 Session Complete! 🎉\n\n### All samples have been rated. Thank you for your participation!"
|
| 300 |
return preferences_df, current_sample_index, final_msg, None, None, None, [], [], True
|
| 301 |
|
config.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
# --- File and Folder Names ---
|
| 4 |
DATA_FOLDER = "data" # Main folder containing domain subfolders
|
| 5 |
-
BACKGROUND_IMAGE_NAME = "
|
| 6 |
FOREGROUND_IMAGE_NAME = "input_fg.jpg" # Standard name for foreground input
|
| 7 |
PROMPT_FILE_NAME = "prompt.txt" # Standard name for the prompt file
|
| 8 |
# Names for the output images from different models.
|
|
@@ -11,7 +11,7 @@ MODEL_OUTPUT_IMAGE_NAMES = {
|
|
| 11 |
"baseline": "cp_bg_fg.jpg",
|
| 12 |
"kv-edit": "kvedit.jpg",
|
| 13 |
"tf-icon": "tf-icon.png",
|
| 14 |
-
"dit-editor": "alphanoise0.
|
| 15 |
}
|
| 16 |
# Names to display for each model in the UI (can be different from filenames)
|
| 17 |
MODEL_DISPLAY_NAMES = {
|
|
@@ -43,7 +43,7 @@ SAMPLES_PER_DOMAIN = 3 # Number of samples to show from each domain per user ses
|
|
| 43 |
# --- Hugging Face Hub ---
|
| 44 |
HF_DATASET_REPO_ID = "matsant01/dit-editor-collected-preferences" # Replace with your actual repo ID
|
| 45 |
HF_TOKEN = None # Set this if your dataset is private, or use HF_HUB_TOKEN env var
|
| 46 |
-
PUSH_INTERVAL_HOURS =
|
| 47 |
|
| 48 |
# --- UI Configuration ---
|
| 49 |
IMAGE_DISPLAY_SIZE = (300, 300) # (width, height) for displaying images
|
|
|
|
| 2 |
|
| 3 |
# --- File and Folder Names ---
|
| 4 |
DATA_FOLDER = "data" # Main folder containing domain subfolders
|
| 5 |
+
BACKGROUND_IMAGE_NAME = "input_bg_bb.png" # Standard name for background input
|
| 6 |
FOREGROUND_IMAGE_NAME = "input_fg.jpg" # Standard name for foreground input
|
| 7 |
PROMPT_FILE_NAME = "prompt.txt" # Standard name for the prompt file
|
| 8 |
# Names for the output images from different models.
|
|
|
|
| 11 |
"baseline": "cp_bg_fg.jpg",
|
| 12 |
"kv-edit": "kvedit.jpg",
|
| 13 |
"tf-icon": "tf-icon.png",
|
| 14 |
+
"dit-editor": "alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png",
|
| 15 |
}
|
| 16 |
# Names to display for each model in the UI (can be different from filenames)
|
| 17 |
MODEL_DISPLAY_NAMES = {
|
|
|
|
| 43 |
# --- Hugging Face Hub ---
|
| 44 |
HF_DATASET_REPO_ID = "matsant01/dit-editor-collected-preferences" # Replace with your actual repo ID
|
| 45 |
HF_TOKEN = None # Set this if your dataset is private, or use HF_HUB_TOKEN env var
|
| 46 |
+
PUSH_INTERVAL_HOURS = 0.05 # Interval in hours to push results to the Hub
|
| 47 |
|
| 48 |
# --- UI Configuration ---
|
| 49 |
IMAGE_DISPLAY_SIZE = (300, 300) # (width, height) for displaying images
|
data/Real-Cartoon/sample_0/{alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png → alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png}
RENAMED
|
File without changes
|
data/Real-Cartoon/{sample_1/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png → sample_0/input_bg_bb.png}
RENAMED
|
File without changes
|
data/Real-Cartoon/{sample_10/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png → sample_1/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png}
RENAMED
|
File without changes
|
data/Real-Cartoon/{sample_11/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png → sample_1/input_bg_bb.png}
RENAMED
|
File without changes
|
data/Real-Cartoon/sample_10/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_10/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_11/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_11/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_12/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_12/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_12/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_13/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_13/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_13/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_14/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_14/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_14/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_15/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_15/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_15/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_16/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_16/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_16/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_17/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_17/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_17/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_18/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_18/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_18/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_19/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_19/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_19/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_2/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_2/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_2/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_20/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_20/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_20/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_21/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_21/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_21/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_22/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_22/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_22/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_23/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_23/alphanoise0.05_timesteps50_QTrue_KTrue_VTrue_taua0.4_taub0.8_guidance3.0.png
DELETED
Git LFS Details
|
data/Real-Cartoon/sample_23/input_bg_bb.png
ADDED
|
Git LFS Details
|
data/Real-Cartoon/sample_24/alphanoise0.05_timesteps50_QTrue_KTrue_VFalse_taua0.4_taub0.8_guidance3.0_all-layers.png
ADDED
|
Git LFS Details
|