├── Images ├── disintegration_animation.gif ├── food_animation.gif └── pencil_sketch_conversion.jpg └── README.md /Images/disintegration_animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseleantj/gpt-prompts/615f0ed16ac2428eb0090e4a33ffb1bf8b90ad35/Images/disintegration_animation.gif -------------------------------------------------------------------------------- /Images/food_animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseleantj/gpt-prompts/615f0ed16ac2428eb0090e4a33ffb1bf8b90ad35/Images/food_animation.gif -------------------------------------------------------------------------------- /Images/pencil_sketch_conversion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseleantj/gpt-prompts/615f0ed16ac2428eb0090e4a33ffb1bf8b90ad35/Images/pencil_sketch_conversion.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ChatGPT Code Interpreter prompts 2 | 3 | I've found the ChatGPT code interpreter feature to be very useful. 4 | 5 | Here are some useful prompts to perform various tasks. 6 | 7 | ## Turn images into pencil drawings 8 | 9 | 10 | 11 | Copy and paste the following prompt into ChatGPT Code Interpreter: 12 | 13 | ``` 14 | Width to 512px, keep aspect ratio. Blur 99px. cv2.divide original pic by blurred pic, scale 255. Unsharp mask, radius 3, amount 3 with skimage.filters. Grayscale. 15 | ``` 16 | 17 | If it doesn't work, don't worry. 18 | 19 | Copy and paste this code. It was written by GPT during a successful attempt. 20 | 21 | ``` 22 | # Can you execute this code on the attached image? 23 | 24 | import cv2 25 | import numpy as np 26 | from skimage import filters, color, img_as_ubyte 27 | from matplotlib import pyplot as plt 28 | 29 | def process_image(image_path): 30 | # Load the image 31 | img = cv2.imread(image_path) 32 | 33 | # Resize the image, preserving the aspect ratio 34 | desired_width = 512 35 | aspect_ratio = img.shape[1] / img.shape[0] 36 | new_height = int(desired_width / aspect_ratio) 37 | img_resized = cv2.resize(img, (desired_width, new_height)) 38 | 39 | # Blur the image 40 | blur = cv2.GaussianBlur(img_resized, (99, 99), 0) 41 | 42 | # Divide the original image by the blurred image 43 | divided = cv2.divide(img_resized, blur, scale=255) 44 | 45 | # Convert to RGB for skimage 46 | divided_rgb = cv2.cvtColor(divided, cv2.COLOR_BGR2RGB) 47 | 48 | # Apply unsharp mask 49 | unsharp_image = filters.unsharp_mask(divided_rgb, radius=3, amount=3) 50 | 51 | # Convert to 8-bit unsigned byte format 52 | unsharp_image_ubyte = img_as_ubyte(unsharp_image) 53 | 54 | # Convert to grayscale 55 | gray = color.rgb2gray(unsharp_image_ubyte) 56 | 57 | # Plot the original and final images side by side 58 | fig, axs = plt.subplots(1, 2, figsize=(10, 5)) 59 | 60 | # Original image 61 | axs[0].imshow(cv2.cvtColor(img_resized, cv2.COLOR_BGR2RGB)) 62 | axs[0].axis('off') 63 | 64 | # Final image 65 | axs[1].imshow(gray, cmap='gray') 66 | axs[1].axis('off') 67 | 68 | plt.tight_layout() 69 | plt.show() 70 | 71 | # Replace 'image_path' with the path of your image 72 | process_image('image_path') 73 | ``` 74 | 75 | 76 | ## Avengers Disintegration animation: 77 | 78 | 79 | 80 | Copy and paste the following prompt into ChatGPT Code Interpreter. 81 | 82 | You also need to upload an image, preferably one with a single subject and a black background. 83 | 84 | ``` 85 | I want to apply the disintegration effect from Avengers to this image. Can you help me with it? Provide me with a link to download the video generated. Use the code below: 86 | 87 | import imageio 88 | import numpy as np 89 | import random 90 | 91 | # Load the image 92 | image_path = "[INSERT IMAGE PATH HERE]" 93 | image = imageio.imread(image_path) 94 | 95 | # Define the block size 96 | block_size = 4 97 | 98 | # Get the dimensions of the image 99 | height, width, _ = image.shape 100 | 101 | # Make sure the image dimensions are divisible by block size 102 | height -= height % block_size 103 | width -= width % block_size 104 | 105 | # Crop the image to the new dimensions 106 | image = image[:height, :width] 107 | 108 | # Calculate the number of blocks in each dimension 109 | num_blocks_y, num_blocks_x = height // block_size, width // block_size 110 | 111 | # Create an index map of blocks 112 | blocks = np.dstack(np.mgrid[0:num_blocks_y, 0:num_blocks_x]).reshape(-1, 2) 113 | 114 | # Multiply the indices by the block size to get the pixel coordinates 115 | blocks *= block_size 116 | 117 | # Define the distance to move the blocks (Ask the user for X in percentage, tell user default = 10%) 118 | distance = round(0.1 * width) # Replace 0.1 with X 119 | 120 | # Define the number of times to move each block 121 | move_count = 3 122 | 123 | # Create a copy of the original image to work on 124 | working_image = image.copy() 125 | 126 | # Convert the blocks to a list and randomly shuffle it 127 | blocks_list = list(map(tuple, blocks)) 128 | random.shuffle(blocks_list) 129 | 130 | # Define the number of blocks to move (Ask the user for Y in percentage, default = 2% of the total blocks) 131 | num_blocks_to_move = int(0.02 * len(blocks_list)) # Replace 0.02 with Y 132 | 133 | # Create a video writer context 134 | with imageio.get_writer('/mnt/data/disintegration_effect.mp4', mode='I', fps=30) as writer: 135 | # Write a static image to the first 3 frames 136 | for _ in range(3): 137 | writer.append_data(working_image) 138 | 139 | # Loop over the blocks in the shuffled list 140 | for _ in range(move_count): 141 | for i in range(0, len(blocks_list), num_blocks_to_move): 142 | # Select a slice of blocks to move 143 | blocks_to_move = blocks_list[i:i+num_blocks_to_move] 144 | 145 | # For each block, move it to the left by the specified distance 146 | for block in blocks_to_move: 147 | y, x = block 148 | shift_distance = int(min(distance * random.random(), x)) # Don't shift more than the x-coordinate of the block 149 | 150 | if x-shift_distance >= 0: 151 | working_image[y:y+block_size, x-shift_distance:x+block_size-shift_distance] = working_image[y:y+block_size, x:x+block_size] 152 | working_image[y:y+block_size, x:x+block_size] = 0 153 | 154 | # Write the frame to the video file 155 | writer.append_data(working_image) 156 | ``` 157 | 158 | Remark: The code above was generated with ChatGPT (with some slight modifications) with the prompt below: 159 | 160 | But if you use the prompt below, I found the results to be very inconsistent, with 1/5 success rate. Sometimes it makes lots of mistakes. Therefore, it's better to just provide GPT with the code that it previously generated. 161 | 162 | ``` 163 | Are you familiar with the disintegration effect from Avengers after Thanos snaps his fingers? I want to apply this effect to the PNG image I uploaded. By turning it into a video, can you do it for me? 164 | 165 | Using the pixels from the transparent layer, group them into blocks of 4x4 pixels. Then, give each block an index. For each frame, several blocks at random. Then translate those blocks to the left. Keep doing this for the frames until all the blocks have left the image, and only a blank image remains. 166 | 167 | Use the imageio library to help you. Save the frames directly to a video file instead of into a list. 168 | ``` 169 | 170 | ## Panning an image and turning it into a video 171 | 172 | 173 | 174 | Copy and paste the following prompt into ChatGPT Code Interpreter. 175 | 176 | ``` 177 | This image is a panoramic shot. 178 | 179 | Help me turn it into a video with aspect ratio 3:2, with the image filling the entire video (so the sides are cut off). The video should be centered in the middle of the image. 180 | 181 | Then, pan the video smoothly (with no sudden jumps) as follows: 182 | 183 | Start: Center --> Right --> Center --> Left --> Center: End 184 | 185 | Use the imageio library to help you. Save the frames directly to a video file instead of into a list. 186 | 187 | Use a frame step of 8 pixels. If necessary, crop the edges of the image so that the size of the image is divisible by the frame step. 188 | ``` 189 | --------------------------------------------------------------------------------