{"id":7092,"date":"2023-07-10T22:54:22","date_gmt":"2023-07-10T13:54:22","guid":{"rendered":"https:\/\/bocek.co.jp\/media\/?p=7092"},"modified":"2023-07-11T13:09:10","modified_gmt":"2023-07-11T04:09:10","slug":"chatgpt%e3%81%aecode-interpreter%e3%82%92%e6%b4%bb%e7%94%a8%e3%81%97%e3%81%a6%e7%94%bb%e5%83%8f%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e5%87%a6%e7%90%86%e3%82%92%e8%a1%8c%e3%81%86","status":"publish","type":"post","link":"https:\/\/taskhub.jp\/magazine\/exercise\/chatgpt\/7092\/","title":{"rendered":"ChatGPT\u306eCode Interpreter\u3092\u6d3b\u7528\u3057\u3066\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306e\u51e6\u7406\u3092\u884c\u3046"},"content":{"rendered":"\n<p>\u300cChatGPT\u306eCode Interpreter\u306e\u6d3b\u7528\u65b9\u6cd5\u304c\u308f\u304b\u3089\u306a\u3044\u2026\u300d\u300cChatGPT\u306eCode Interpreter\u3092\u4f7f\u3063\u3066\u753b\u50cf\u306e\u51e6\u7406\u304c\u3067\u304d\u308b\u306e\uff1f\u300d\u305d\u3046\u601d\u3046\u65b9\u3082\u591a\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n\n\n\n<p>\u5b9f\u306f\u3001ChatGPT Code Interpreter\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u7c21\u5358\u306b\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306e\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56dePROMPTY\u3067\u306f\u3001ChatGPT Code Interpreter\u3092\u4f7f\u3063\u305f\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306e\u51e6\u7406\u65b9\u6cd5\u3092\u4f8b\u3092\u4f7f\u3063\u3066\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>Code Interpreter\u306e\u6982\u8981\u306b\u3064\u3044\u3066\u77e5\u308a\u305f\u3044\u65b9\u306f\u3001\u3053\u3061\u3089\u306e\u8a18\u4e8b\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n\n\n\n<h2 class=\"wp-block-heading\">\u2460 \u753b\u50cf\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3092\u5909\u66f4\u3059\u308b<\/h2>\n\n\n\n<p>\u4eca\u56de\u306f\u3053\u3061\u3089\u306e\u753b\u50cf\u306e\u62e1\u5f35\u5b50\u3092\u5909\u66f4\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/taskhub.jp\/magazine\/wp-content\/themes\/the-thor\/img\/dummy.gif\" data-layzr=\"https:\/\/bocek.co.jp\/media\/wp-content\/uploads\/2023\/07\/sample.jpeg\" alt=\"\" class=\"wp-image-7093\" width=\"477\" height=\"317\"\/><\/figure>\n\n\n\n<p>\u30d7\u30ed\u30f3\u30d7\u30c8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3053\u306e\u753b\u50cf\u3092png\u30d5\u30a1\u30a4\u30eb\u306b\u5909\u63db\u3057\u3066\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/code><\/pre>\n\n\n\n<p>GPT-4\u306e\u51fa\u529b\uff08Code Interpreter\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/taskhub.jp\/magazine\/wp-content\/themes\/the-thor\/img\/dummy.gif\" data-layzr=\"https:\/\/bocek.co.jp\/media\/wp-content\/uploads\/2023\/07\/image-116.png\" alt=\"\" class=\"wp-image-7097\"\/><\/figure>\n\n\n\n<p>\u30d7\u30ed\u30f3\u30d7\u30c8\u306e\u6307\u793a\u901a\u308a\u3001jpeg\u306e\u753b\u50cf\u3092png\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u307e\u3057\u305f\u3002\u3053\u306e\u3088\u3046\u306b\u753b\u50cf\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u6307\u793a\u3092\u4e0e\u3048\u308b\u3060\u3051\u3067\u3001\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306e\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>Code Interpreter\u3067\u5b9f\u884c\u3057\u305fPython\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Load the new image\nimg_new_3 = Image.open(\"\/mnt\/data\/sample.jpeg\")\n\n# Save the image in PNG format\nimg_new_3.save(\"\/mnt\/data\/sample_new_3.png\")\n\n\"\/mnt\/data\/sample_new_3.png\"\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2461 \u753b\u50cf\u3092\u30b0\u30ec\u30fc\u30b9\u30b1\u30fc\u30eb\uff08\u767d\u9ed2\uff09\u753b\u50cf\u306b\u5909\u63db\u3059\u308b<\/h2>\n\n\n\n<p>\u30d7\u30ed\u30f3\u30d7\u30c8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3053\u306e\u753b\u50cf\u3092\u30b0\u30ec\u30fc\u30b9\u30b1\u30fc\u30eb\u753b\u50cf\u306b\u5909\u63db\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u5909\u63db\u5f8c\u306e\u753b\u50cf\u3092\u9069\u5207\u306a\u540d\u524d\u3067\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\u5909\u63db\u524d\u306e\u753b\u50cf\u3068\u4e26\u3079\u3066\u8868\u793a\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/code><\/pre>\n\n\n\n<p>GPT-4\u306e\u51fa\u529b\uff08Code Interpreter\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/taskhub.jp\/magazine\/wp-content\/themes\/the-thor\/img\/dummy.gif\" data-layzr=\"https:\/\/bocek.co.jp\/media\/wp-content\/uploads\/2023\/07\/image-115.png\" alt=\"\" class=\"wp-image-7096\"\/><\/figure>\n\n\n\n<p>\u30d7\u30ed\u30f3\u30d7\u30c8\u306e\u6307\u793a\u901a\u308a\u306bRGB\u753b\u50cf\u3092\u30b0\u30ec\u30fc\u30b9\u30b1\u30fc\u30eb\u753b\u50cf\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u5909\u63db\u524d\u306e\u753b\u50cf\u4e26\u3079\u3066\u6bd4\u8f03\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>Code Interpreter\u3067\u5b9f\u884c\u3057\u305fPython\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Load the new image\nimg_new_2 = Image.open(\"\/mnt\/data\/sample.jpeg\")\n\n# Convert to grayscale\nimg_new_2_gray = img_new_2.convert(\"L\")\n\n# Save the grayscale image\nimg_new_2_gray.save(\"\/mnt\/data\/sample_new_2_gray.jpeg\")\n\n# Display the original and grayscale images side by side\nfig, ax = plt.subplots(1, 2, figsize=(12, 6))\n\n# Original image\nax&#091;0].imshow(img_new_2)\nax&#091;0].set_title(\"Original Image\")\nax&#091;0].axis(\"off\")\n\n# Grayscale image\nax&#091;1].imshow(img_new_2_gray, cmap='gray')\nax&#091;1].set_title(\"Grayscale Image\")\nax&#091;1].axis(\"off\")\n\nplt.show()\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2462 \u30c6\u30fc\u30de\u3092\u6307\u5b9a\u3057\u3066\u753b\u50cf\u3092\u51e6\u7406\u3059\u308b<\/h2>\n\n\n\n<p>\u30d7\u30ed\u30f3\u30d7\u30c8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3053\u306e\u753b\u50cf\u3092\u30ec\u30c8\u30ed\u98a8\u306b\u5909\u63db\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u5909\u63db\u5f8c\u306e\u753b\u50cf\u3092\u9069\u5207\u306a\u540d\u524d\u3067\u4fdd\u5b58\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\u5909\u63db\u524d\u306e\u753b\u50cf\u3068\u4e26\u3079\u3066\u8868\u793a\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/code><\/pre>\n\n\n\n<p>GPT-4\u306e\u51fa\u529b\uff08Code Interpreter\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/taskhub.jp\/magazine\/wp-content\/themes\/the-thor\/img\/dummy.gif\" data-layzr=\"https:\/\/bocek.co.jp\/media\/wp-content\/uploads\/2023\/07\/image-118.png\" alt=\"\" class=\"wp-image-7099\"\/><\/figure>\n\n\n\n<p>\u30ec\u30c8\u30ed\u98a8\u3068\u3044\u3046\u6307\u793a\u306e\u610f\u56f3\u3092\u7406\u89e3\u3057\u3066\u3001\u30bb\u30d4\u30a2\u8272\u306b\u5909\u63db\u3057\u307e\u3057\u305f\u3002\u3053\u306e\u3088\u3046\u306b\u3001\u30c6\u30fc\u30de\u3092\u4e0e\u3048\u308b\u3060\u3051\u3067\u3001\u305d\u308c\u306b\u6cbf\u3063\u305f\u51e6\u7406\u3092\u9078\u3093\u3067\u304f\u308c\u308b\u3053\u3068\u304cChatGPT Code Interpreter\u306e\u5927\u304d\u306a\u30e1\u30ea\u30c3\u30c8\u3068\u8003\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>Code Interpreter\u3067\u5b9f\u884c\u3057\u305fPython\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from PIL import ImageEnhance\n\n# Load the new image\nimg_new_4 = Image.open(\"\/mnt\/data\/sample.jpeg\")\n\n# Convert image to sepia\nimg_new_4 = img_new_4.convert(\"RGB\")\nsepia_image = Image.new(\"RGB\", img_new_4.size)\nsepia_list = &#091;]\n\nfor pixel in img_new_4.getdata():\n    r, g, b = pixel\n    # Sepia transformation\n    tr = int(0.393 * r + 0.769 * g + 0.189 * b)\n    tg = int(0.349 * r + 0.686 * g + 0.168 * b)\n    tb = int(0.272 * r + 0.534 * g + 0.131 * b)\n    if tr &gt; 255: tr = 255\n    if tg &gt; 255: tg = 255\n    if tb &gt; 255: tb = 255\n    sepia_list.append((tr,tg,tb))\n\nsepia_image.putdata(sepia_list)\n\n# Save the retro-style image\nsepia_image.save(\"\/mnt\/data\/sample_new_4_retro.jpeg\")\n\n# Display the original and retro-style images side by side\nfig, ax = plt.subplots(1, 2, figsize=(12, 6))\n\n# Original image\nax&#091;0].imshow(img_new_4)\nax&#091;0].set_title(\"Original Image\")\nax&#091;0].axis(\"off\")\n\n# Retro-style image\nax&#091;1].imshow(sepia_image)\nax&#091;1].set_title(\"Retro-style Image\")\nax&#091;1].axis(\"off\")\n\nplt.show()\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2463 \u7269\u4f53\u306e\u8f2a\u90ed\u3092\u691c\u51fa\u3059\u308b<\/h2>\n\n\n\n<p>\u4eca\u56de\u306f\u3053\u3061\u3089\u306e\u753b\u50cf\u306e\u8f2a\u90ed\u3092\u691c\u51fa\u3057\u3066\u3082\u3089\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/taskhub.jp\/magazine\/wp-content\/themes\/the-thor\/img\/dummy.gif\" data-layzr=\"https:\/\/bocek.co.jp\/media\/wp-content\/uploads\/2023\/07\/sample2.jpg\" alt=\"\" class=\"wp-image-7094\" width=\"504\" height=\"334\"\/><\/figure>\n\n\n\n<p>\u30d7\u30ed\u30f3\u30d7\u30c8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u3053\u306e\u753b\u50cf\u306e\u8f2a\u90ed\u3092\u691c\u51fa\u3057\u3066\u3001\u7dd1\u8272\u3067\u56f2\u3093\u3067\u304f\u3060\u3055\u3044\u3002\n<\/code><\/pre>\n\n\n\n<p>GPT-4\u306e\u51fa\u529b\uff08Code Interpreter\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/taskhub.jp\/magazine\/wp-content\/themes\/the-thor\/img\/dummy.gif\" data-layzr=\"https:\/\/bocek.co.jp\/media\/wp-content\/uploads\/2023\/07\/image-119.png\" alt=\"\" class=\"wp-image-7100\"\/><\/figure>\n\n\n\n<p>\u30d7\u30ed\u30f3\u30d7\u30c8\u306e\u6307\u793a\u901a\u308a\u3001\u98df\u30d1\u30f3\u306e\u8f2a\u90ed\u3092\u691c\u51fa\u3057\u3066\u3001\u7dd1\u8272\u3067\u56f2\u3093\u3060\u753b\u50cf\u304c\u51fa\u529b\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306fCanny\u6cd5\u3092\u3044\u3046\u624b\u6cd5\u3067\u8f2a\u90ed\u691c\u51fa\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002\u7279\u306b\u8a73\u7d30\u306a\u6307\u793a\u3092\u51fa\u3059\u3053\u3068\u306a\u304f\u3001\u6700\u9069\u306a\u65b9\u6cd5\u3092\u9078\u629e\u3057\u3066\u3001\u8f2a\u90ed\u306e\u691c\u51fa\u3092\u3057\u3066\u304f\u308c\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>Code Interpreter\u3067\u5b9f\u884c\u3057\u305fPython\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import cv2\nimport numpy as np\n\n# Load the image using OpenCV\nimg_new_6 = cv2.imread(\"\/mnt\/data\/sample2.jpg\")\n\n# Convert to grayscale\ngray = cv2.cvtColor(img_new_6, cv2.COLOR_BGR2GRAY)\n\n# Perform edge detection\nedges = cv2.Canny(gray, threshold1=30, threshold2=100)\n\n# Perform a dilation and erosion to close gaps in between object edges\ndilated_edges = cv2.dilate(edges, None, iterations=2)\nedges = cv2.erode(dilated_edges, None, iterations=1)\n\n# Find contours in the edge map\ncontours, _ = cv2.findContours(edges.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)\n\n# Draw contours\ncv2.drawContours(img_new_6, contours, -1, (0,255,0), 2)\n\n# Save the image with contours\ncv2.imwrite(\"\/mnt\/data\/sample_new_6_contours.jpg\", img_new_6)\n\n# Convert the color from BGR to RGB (for correct display in matplotlib)\nimg_new_6 = cv2.cvtColor(img_new_6, cv2.COLOR_BGR2RGB)\n\n# Display the original image and the image with contours\nfig, ax = plt.subplots(1, 2, figsize=(12, 6))\n\n# Original image\nax&#091;0].imshow(Image.open(\"\/mnt\/data\/sample2.jpg\"))\nax&#091;0].set_title(\"Original Image\")\nax&#091;0].axis(\"off\")\n\n# Image with contours\nax&#091;1].imshow(img_new_6)\nax&#091;1].set_title(\"Image with Contours\")\nax&#091;1].axis(\"off\")\n\nplt.show()\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u4eca\u56dePROMPTY\u3067\u306f\u3001ChatGPT Code Interpreter\u3092\u6d3b\u7528\u3057\u3066\u3001\u6b21\u306e\u3088\u3046\u306a\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306e\u51e6\u7406\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<ul>\n<li>\u753b\u50cf\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3092\u5909\u66f4\u3059\u308b<\/li>\n\n\n\n<li>RGB\u753b\u50cf\u3092\u30b0\u30ec\u30fc\u30b9\u30b1\u30fc\u30eb\u306b\u5909\u63db\u3059\u308b<\/li>\n\n\n\n<li>\u30c6\u30fc\u30de\u3092\u6307\u5b9a\u3057\u3066\u3001\u305d\u308c\u306b\u6cbf\u3063\u305f\u753b\u50cf\u306e\u51e6\u7406\u3092\u884c\u3046<\/li>\n\n\n\n<li>\u7269\u4f53\u306e\u8f2a\u90ed\u3092\u691c\u51fa\u3059\u308b<\/li>\n<\/ul>\n\n\n\n<p>\u753b\u50cf\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u3001\u65e5\u672c\u8a9e\u3067\u6307\u793a\u3092\u51fa\u3059\u3060\u3051\u3067\u3001\u6240\u671b\u306e\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\u304c\u3067\u304d\u308b\u3053\u3068\u304c\u3001ChatGPT Code Interpreter\u306e\u5927\u304d\u306a\u5f37\u307f\u3068\u8a00\u3048\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306e\u4f8b\u3092\u53c2\u8003\u306b\u3001\u7686\u3055\u307e\u3082ChatGPT Code Interpreter\u3092\u4f7f\u3063\u305f\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306e\u51e6\u7406\u3092\u8a66\u3057\u3066\u307f\u3066\u306f\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300cChatGPT\u306eCode Interpreter\u306e\u6d3b\u7528\u65b9\u6cd5\u304c\u308f\u304b\u3089\u306a\u3044\u2026\u300d\u300cChatGPT\u306eCode Interpreter\u3092\u4f7f\u3063\u3066\u753b\u50cf\u306e\u51e6\u7406\u304c\u3067\u304d\u308b\u306e\uff1f\u300d\u305d\u3046\u601d\u3046\u65b9\u3082\u591a\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002 \u5b9f [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":7136,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":""},"categories":[46],"tags":[],"_links":{"self":[{"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/posts\/7092"}],"collection":[{"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/comments?post=7092"}],"version-history":[{"count":3,"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/posts\/7092\/revisions"}],"predecessor-version":[{"id":7180,"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/posts\/7092\/revisions\/7180"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/media\/7136"}],"wp:attachment":[{"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/media?parent=7092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/categories?post=7092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taskhub.jp\/magazine\/wp-json\/wp\/v2\/tags?post=7092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}