Created a pipeline
This commit is contained in:
		
							parent
							
								
									8213eff41b
								
							
						
					
					
						commit
						91350f3ca3
					
				
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							|  | @ -43,6 +43,16 @@ Remember to replace `your_openai_api_key_here` with your actual OpenAI API key. | |||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| ### Pipeline Usage | ||||
| 
 | ||||
| To convert a directory of images directly to an Anki deck package: | ||||
| 
 | ||||
| ```bash | ||||
| python pipeline.py /path/to/your/image_directory/ | ||||
| ``` | ||||
| 
 | ||||
| This will process the images, extract text, convert text to a set of questions and answers in CSV format, and then produce an `output.apkg` file ready for import into Anki. | ||||
| 
 | ||||
| ### Image to Text Conversion | ||||
| 
 | ||||
| To convert images from a directory to a single text file using OCR: | ||||
|  |  | |||
							
								
								
									
										27
									
								
								pipeline.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								pipeline.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| import sys | ||||
| import os | ||||
| 
 | ||||
| from images2text import main as images_to_text | ||||
| from text2csvdeck import create_csv_deck | ||||
| 
 | ||||
| CSV_DECK_NAME = "output_deck.csv" | ||||
| APKG_NAME = "output.apkg" | ||||
| 
 | ||||
| 
 | ||||
| def pipeline(directory_path): | ||||
|     # 1. Convert images in the directory to a text file | ||||
|     text_file_name = images_to_text(directory_path) | ||||
| 
 | ||||
|     # 2. Convert the text file to a CSV deck using ChatGPT | ||||
|     create_csv_deck(text_file_name) | ||||
| 
 | ||||
|     # 3. Convert the CSV deck to an Anki package | ||||
|     os.system(f"python csv2ankicards.py {CSV_DECK_NAME} {APKG_NAME}") | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|     if len(sys.argv) != 2: | ||||
|         print("Usage: python pipeline.py <directory_path_containing_images>") | ||||
|         sys.exit(1) | ||||
| 
 | ||||
|     pipeline(sys.argv[1]) | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user