The pipeline works end-to-end

This commit is contained in:
B.J. Dweck 2023-09-08 12:58:19 +03:00
parent 91350f3ca3
commit af4b615aa3
2 changed files with 7 additions and 2 deletions

View File

@ -75,9 +75,14 @@ def main(directory_path):
# Filter out any None values and write the text to final.txt # Filter out any None values and write the text to final.txt
final_text = [text for text in final_text if text is not None] final_text = [text for text in final_text if text is not None]
with open("final.txt", 'w') as f: FINAL_OUTPUT = "final.txt"
with open(FINAL_OUTPUT, 'w') as f:
f.write("\n".join(final_text)) f.write("\n".join(final_text))
print(f"All images processed! Final output saved to {FINAL_OUTPUT}")
return FINAL_OUTPUT # Add this line
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) != 2: if len(sys.argv) != 2:
print("Usage: python images2text.py <directory_path>") print("Usage: python images2text.py <directory_path>")

View File

@ -47,7 +47,7 @@ def create_csv_deck(text_file_path):
# Extract CSV content from response and save to a new file # Extract CSV content from response and save to a new file
csv_content = response.choices[0]['message']['content'] csv_content = response.choices[0]['message']['content']
output_filename = text_file_path.replace(".txt", "_deck.csv") output_filename = "output_deck.csv"
with open(output_filename, 'w') as csv_file: with open(output_filename, 'w') as csv_file:
csv_file.write(csv_content) csv_file.write(csv_content)