Skip to content

Commit

Permalink
fix default input
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciejoss committed Jan 13, 2025
1 parent 92140af commit b0d5886
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions wimudp/data_poisoning/dirty_label/dataset_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ def process_csv_file(concept_a: str = None, concept_c_action: str = None, rows_n

def filter_caption_len(row: pd.Series, concept_a: str, concept_c_action: str) -> bool:
return concept_c_action in row["caption"] and concept_a not in row["caption"]

if __name__ == "__main__":
df = process_csv_file()
df.head(ROWS_NUMBER).to_csv(CSV_CONCEPT_C_FILE)
5 changes: 4 additions & 1 deletion wimudp/data_poisoning/generate_dirty_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

def main():
concept_a = input("Enter value for CONCEPT_A (or press Enter to use default): ").strip()
concept_a = None if concept_a == "" else concept_a

concept_a_action = input("Enter value for CONCEPT_A_ACTION (or press Enter to use default): ").strip()

concept_a_action = None if concept_a_action == "" else concept_a_action

rows_number = input("Enter value for ROWS_NUMBER (or press Enter to use default): ").strip()
rows_number = int(rows_number) if rows_number.isdigit() else None

Expand Down
10 changes: 8 additions & 2 deletions wimudp/data_poisoning/generate_nightshade.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@

def main():
concept_a = input("Enter value for CONCEPT_A (or press Enter to use default): ").strip()
concept_a = None if concept_a == "" else concept_a

concept_c_action = input("Enter value for CONCEPT_C_ACTION (or press Enter to use default): ").strip()
rows_number = input("Enter value for ROWS_NUMBER (or press Enter to use default): ").strip()
concept_c_action = None if concept_c_action == "" else concept_c_action

rows_number = input("Enter value for ROWS_NUMBER (or press Enter to use default): ").strip()
rows_number = int(rows_number) if rows_number.isdigit() else None

concept_c = input("Enter value for CONCEPT_C (or press Enter to use default): ").strip()
concept_c = None if concept_c == "" else concept_c

concept_c_action_extractor = input("Enter value for CONCEPT_C_ACTION (or press Enter to use default): ").strip()
samples_number = input("Enter value for SAMPLES_NUMBER (or press Enter to use default): ").strip()
concept_c_action_extractor = None if concept_c_action_extractor == "" else concept_c_action_extractor

samples_number = input("Enter value for SAMPLES_NUMBER (or press Enter to use default): ").strip()
samples_number = int(samples_number) if samples_number.isdigit() else None

display_stage("Filtering data")
Expand Down
5 changes: 5 additions & 0 deletions wimudp/data_poisoning/nightshade/data_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ def check_audio_file(youtube_id: str) -> bool:
file_path = os.path.join(os.getcwd(), AUDIOS_SAMPLES_DIR, f"{youtube_id}.wav")

return os.path.exists(file_path)

if __name__ == "__main__":
samples = get_samples()

samples.to_csv(CSV_NS_SAMPLES_FILE, index=False)

0 comments on commit b0d5886

Please sign in to comment.