import os import json import sys import uuid # modifications = [ # "There is a modification involving the addition of a beard. ", # "There is a modification involving the addition of a pair of eyeglasses. ", # "There is a modification making the person to appear to be smiling. ", # "There is a modification making the person to appear younger than they really are. ", # "There is a modification involving the addition of Bangs. " # "There is no modification. " # ] # Function to get list of image files in the directory def get_image_files(directory): image_files = [] for filename in os.listdir(directory): if filename.endswith(".jpg") or filename.endswith(".png"): image_files.append(filename) return image_files # Function to create JSON file with entries for each image file def create_json(image_dir, json_file_path, answerbruh): # Get list of image files image_files = get_image_files(image_dir) # Create list of entries for each image file image_entries = [] with open(json_file_path, "r") as json_file: image_entries=json.load(json_file) answer=answerbruh for image_file in image_files: image_path = os.path.join(image_dir, image_file) entry_id = str(uuid.uuid4()) entry = { "id": entry_id, "image": image_path, "conversations": [ { "from": "human", "value": "Tell me the probability of this image being real. Answer a probability score between 0 and 100." }, { "from": "gpt", "value": answer } ] } image_entries.append(entry) # Writing data to the JSON file with open(json_file_path, "w") as json_file: json.dump(image_entries, json_file, indent=4) print("JSON file created successfully at", json_file_path) # # Check if the script is called with the correct number of arguments # if len(sys.argv) != 3: # print("Usage: python script.py ") # sys.exit(1) # # Get command-line arguments # image_dir = sys.argv[1] #directory path # json_file_path = sys.argv[2] #output path # # Check if the specified directory exists # if not os.path.isdir(image_dir): # print("Error: The specified directory does not exist.") # sys.exit(1) # Call the function to create the JSON file #print(image_dir) #get_answer(image_dir) create_json("/fsx/ivan.laptev/Deepfake/dffd/ffhq/train", "/fsx/ivan.laptev/Deepfake/deepfakehtml/my_code/json/lorajsondffd7.json", "0") # create_json("/fsx/ivan.laptev/Deepfake/dffdtestt/face2face", "/fsx/ivan.laptev/Deepfake/deepfakehtml/my_code/json/lorajsondffd2.json", "1") # create_json("/fsx/ivan.laptev/Deepfake/dffd/stargan/train", "/fsx/ivan.laptev/Deepfake/deepfakehtml/my_code/json/lorajsondffd3.json", "Attributes manipulation.") create_json("/fsx/ivan.laptev/Deepfake/dffd/stylegan_ffhq/train", "/fsx/ivan.laptev/Deepfake/deepfakehtml/my_code/json/lorajsondffd7.json", "100")