Commit ·
d952c8a
1
Parent(s): d721e7b
Update caption.py
Browse files25 unmodified lines26272829303141 unmodified lines7374757677787980818283848586878889909192939495969798998 unmodified lines10810911011125 unmodified linesprev_eps = 0batch_texts = []df = pd.DataFrame()if filepath.endswith('.parquet'):print("Reading from a parquet file...")41 unmodified linesexecutor.submit(df.to_parquet, filepath)i += BATCH_SIZE# Delete the original parquet file if it is emptyif df.empty:os.remove(filepath)print(f"Deleted the original file: {filepath}")# Initialize the HuggingFace APIapi = HfApi()# Upload the processed file to the repositorytry:api.upload_file(path_or_fileobj=new_filepath,path_in_repo=new_filepath,repo_id="AlignmentLab-AI/caption_creation_0.8",repo_type="dataset",)print(f"Uploaded {new_filepath} to AlignmentLab-AI/caption_creation_0.8 repository.")except Exception as e:print(f"Error uploading file: {e}")def main():folder_name = 'captionate'sampling_params = SamplingParams(temperature=0.7, top_p=0.95, max_tokens=100)8 unmodified linesif __name__ == "__main__":main()25 unmodified lines2627282930313241 unmodified lines74757677787980818283848586878889909192939495969798991001011021038 unmodified lines11211311411525 unmodified linesprev_eps = 0batch_texts = []df = pd.DataFrame()batch_counter = 0 # Counter to keep track of batches processedif filepath.endswith('.parquet'):print("Reading from a parquet file...")41 unmodified linesexecutor.submit(df.to_parquet, filepath)i += BATCH_SIZEbatch_counter += 1# Push to hub every 10 batchesif batch_counter % 10 == 0:# Initialize the HuggingFace APIapi = HfApi()# Upload the processed file to the repositorytry:api.upload_file(path_or_fileobj=new_filepath,path_in_repo=new_filepath,repo_id="AlignmentLab-AI/caption_creation_0.8",repo_type="dataset",)print(f"Uploaded {new_filepath} to AlignmentLab-AI/caption_creation_0.8 repository.")except Exception as e:print(f"Error uploading file: {e}")# Delete the original parquet file if it is emptyif df.empty:os.remove(filepath)print(f"Deleted the original file: {filepath}")def main():folder_name = 'captionate'sampling_params = SamplingParams(temperature=0.7, top_p=0.95, max_tokens=100)8 unmodified linesif __name__ == "__main__":main()`
caption.py+20-16