{"id":34305,"date":"2024-12-04T06:01:57","date_gmt":"2024-12-03T22:01:57","guid":{"rendered":"https:\/\/17aitech.com\/?p=34305"},"modified":"2024-12-04T06:01:57","modified_gmt":"2024-12-03T22:01:57","slug":"%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%ef%bc%8c%e7%94%a8%e8%8b%b1%e4%bc%9f%e8%be%bet4%e3%80%81a10%e8%ae%ad%e7%bb%83%e5%b0%8f%e5%9e%8b%e6%96%87%e7%94%9f%e8%a7%86%e9%a2%91%e6%a8%a1%e5%9e%8b%ef%bc%8c","status":"publish","type":"post","link":"https:\/\/17aitech.com\/?p=34305","title":{"rendered":"\u4ece\u96f6\u5f00\u59cb\uff0c\u7528\u82f1\u4f1f\u8fbeT4\u3001A10\u8bad\u7ec3\u5c0f\u578b\u6587\u751f\u89c6\u9891\u6a21\u578b\uff0c\u51e0\u5c0f\u65f6\u641e\u5b9a"},"content":{"rendered":"<p>\u6587\u7ae0\u6765\u6e90\u4e8e\u4e92\u8054\u7f51:<a href=\"https:\/\/www.jiqizhixin.com\/articles\/2024-07-01-6\" target=\"_blank\">\u4ece\u96f6\u5f00\u59cb\uff0c\u7528\u82f1\u4f1f\u8fbeT4\u3001A10\u8bad\u7ec3\u5c0f\u578b\u6587\u751f\u89c6\u9891\u6a21\u578b\uff0c\u51e0\u5c0f\u65f6\u641e\u5b9a<\/a><\/p>\n<blockquote data-author-name=\"\" data-content-utf8-length=\"10\" data-source-title=\"\" data-type=\"2\" data-url=\"\">\n<section>\n<section>\n<section>\n<section>\u5f88\u7fd4\u5b9e\u7684\u4e00\u7bc7\u6559\u7a0b\u3002<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/blockquote>\n<section>OpenAI \u7684 Sora\u3001Stability AI \u7684 Stable Video Diffusion \u4ee5\u53ca\u8bb8\u591a\u5176\u4ed6\u5df2\u7ecf\u53d1\u5e03\u6216\u672a\u6765\u5c06\u51fa\u73b0\u7684\u6587\u672c\u751f\u6210\u89c6\u9891\u6a21\u578b\uff0c\u662f\u7ee7\u5927\u8bed\u8a00\u6a21\u578b (LLM) \u4e4b\u540e 2024 \u5e74\u6700\u6d41\u884c\u7684 AI \u8d8b\u52bf\u4e4b\u4e00\u3002<\/section>\n<section><\/section>\n<section>\u5728\u8fd9\u7bc7\u535a\u5ba2\u4e2d\uff0c\u4f5c\u8005\u5c06\u5c55\u793a\u5982\u4f55\u5c06\u4ece\u5934\u5f00\u59cb\u6784\u5efa\u4e00\u4e2a\u5c0f\u89c4\u6a21\u7684\u6587\u672c\u751f\u6210\u89c6\u9891\u6a21\u578b\uff0c\u6db5\u76d6\u4e86\u4ece\u7406\u89e3\u7406\u8bba\u6982\u5ff5\u3001\u5230\u7f16\u5199\u6574\u4e2a\u67b6\u6784\u518d\u5230\u751f\u6210\u6700\u7ec8\u7ed3\u679c\u7684\u6240\u6709\u5185\u5bb9\u3002<\/section>\n<section><\/section>\n<section>\u7531\u4e8e\u4f5c\u8005\u6ca1\u6709\u5927\u7b97\u529b\u7684 GPU\uff0c\u6240\u4ee5\u4ec5\u7f16\u5199\u4e86\u5c0f\u89c4\u6a21\u67b6\u6784\u3002\u4ee5\u4e0b\u662f\u5728\u4e0d\u540c\u5904\u7406\u5668\u4e0a\u8bad\u7ec3\u6a21\u578b\u6240\u9700\u65f6\u95f4\u7684\u6bd4\u8f83\u3002<\/section>\n<section><a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-673ce5fc5892c93d834e1b30cc343669.png\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-673ce5fc5892c93d834e1b30cc343669.png\"><\/a><\/section>\n<section>\u4f5c\u8005\u8868\u793a\uff0c\u5728 CPU \u4e0a\u8fd0\u884c\u663e\u7136\u9700\u8981\u66f4\u957f\u7684\u65f6\u95f4\u6765\u8bad\u7ec3\u6a21\u578b\u3002\u5982\u679c\u4f60\u9700\u8981\u5feb\u901f\u6d4b\u8bd5\u4ee3\u7801\u4e2d\u7684\u66f4\u6539\u5e76\u67e5\u770b\u7ed3\u679c\uff0cCPU \u4e0d\u662f\u6700\u4f73\u9009\u62e9\u3002\u56e0\u6b64\u5efa\u8bae\u4f7f\u7528 Colab \u6216 Kaggle \u7684 T4 GPU \u8fdb\u884c\u66f4\u9ad8\u6548\u3001\u66f4\u5feb\u901f\u7684\u8bad\u7ec3\u3002<\/section>\n<section><\/section>\n<section><strong>\u6784\u5efa\u76ee\u6807<\/strong><\/section>\n<section><\/section>\n<section>\u6211\u4eec\u91c7\u7528\u4e86\u4e0e\u4f20\u7edf\u673a\u5668\u5b66\u4e60\u6216\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u7c7b\u4f3c\u7684\u65b9\u6cd5\uff0c\u5373\u5728\u6570\u636e\u96c6\u4e0a\u8fdb\u884c\u8bad\u7ec3\uff0c\u7136\u540e\u5728\u672a\u89c1\u8fc7\u6570\u636e\u4e0a\u8fdb\u884c\u6d4b\u8bd5\u3002\u5728\u6587\u672c\u8f6c\u89c6\u9891\u7684\u80cc\u666f\u4e0b\uff0c\u5047\u8bbe\u6709\u4e00\u4e2a\u5305\u542b 10 \u4e07\u4e2a\u72d7\u6361\u7403\u548c\u732b\u8ffd\u8001\u9f20\u89c6\u9891\u7684\u8bad\u7ec3\u6570\u636e\u96c6\uff0c\u7136\u540e\u8bad\u7ec3\u6a21\u578b\u6765\u751f\u6210\u732b\u6361\u7403\u6216\u72d7\u8ffd\u8001\u9f20\u7684\u89c6\u9891\u3002<\/section>\n<section><a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-c8c2717594852ce9e0c6e0c0ff3c1b28.gif\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-c8c2717594852ce9e0c6e0c0ff3c1b28.gif\"><\/a><\/section>\n<section><em><sup>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u56fe\u6e90\uff1aiStock, GettyImages<\/sup><\/em><\/section>\n<section><\/section>\n<section>\u867d\u7136\u6b64\u7c7b\u8bad\u7ec3\u6570\u636e\u96c6\u5728\u4e92\u8054\u7f51\u4e0a\u5f88\u5bb9\u6613\u83b7\u5f97\uff0c\u4f46\u6240\u9700\u7684\u7b97\u529b\u6781\u9ad8\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u7531 Python \u4ee3\u7801\u751f\u6210\u7684\u79fb\u52a8\u5bf9\u8c61\u89c6\u9891\u6570\u636e\u96c6\u3002\u540c\u65f6\u4f7f\u7528 GAN\uff08\u751f\u6210\u5bf9\u6297\u7f51\u7edc\uff09\u67b6\u6784\u6765\u521b\u5efa\u6a21\u578b\uff0c\u800c\u4e0d\u662f OpenAI Sora \u4f7f\u7528\u7684\u6269\u6563\u6a21\u578b\u3002<\/section>\n<section><\/section>\n<section>\u6211\u4eec\u4e5f\u5c1d\u8bd5\u4f7f\u7528\u6269\u6563\u6a21\u578b\uff0c\u4f46\u5185\u5b58\u8981\u6c42\u8d85\u51fa\u4e86\u81ea\u5df1\u7684\u80fd\u529b\u3002\u53e6\u4e00\u65b9\u9762\uff0cGAN \u53ef\u4ee5\u66f4\u5bb9\u6613\u3001\u66f4\u5feb\u5730\u8fdb\u884c\u8bad\u7ec3\u548c\u6d4b\u8bd5\u3002<\/section>\n<section><\/section>\n<section><strong>\u51c6\u5907\u6761\u4ef6<\/strong><\/section>\n<section><\/section>\n<section>\u6211\u4eec\u5c06\u4f7f\u7528 OOP\uff08\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff09\uff0c\u56e0\u6b64\u5fc5\u987b\u5bf9\u5b83\u4ee5\u53ca\u795e\u7ecf\u7f51\u7edc\u6709\u57fa\u672c\u7684\u4e86\u89e3\u3002\u6b64\u5916 GAN\uff08\u751f\u6210\u5bf9\u6297\u7f51\u7edc\uff09\u7684\u77e5\u8bc6\u4e0d\u662f\u5fc5\u9700\u7684\uff0c\u56e0\u4e3a\u8fd9\u91cc\u7b80\u5355\u4ecb\u7ecd\u5b83\u4eec\u7684\u67b6\u6784\u3002<\/section>\n<section><\/section>\n<ul>\n<li>\n<section>OOP\uff1ahttps:\/\/www.youtube.com\/watch?v=q2SGW2VgwAM<\/section>\n<\/li>\n<li>\n<section>\u795e\u7ecf\u7f51\u7edc\u7406\u8bba\uff1ahttps:\/\/www.youtube.com\/watch?v=Jy4wM2X21u0<\/section>\n<\/li>\n<li>\n<section>GAN \u67b6\u6784\uff1ahttps:\/\/www.youtube.com\/watch?v=TpMIssRdhco<\/section>\n<\/li>\n<li>\n<section>Python \u57fa\u7840\uff1ahttps:\/\/www.youtube.com\/watch?v=eWRfhZUzrAc<\/section>\n<\/li>\n<\/ul>\n<section><\/section>\n<section><strong>\u4e86\u89e3 GAN \u67b6\u6784<\/strong><\/section>\n<section><\/section>\n<section><strong>\u4ec0\u4e48\u662f GAN\uff1f<\/strong><\/section>\n<section><\/section>\n<section>\u751f\u6210\u5bf9\u6297\u7f51\u7edc\u662f\u4e00\u79cd\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\uff0c\u5176\u4e2d\u4e24\u4e2a\u795e\u7ecf\u7f51\u7edc\u76f8\u4e92\u7ade\u4e89\uff1a\u4e00\u4e2a\u4ece\u7ed9\u5b9a\u7684\u6570\u636e\u96c6\u521b\u5efa\u65b0\u6570\u636e\uff08\u5982\u56fe\u50cf\u6216\u97f3\u4e50\uff09\uff0c\u53e6\u4e00\u4e2a\u5219\u5224\u65ad\u6570\u636e\u662f\u771f\u5b9e\u7684\u8fd8\u662f\u865a\u5047\u7684\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u4e00\u76f4\u6301\u7eed\u5230\u751f\u6210\u7684\u6570\u636e\u4e0e\u539f\u59cb\u6570\u636e\u65e0\u6cd5\u533a\u5206\u3002<\/section>\n<section><\/section>\n<section><strong>\u771f\u5b9e\u4e16\u754c\u5e94\u7528<\/strong><\/section>\n<section><\/section>\n<ul>\n<li>\n<section>\u751f\u6210\u56fe\u50cf\uff1aGAN \u6839\u636e\u6587\u672c prompt \u521b\u5efa\u903c\u771f\u7684\u56fe\u50cf\u6216\u4fee\u6539\u73b0\u6709\u56fe\u50cf\uff0c\u4f8b\u5982\u589e\u5f3a\u5206\u8fa8\u7387\u6216\u4e3a\u9ed1\u767d\u7167\u7247\u6dfb\u52a0\u989c\u8272\u3002<\/section>\n<\/li>\n<li>\n<section>\u6570\u636e\u589e\u5f3a\uff1aGAN \u751f\u6210\u5408\u6210\u6570\u636e\u6765\u8bad\u7ec3\u5176\u4ed6\u673a\u5668\u5b66\u4e60\u6a21\u578b\uff0c\u4f8b\u5982\u4e3a\u6b3a\u8bc8\u68c0\u6d4b\u7cfb\u7edf\u521b\u5efa\u6b3a\u8bc8\u4ea4\u6613\u6570\u636e\u3002<\/section>\n<\/li>\n<li>\n<section>\u8865\u5145\u7f3a\u5931\u4fe1\u606f\uff1aGAN \u53ef\u4ee5\u586b\u5145\u7f3a\u5931\u6570\u636e\uff0c\u4f8b\u5982\u6839\u636e\u5730\u5f62\u56fe\u751f\u6210\u5730\u4e0b\u56fe\u50cf\u4ee5\u7528\u4e8e\u80fd\u6e90\u5e94\u7528\u3002<\/section>\n<\/li>\n<li>\n<section>\u751f\u6210 3D \u6a21\u578b\uff1aGAN \u5c06 2D \u56fe\u50cf\u8f6c\u6362\u4e3a 3D \u6a21\u578b\uff0c\u5728\u533b\u7597\u4fdd\u5065\u7b49\u9886\u57df\u975e\u5e38\u6709\u7528\uff0c\u53ef\u7528\u4e8e\u4e3a\u624b\u672f\u89c4\u5212\u521b\u5efa\u903c\u771f\u7684\u5668\u5b98\u56fe\u50cf\u3002<\/section>\n<\/li>\n<\/ul>\n<section><\/section>\n<section><strong>GAN \u5de5\u4f5c\u539f\u7406<\/strong><\/section>\n<section><\/section>\n<section>GAN \u7531\u4e24\u4e2a\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u7ec4\u6210\uff1a\u751f\u6210\u5668\u548c\u5224\u522b\u5668\u3002\u8fd9\u4e24\u4e2a\u7f51\u7edc\u5728\u5bf9\u6297\u8bbe\u7f6e\u4e2d\u4e00\u8d77\u8bad\u7ec3\uff0c\u5176\u4e2d\u4e00\u4e2a\u7f51\u7edc\u751f\u6210\u65b0\u6570\u636e\uff0c\u53e6\u4e00\u4e2a\u7f51\u7edc\u8bc4\u4f30\u6570\u636e\u662f\u771f\u662f\u5047\u3002<\/section>\n<section><a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-6cba4a3015d9f25dc96baa3e6137edbc.png\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-6cba4a3015d9f25dc96baa3e6137edbc.png\"><\/a><\/section>\n<section><strong>GAN \u8bad\u7ec3\u793a\u4f8b<\/strong><\/section>\n<section><\/section>\n<section>\u8ba9\u6211\u4eec\u4ee5\u56fe\u50cf\u5230\u56fe\u50cf\u7684\u8f6c\u6362\u4e3a\u4f8b\uff0c\u89e3\u91ca\u4e00\u4e0b GAN \u6a21\u578b\uff0c\u91cd\u70b9\u662f\u4fee\u6539\u4eba\u8138\u3002<\/section>\n<section><\/section>\n<section>1. \u8f93\u5165\u56fe\u50cf\uff1a\u8f93\u5165\u56fe\u50cf\u662f\u4e00\u5f20\u771f\u5b9e\u7684\u4eba\u8138\u56fe\u50cf\u3002<\/section>\n<section>2. \u5c5e\u6027\u4fee\u6539\uff1a\u751f\u6210\u5668\u4f1a\u4fee\u6539\u4eba\u8138\u7684\u5c5e\u6027\uff0c\u6bd4\u5982\u7ed9\u773c\u775b\u52a0\u4e0a\u58a8\u955c\u3002<\/section>\n<section>3. \u751f\u6210\u56fe\u50cf\uff1a\u751f\u6210\u5668\u4f1a\u521b\u5efa\u4e00\u7ec4\u6dfb\u52a0\u4e86\u592a\u9633\u955c\u7684\u56fe\u50cf\u3002<\/section>\n<section>4. \u5224\u522b\u5668\u7684\u4efb\u52a1\uff1a\u5224\u522b\u5668\u63a5\u6536\u5230\u6df7\u5408\u7684\u771f\u5b9e\u56fe\u50cf\uff08\u5e26\u6709\u592a\u9633\u955c\u7684\u4eba\uff09\u548c\u751f\u6210\u7684\u56fe\u50cf\uff08\u6dfb\u52a0\u4e86\u592a\u9633\u955c\u7684\u4eba\u8138\uff09\u3002\u00a0<\/section>\n<section>5. \u8bc4\u4f30\uff1a\u5224\u522b\u5668\u5c1d\u8bd5\u533a\u5206\u771f\u5b9e\u56fe\u50cf\u548c\u751f\u6210\u56fe\u50cf\u3002\u00a0<\/section>\n<section>6. \u53cd\u9988\u56de\u8def\uff1a\u5982\u679c\u5224\u522b\u5668\u6b63\u786e\u8bc6\u522b\u51fa\u5047\u56fe\u50cf\uff0c\u751f\u6210\u5668\u4f1a\u8c03\u6574\u5176\u53c2\u6570\u4ee5\u751f\u6210\u66f4\u903c\u771f\u7684\u56fe\u50cf\u3002\u5982\u679c\u751f\u6210\u5668\u6210\u529f\u6b3a\u9a97\u4e86\u5224\u522b\u5668\uff0c\u5224\u522b\u5668\u4f1a\u66f4\u65b0\u5176\u53c2\u6570\u4ee5\u63d0\u9ad8\u68c0\u6d4b\u80fd\u529b\u3002\u00a0<\/section>\n<section><\/section>\n<section>\u901a\u8fc7\u8fd9\u4e00\u5bf9\u6297\u8fc7\u7a0b\uff0c\u4e24\u4e2a\u7f51\u7edc\u90fd\u5728\u4e0d\u65ad\u6539\u8fdb\u3002\u751f\u6210\u5668\u8d8a\u6765\u8d8a\u5584\u4e8e\u751f\u6210\u903c\u771f\u7684\u56fe\u50cf\uff0c\u800c\u5224\u522b\u5668\u5219\u8d8a\u6765\u8d8a\u5584\u4e8e\u8bc6\u522b\u5047\u56fe\u50cf\uff0c\u76f4\u5230\u8fbe\u5230\u5e73\u8861\uff0c\u5224\u522b\u5668\u518d\u4e5f\u65e0\u6cd5\u533a\u5206\u771f\u5b9e\u56fe\u50cf\u548c\u751f\u6210\u7684\u56fe\u50cf\u3002\u6b64\u65f6\uff0cGAN \u5df2\u6210\u529f\u5b66\u4f1a\u751f\u6210\u903c\u771f\u7684\u4fee\u6539\u56fe\u50cf\u3002<\/section>\n<section><\/section>\n<section><strong>\u8bbe\u7f6e\u80cc\u666f<\/strong><\/section>\n<section><\/section>\n<section>\u6211\u4eec\u5c06\u4f7f\u7528\u4e00\u7cfb\u5217 Python \u5e93\uff0c\u8ba9\u6211\u4eec\u5bfc\u5165\u5b83\u4eec\u3002<\/section>\n<section>\n<pre data-lang=\"python\"><section><code># Operating System module for interacting with the operating system<\/code><\/section><section><code>import os<\/code><\/section><section><code>\r\n<\/code><code># Module for generating random numbers<\/code><\/section><section><code>import random<\/code><\/section><section><code>\r\n<\/code><code># Module for numerical operations<\/code><\/section><section><code>import numpy as np<\/code><\/section><section><code>\r\n<\/code><code># OpenCV library for image processing<\/code><\/section><section><code>import cv2<\/code><\/section><section><code>\r\n<\/code><code># Python Imaging Library for image processing<\/code><\/section><section><code>from PIL import Image, ImageDraw, ImageFont<\/code><\/section><section><code>\r\n<\/code><code># PyTorch library for deep learning<\/code><\/section><section><code>import torch<\/code><\/section><section><code>\r\n<\/code><code># Dataset class for creating custom datasets in PyTorch<\/code><\/section><section><code>from torch.utils.data import Dataset<\/code><\/section><section><code>\r\n<\/code><code># Module for image transformations<\/code><\/section><section><code>import torchvision.transforms as transforms<\/code><\/section><section><code>\r\n<\/code><code># Neural network module in PyTorch<\/code><\/section><section><code>import torch.nn as nn<\/code><\/section><section><code>\r\n<\/code><code># Optimization algorithms in PyTorch<\/code><\/section><section><code>import torch.optim as optim<\/code><\/section><section><code>\r\n<\/code><code># Function for padding sequences in PyTorch<\/code><\/section><section><code>from torch.nn.utils.rnn import pad_sequence<\/code><\/section><section><code>\r\n<\/code><code># Function for saving images in PyTorch<\/code><\/section><section><code>from torchvision.utils import save_image<\/code><\/section><section><code>\r\n<\/code><code># Module for plotting graphs and images<\/code><\/section><section><code>import matplotlib.pyplot as plt<\/code><\/section><section><code>\r\n<\/code><code># Module for displaying rich content in IPython environments<\/code><\/section><section><code>from IPython.display import clear_output, display, HTML<\/code><\/section><section><code>\r\n<\/code><code># Module for encoding and decoding binary data to text<\/code><\/section><section><code>import base64<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u73b0\u5728\u6211\u4eec\u5df2\u7ecf\u5bfc\u5165\u4e86\u6240\u6709\u7684\u5e93\uff0c\u4e0b\u4e00\u6b65\u5c31\u662f\u5b9a\u4e49\u6211\u4eec\u7684\u8bad\u7ec3\u6570\u636e\uff0c\u7528\u4e8e\u8bad\u7ec3 GAN \u67b6\u6784\u3002<\/section>\n<section><\/section>\n<section><strong>\u5bf9\u8bad\u7ec3\u6570\u636e\u8fdb\u884c\u7f16\u7801<\/strong><\/section>\n<section><\/section>\n<section>\u6211\u4eec\u9700\u8981\u81f3\u5c11 10000 \u4e2a\u89c6\u9891\u4f5c\u4e3a\u8bad\u7ec3\u6570\u636e\u3002\u4e3a\u4ec0\u4e48\u5462\uff1f\u56e0\u4e3a\u6211\u6d4b\u8bd5\u4e86\u8f83\u5c0f\u6570\u91cf\u7684\u89c6\u9891\uff0c\u7ed3\u679c\u975e\u5e38\u7cdf\u7cd5\uff0c\u51e0\u4e4e\u6ca1\u6709\u4efb\u4f55\u6548\u679c\u3002\u4e0b\u4e00\u4e2a\u91cd\u8981\u95ee\u9898\u662f\uff1a\u8fd9\u4e9b\u89c6\u9891\u5185\u5bb9\u662f\u4ec0\u4e48\uff1f \u00a0\u6211\u4eec\u7684\u8bad\u7ec3\u89c6\u9891\u6570\u636e\u96c6\u5305\u62ec\u4e00\u4e2a\u5706\u5708\u4ee5\u4e0d\u540c\u65b9\u5411\u548c\u4e0d\u540c\u8fd0\u52a8\u65b9\u5f0f\u79fb\u52a8\u7684\u89c6\u9891\u3002\u8ba9\u6211\u4eec\u6765\u7f16\u5199\u4ee3\u7801\u5e76\u751f\u6210 10,000 \u4e2a\u89c6\u9891\uff0c\u770b\u770b\u5b83\u7684\u6548\u679c\u5982\u4f55\u3002<\/section>\n<section>\n<pre data-lang=\"makefile\"><section><code># Create a directory named 'training_dataset'<\/code><\/section><section><code>os.makedirs('training_dataset', exist_ok=True)<\/code><\/section><section><code>\r\n<\/code><code># Define the number of videos to generate for the dataset<\/code><\/section><section><code>num_videos = 10000<\/code><\/section><section><code>\r\n<\/code><code># Define the number of frames per video (1 Second Video)<\/code><\/section><section><code>frames_per_video = 10<\/code><\/section><section><code>\r\n<\/code><code># Define the size of each image in the dataset<\/code><\/section><section><code>img_size = (64, 64)<\/code><\/section><section><code>\r\n<\/code><code># Define the size of the shapes (Circle)<\/code><\/section><section><code>shape_size = 10 <\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u8bbe\u7f6e\u4e00\u4e9b\u57fa\u672c\u53c2\u6570\u540e\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u9700\u8981\u5b9a\u4e49\u8bad\u7ec3\u6570\u636e\u96c6\u7684\u6587\u672c prompt\uff0c\u5e76\u636e\u6b64\u751f\u6210\u8bad\u7ec3\u89c6\u9891\u3002<\/section>\n<section>\n<pre data-lang=\"makefile\"><section><code># Define text prompts and corresponding movements for circles<\/code><\/section><section><code>prompts_and_movements = [<\/code><\/section><section><code> (\"circle moving down\", \"circle\", \"down\"), # Move circle downward<\/code><\/section><section><code> (\"circle moving left\", \"circle\", \"left\"), # Move circle leftward<\/code><\/section><section><code> (\"circle moving right\", \"circle\", \"right\"), # Move circle rightward<\/code><\/section><section><code> (\"circle moving diagonally up-right\", \"circle\", \"diagonal_up_right\"), # Move circle diagonally up-right<\/code><\/section><section><code> (\"circle moving diagonally down-left\", \"circle\", \"diagonal_down_left\"), # Move circle diagonally down-left<\/code><\/section><section><code> (\"circle moving diagonally up-left\", \"circle\", \"diagonal_up_left\"), # Move circle diagonally up-left<\/code><\/section><section><code> (\"circle moving diagonally down-right\", \"circle\", \"diagonal_down_right\"), # Move circle diagonally down-right<\/code><\/section><section><code> (\"circle rotating clockwise\", \"circle\", \"rotate_clockwise\"), # Rotate circle clockwise<\/code><\/section><section><code> (\"circle rotating counter-clockwise\", \"circle\", \"rotate_counter_clockwise\"), # Rotate circle counter-clockwise<\/code><\/section><section><code> (\"circle shrinking\", \"circle\", \"shrink\"), # Shrink circle<\/code><\/section><section><code> (\"circle expanding\", \"circle\", \"expand\"), # Expand circle<\/code><\/section><section><code> (\"circle bouncing vertically\", \"circle\", \"bounce_vertical\"), # Bounce circle vertically<\/code><\/section><section><code> (\"circle bouncing horizontally\", \"circle\", \"bounce_horizontal\"), # Bounce circle horizontally<\/code><\/section><section><code> (\"circle zigzagging vertically\", \"circle\", \"zigzag_vertical\"), # Zigzag circle vertically<\/code><\/section><section><code> (\"circle zigzagging horizontally\", \"circle\", \"zigzag_horizontal\"), # Zigzag circle horizontally<\/code><\/section><section><code> (\"circle moving up-left\", \"circle\", \"up_left\"), # Move circle up-left<\/code><\/section><section><code> (\"circle moving down-right\", \"circle\", \"down_right\"), # Move circle down-right<\/code><\/section><section><code> (\"circle moving down-left\", \"circle\", \"down_left\"), # Move circle down-left<\/code><\/section><section><code>]<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u6211\u4eec\u5df2\u7ecf\u5229\u7528\u8fd9\u4e9b prompt \u5b9a\u4e49\u4e86\u5706\u7684\u51e0\u4e2a\u8fd0\u52a8\u8f68\u8ff9\u3002\u73b0\u5728\uff0c\u6211\u4eec\u9700\u8981\u7f16\u5199\u4e00\u4e9b\u6570\u5b66\u516c\u5f0f\uff0c\u4ee5\u4fbf\u6839\u636e prompt \u79fb\u52a8\u5706\u3002<\/section>\n<section>\n<pre data-lang=\"python\"><section><code># Define function with parameters<\/code><\/section><section><code>def create_image_with_moving_shape(size, frame_num, shape, direction):<\/code><code> <\/code><code>\u00a0<\/code><\/section><section>\r\n<\/section><section><code># Create a new RGB image with specified size and white background<\/code><\/section><section><code>img = Image.new('RGB', size, color=(255, 255, 255))\u00a0<\/code><\/section><section><code>\r\n<\/code><code> # Create a drawing context for the image<\/code><\/section><section><code> draw = ImageDraw.Draw(img) <\/code><\/section><section><code>\r\n<\/code><code> # Calculate the center coordinates of the image<\/code><\/section><section><code> center_x, center_y = size[0] \/\/ 2, size[1] \/\/ 2 <\/code><\/section><section><code>\r\n<\/code><code> # Initialize position with center for all movements<\/code><\/section><section><code> position = (center_x, center_y) <\/code><\/section><section><code>\r\n<\/code><code> # Define a dictionary mapping directions to their respective position adjustments or image transformations<\/code><\/section><section><code> direction_map = { <\/code><code> <\/code><\/section><section><code># Adjust position downwards based on frame number<\/code><code> <\/code><\/section><section><code>\"down\": (0, frame_num * 5 % size[1]),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position to the left based on frame number<\/code><code> <\/code><\/section><section><code>\"left\": (-frame_num * 5 % size[0], 0),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position to the right based on frame number<\/code><code> <\/code><\/section><section><code>\"right\": (frame_num * 5 % size[0], 0),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position diagonally up and to the right<\/code><code> <\/code><\/section><section><code>\"diagonal_up_right\": (frame_num * 5 % size[0], -frame_num * 5 % size[1]),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position diagonally down and to the left<\/code><code> <\/code><\/section><section><code>\"diagonal_down_left\": (-frame_num * 5 % size[0], frame_num * 5 % size[1]),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position diagonally up and to the left<\/code><code> <\/code><\/section><section><code>\"diagonal_up_left\": (-frame_num * 5 % size[0], -frame_num * 5 % size[1]),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position diagonally down and to the right<\/code><code> <\/code><\/section><section><code>\"diagonal_down_right\": (frame_num * 5 % size[0], frame_num * 5 % size[1]),\u00a0<\/code><code> <\/code><\/section><section><code># Rotate the image clockwise based on frame number<\/code><code> <\/code><\/section><section><code>\"rotate_clockwise\": img.rotate(frame_num * 10 % 360, center=(center_x, center_y), fillcolor=(255, 255, 255)),\u00a0<\/code><code> # Rotate the image counter-clockwise based on frame number<\/code><code> <\/code><\/section><section><code>\"rotate_counter_clockwise\": img.rotate(-frame_num * 10 % 360, center=(center_x, center_y), fillcolor=(255, 255, 255)),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position for a bouncing effect vertically<\/code><code> <\/code><\/section><section><code>\"bounce_vertical\": (0, center_y - abs(frame_num * 5 % size[1] - center_y)),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position for a bouncing effect horizontally<\/code><code> <\/code><\/section><section><code>\"bounce_horizontal\": (center_x - abs(frame_num * 5 % size[0] - center_x), 0),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position for a zigzag effect vertically<\/code><code> <\/code><\/section><section><code>\"zigzag_vertical\": (0, center_y - frame_num * 5 % size[1]) if frame_num % 2 == 0 else (0, center_y + frame_num * 5 % size[1]),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position for a zigzag effect horizontally<\/code><code> <\/code><\/section><section><code>\"zigzag_horizontal\": (center_x - frame_num * 5 % size[0], center_y) if frame_num % 2 == 0 else (center_x + frame_num * 5 % size[0], center_y),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position upwards and to the right based on frame number<\/code><code> <\/code><\/section><section><code>\"up_right\": (frame_num * 5 % size[0], -frame_num * 5 % size[1]),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position upwards and to the left based on frame number<\/code><code> <\/code><\/section><section><code>\"up_left\": (-frame_num * 5 % size[0], -frame_num * 5 % size[1]),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position downwards and to the right based on frame number<\/code><code> <\/code><\/section><section><code>\"down_right\": (frame_num * 5 % size[0], frame_num * 5 % size[1]),\u00a0<\/code><code> <\/code><\/section><section><code># Adjust position downwards and to the left based on frame number<\/code><code> <\/code><\/section><section><code>\"down_left\": (-frame_num * 5 % size[0], frame_num * 5 % size[1])\u00a0<\/code><code> <\/code><\/section><section><code>}<\/code><\/section><section><code>\r\n<\/code><code># Check if direction is in the direction map<\/code><code> <\/code><\/section><section><code>if direction in direction_map:\u00a0<\/code><code> <\/code><\/section><section><code># Check if the direction maps to a position adjustment<\/code><code> <\/code><\/section><section><code>if isinstance(direction_map[direction], tuple):\u00a0<\/code><code> <\/code><\/section><section><code># Update position based on the adjustment<\/code><code> <\/code><\/section><section><code>position = tuple(np.add(position, direction_map[direction]))\u00a0<\/code><code> <\/code><\/section><section><code>else: # If the direction maps to an image transformation<\/code><code> <\/code><\/section><section><code># Update the image based on the transformation<\/code><code> <\/code><\/section><section><code>img = direction_map[direction]\u00a0<\/code><\/section><section><code>\r\n<\/code><code># Return the image as a numpy array<\/code><code> <\/code><\/section><section><code>return np.array(img)<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u4e0a\u8ff0\u51fd\u6570\u7528\u4e8e\u6839\u636e\u6240\u9009\u65b9\u5411\u5728\u6bcf\u4e00\u5e27\u4e2d\u79fb\u52a8\u6211\u4eec\u7684\u5706\u3002\u6211\u4eec\u53ea\u9700\u5728\u5176\u4e0a\u8fd0\u884c\u4e00\u4e2a\u5faa\u73af\uff0c\u76f4\u81f3\u751f\u6210\u6240\u6709\u89c6\u9891\u7684\u6b21\u6570\u3002<\/section>\n<section>\n<pre data-lang=\"python\"><section><code># Iterate over the number of videos to generate<\/code><\/section><section><code>for i in range(num_videos):<\/code><\/section><section><code>    # Randomly choose a prompt and movement from the predefined list<\/code><\/section><section><code>    prompt, shape, direction = random.choice(prompts_and_movements)<\/code><code>   <\/code><\/section><section><code> <\/code><\/section><section><code>\u00a0 \u00a0# Create a directory for the current video<\/code><code> <\/code><\/section><section><code>\u00a0 \u00a0video_dir = f'training_dataset\/video_{i}'<\/code><code> <\/code><\/section><section><code>\u00a0 \u00a0os.makedirs(video_dir, exist_ok=True)<\/code><code>    <\/code><\/section><section>\r\n<\/section><section><code>\u00a0 \u00a0# Write the chosen prompt to a text file in the video directory<\/code><\/section><section><code>\u00a0 \u00a0with open(f'{video_dir}\/prompt.txt', 'w') as f:<\/code><\/section><section><code>        f.write(prompt)<\/code><\/section><section><code>\u00a0 \u00a0<\/code><\/section><section><code>\u00a0  <\/code><code># Generate frames for the current video<\/code><\/section><section><code>\u00a0 \u00a0for frame_num in range(frames_per_video):<\/code><\/section><section><code>        # Create an image with a moving shape based on the current frame number, shape, and direction<\/code><\/section><section><code>        img = create_image_with_moving_shape(img_size, frame_num, shape, direction)<\/code><code>        <\/code><\/section><section>\r\n<\/section><section><code>        # Save the generated image as a PNG file in the video directory<\/code><\/section><section><code>        cv2.imwrite(f'{video_dir}\/frame_{frame_num}.png', img)<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u8fd0\u884c\u4e0a\u8ff0\u4ee3\u7801\u540e\uff0c\u5c31\u4f1a\u751f\u6210\u6574\u4e2a\u8bad\u7ec3\u6570\u636e\u96c6\u3002\u4ee5\u4e0b\u662f\u8bad\u7ec3\u6570\u636e\u96c6\u6587\u4ef6\u7684\u7ed3\u6784\u3002<\/section>\n<section><a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-ec096ca51bfb7135a22fcce6b88ca69d.png\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-ec096ca51bfb7135a22fcce6b88ca69d.png\"><\/a><\/section>\n<section>\u6bcf\u4e2a\u8bad\u7ec3\u89c6\u9891\u6587\u4ef6\u5939\u5305\u542b\u5176\u5e27\u4ee5\u53ca\u5bf9\u5e94\u7684\u6587\u672c prompt\u3002\u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u6211\u4eec\u7684\u8bad\u7ec3\u6570\u636e\u96c6\u6837\u672c\u3002<\/section>\n<section><\/section>\n<section>\u5728\u6211\u4eec\u7684\u8bad\u7ec3\u6570\u636e\u96c6\u4e2d\uff0c\u6211\u4eec\u6ca1\u6709\u5305\u542b\u5706\u5708\u5148\u5411\u4e0a\u79fb\u52a8\u7136\u540e\u5411\u53f3\u79fb\u52a8\u7684\u8fd0\u52a8\u3002\u6211\u4eec\u5c06\u4f7f\u7528\u8fd9\u4e2a\u4f5c\u4e3a\u6d4b\u8bd5 prompt\uff0c\u6765\u8bc4\u4f30\u6211\u4eec\u8bad\u7ec3\u7684\u6a21\u578b\u5728\u672a\u89c1\u8fc7\u7684\u6570\u636e\u4e0a\u7684\u8868\u73b0\u3002<\/section>\n<section><a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-82b07e698e2fca6849852371b2cdc0cf.gif\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-82b07e698e2fca6849852371b2cdc0cf.gif\"><\/a><\/section>\n<section>\u8fd8\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u8981\u70b9\u9700\u8981\u6ce8\u610f\uff0c\u6211\u4eec\u7684\u8bad\u7ec3\u6570\u636e\u5305\u542b\u8bb8\u591a\u7269\u4f53\u4ece\u573a\u666f\u4e2d\u79fb\u51fa\u6216\u90e8\u5206\u51fa\u73b0\u5728\u6444\u50cf\u673a\u524d\u65b9\u7684\u6837\u672c\uff0c\u7c7b\u4f3c\u4e8e\u6211\u4eec\u5728 OpenAI Sora \u6f14\u793a\u89c6\u9891\u4e2d\u89c2\u5bdf\u5230\u7684\u60c5\u51b5\u3002\u00a0<\/section>\n<section><a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-bcc169c7b383aa7cbcf5dc58547d5091.gif\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-bcc169c7b383aa7cbcf5dc58547d5091.gif\"><\/a><\/section>\n<section>\u5728\u6211\u4eec\u7684\u8bad\u7ec3\u6570\u636e\u4e2d\u5305\u542b\u6b64\u7c7b\u6837\u672c\u7684\u539f\u56e0\u662f\u4e3a\u4e86\u6d4b\u8bd5\u5f53\u5706\u5708\u4ece\u89d2\u843d\u8fdb\u5165\u573a\u666f\u65f6\uff0c\u6a21\u578b\u662f\u5426\u80fd\u591f\u4fdd\u6301\u4e00\u81f4\u6027\u800c\u4e0d\u4f1a\u7834\u574f\u5176\u5f62\u72b6\u3002<\/section>\n<section><\/section>\n<section>\u73b0\u5728\u6211\u4eec\u7684\u8bad\u7ec3\u6570\u636e\u5df2\u7ecf\u751f\u6210\uff0c\u9700\u8981\u5c06\u8bad\u7ec3\u89c6\u9891\u8f6c\u6362\u4e3a\u5f20\u91cf\uff0c\u8fd9\u662f PyTorch \u7b49\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u4e2d\u4f7f\u7528\u7684\u4e3b\u8981\u6570\u636e\u7c7b\u578b\u3002\u6b64\u5916\uff0c\u901a\u8fc7\u5c06\u6570\u636e\u7f29\u653e\u5230\u8f83\u5c0f\u7684\u8303\u56f4\uff0c\u6267\u884c\u5f52\u4e00\u5316\u7b49\u8f6c\u6362\u6709\u52a9\u4e8e\u63d0\u9ad8\u8bad\u7ec3\u67b6\u6784\u7684\u6536\u655b\u6027\u548c\u7a33\u5b9a\u6027\u3002<\/section>\n<section><\/section>\n<section><strong>\u9884\u5904\u7406\u8bad\u7ec3\u6570\u636e<\/strong><\/section>\n<section><\/section>\n<section>\u6211\u4eec\u5fc5\u987b\u4e3a\u6587\u672c\u8f6c\u89c6\u9891\u4efb\u52a1\u7f16\u5199\u4e00\u4e2a\u6570\u636e\u96c6\u7c7b\uff0c\u5b83\u53ef\u4ee5\u4ece\u8bad\u7ec3\u6570\u636e\u96c6\u76ee\u5f55\u4e2d\u8bfb\u53d6\u89c6\u9891\u5e27\u53ca\u5176\u76f8\u5e94\u7684\u6587\u672c prompt\uff0c\u4f7f\u5176\u53ef\u4ee5\u5728 PyTorch \u4e2d\u4f7f\u7528\u3002<\/section>\n<section>\n<pre data-lang=\"ruby\"><section><code># Define a dataset class inheriting from torch.utils.data.Dataset<\/code><\/section><section><code>class TextToVideoDataset(Dataset):<\/code><\/section><section><code>    def __init__(self, root_dir, transform=None):<\/code><\/section><section><code>        # Initialize the dataset with root directory and optional transform<\/code><\/section><section><code>        self.root_dir = root_dir<\/code><\/section><section><code>        self.transform = transform<\/code><\/section><section><code>        # List all subdirectories in the root directory<\/code><\/section><section><code>        self.video_dirs = [os.path.join(root_dir, d) for d in os.listdir(root_dir) if os.path.isdir(os.path.join(root_dir, d))]<\/code><\/section><section><code>        # Initialize lists to store frame paths and corresponding prompts<\/code><\/section><section><code>        self.frame_paths = []<\/code><\/section><section><code>        self.prompts = []<\/code><\/section><section><code>\r\n<\/code><code>        # Loop through each video directory<\/code><\/section><section><code>        for video_dir in self.video_dirs:<\/code><\/section><section><code>            # List all PNG files in the video directory and store their paths<\/code><\/section><section><code>            frames = [os.path.join(video_dir, f) for f in os.listdir(video_dir) if f.endswith('.png')]<\/code><\/section><section><code>            self.frame_paths.extend(frames)<\/code><\/section><section><code>            # Read the prompt text file in the video directory and store its content<\/code><\/section><section><code>            with open(os.path.join(video_dir, 'prompt.txt'), 'r') as f:<\/code><\/section><section><code>                prompt = f.read().strip()<\/code><\/section><section><code>            # Repeat the prompt for each frame in the video and store in prompts list<\/code><\/section><section><code>            self.prompts.extend([prompt] * len(frames))<\/code><\/section><section><code>\r\n<\/code><code>    # Return the total number of samples in the dataset<\/code><\/section><section><code>    def __len__(self):<\/code><\/section><section><code>        return len(self.frame_paths)<\/code><\/section><section><code>\r\n<\/code><code>    # Retrieve a sample from the dataset given an index<\/code><\/section><section><code>    def __getitem__(self, idx):<\/code><\/section><section><code>        # Get the path of the frame corresponding to the given index<\/code><\/section><section><code>        frame_path = self.frame_paths[idx]<\/code><\/section><section><code>        # Open the image using PIL (Python Imaging Library)<\/code><\/section><section><code>        image = Image.open(frame_path)<\/code><\/section><section><code>        # Get the prompt corresponding to the given index<\/code><\/section><section><code>        prompt = self.prompts[idx]<\/code><\/section><section><code>\r\n<\/code><code>        # Apply transformation if specified<\/code><\/section><section><code>        if self.transform:<\/code><\/section><section><code>            image = self.transform(image)<\/code><\/section><section><code>\r\n<\/code><code>        # Return the transformed image and the prompt<\/code><\/section><section><code>        return image, prompt<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u5728\u7ee7\u7eed\u7f16\u5199\u67b6\u6784\u4ee3\u7801\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u8bad\u7ec3\u6570\u636e\u8fdb\u884c\u5f52\u4e00\u5316\u5904\u7406\u3002\u6211\u4eec\u4f7f\u7528 16 \u7684 batch \u5927\u5c0f\u5e76\u5bf9\u6570\u636e\u8fdb\u884c\u6df7\u6d17\u4ee5\u5f15\u5165\u66f4\u591a\u968f\u673a\u6027\u3002<\/section>\n<section><\/section>\n<section><strong>\u5b9e\u73b0\u6587\u672c\u5d4c\u5165\u5c42<\/strong><\/section>\n<section><\/section>\n<section>\u4f60\u53ef\u80fd\u5df2\u7ecf\u770b\u5230\uff0c\u5728 Transformer \u67b6\u6784\u4e2d\uff0c\u8d77\u70b9\u662f\u5c06\u6587\u672c\u8f93\u5165\u8f6c\u6362\u4e3a\u5d4c\u5165\uff0c\u4ece\u800c\u5728\u591a\u5934\u6ce8\u610f\u529b\u4e2d\u8fdb\u884c\u8fdb\u4e00\u6b65\u5904\u7406\u3002\u7c7b\u4f3c\u5730\uff0c\u6211\u4eec\u5728\u8fd9\u91cc\u5fc5\u987b\u7f16\u5199\u4e00\u4e2a\u6587\u672c\u5d4c\u5165\u5c42\u3002\u57fa\u4e8e\u8be5\u5c42\uff0cGAN \u67b6\u6784\u8bad\u7ec3\u5728\u6211\u4eec\u7684\u5d4c\u5165\u6570\u636e\u548c\u56fe\u50cf\u5f20\u91cf\u4e0a\u8fdb\u884c\u3002<\/section>\n<section>\n<pre data-lang=\"ruby\"><section><code># Define a class for text embedding<\/code><\/section><section><code>class TextEmbedding(nn.Module):<\/code><\/section><section><code>    # Constructor method with vocab_size and embed_size parameters<\/code><\/section><section><code>    def __init__(self, vocab_size, embed_size):<\/code><\/section><section><code>        # Call the superclass constructor<\/code><\/section><section><code>        super(TextEmbedding, self).__init__()<\/code><\/section><section><code>        # Initialize embedding layer<\/code><\/section><section><code>        self.embedding = nn.Embedding(vocab_size, embed_size)<\/code><\/section><section><code>\r\n<\/code><code>    # Define the forward pass method<\/code><\/section><section><code>    def forward(self, x):<\/code><\/section><section><code>        # Return embedded representation of input<\/code><\/section><section><code>        return self.embedding(x) <\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u8bcd\u6c47\u91cf\u5c06\u57fa\u4e8e\u6211\u4eec\u7684\u8bad\u7ec3\u6570\u636e\uff0c\u5728\u7a0d\u540e\u8fdb\u884c\u8ba1\u7b97\u3002\u5d4c\u5165\u5927\u5c0f\u5c06\u4e3a 10\u3002\u5982\u679c\u4f7f\u7528\u66f4\u5927\u7684\u6570\u636e\u96c6\uff0c\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528 Hugging Face \u4e0a\u5df2\u6709\u7684\u5d4c\u5165\u6a21\u578b\u3002<\/section>\n<section><\/section>\n<section><strong>\u5b9e\u73b0\u751f\u6210\u5668\u5c42<\/strong><\/section>\n<section><\/section>\n<section>\u73b0\u5728\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\u751f\u6210\u5668\u5728 GAN \u4e2d\u7684\u4f5c\u7528\uff0c\u63a5\u4e0b\u6765\u8ba9\u6211\u4eec\u5bf9\u8fd9\u4e00\u5c42\u8fdb\u884c\u7f16\u7801\uff0c\u7136\u540e\u4e86\u89e3\u5176\u5185\u5bb9\u3002<\/section>\n<section>\n<pre data-lang=\"ruby\"><section><code>class Generator(nn.Module):<\/code><\/section><section><code> def __init__(self, text_embed_size):<\/code><\/section><section><code>\u00a0super(Generator, self).__init__()<\/code><\/section><section>\r\n<\/section><section><code># Fully connected layer that takes noise and text embedding as input<\/code><code> <\/code><\/section><section><code>self.fc1 = nn.Linear(100 + text_embed_size, 256 * 8 * 8)<\/code><code> <\/code><code> <\/code><\/section><section><code># Transposed convolutional layers to upsample the input<\/code><code> <\/code><\/section><section><code>self.deconv1 = nn.ConvTranspose2d(256, 128, 4, 2, 1)<\/code><code> <\/code><\/section><section><code>self.deconv2 = nn.ConvTranspose2d(128, 64, 4, 2, 1)<\/code><code> <\/code><\/section><section><code>self.deconv3 = nn.ConvTranspose2d(64, 3, 4, 2, 1) <\/code><code># Output has 3 channels for RGB images<\/code><code> <\/code><code> <\/code><\/section><section>\r\n<\/section><section><code># Activation functions<\/code><code> <\/code><\/section><section><code>self.relu = nn.ReLU(True)\u00a0<\/code><code># ReLU activation function<\/code><code> <\/code><\/section><section><code>self.tanh = nn.Tanh()\u00a0<\/code><code># Tanh activation function for final output<\/code><code>\r\n<\/code><\/section><section>\r\n<\/section><section><code>def forward(self, noise, text_embed):<\/code><code> <\/code><\/section><section><code># Concatenate noise and text embedding along the channel dimension<\/code><code> <\/code><\/section><section><code>x = torch.cat((noise, text_embed), dim=1)<\/code><code> <\/code><code> <\/code><\/section><section>\r\n<\/section><section><code># Fully connected layer followed by reshaping to 4D tensor<\/code><code> <\/code><\/section><section><code>x = self.fc1(x).view(-1, 256, 8, 8)<\/code><code> <\/code><code> <\/code><\/section><section>\r\n<\/section><section><code># Upsampling through transposed convolution layers with ReLU activation<\/code><code> <\/code><\/section><section><code>x = self.relu(self.deconv1(x))<\/code><code> <\/code><\/section><section><code>x = self.relu(self.deconv2(x))<\/code><code> <\/code><code> <\/code><\/section><section>\r\n<\/section><section><code># Final layer with Tanh activation to ensure output values are between -1 and 1 (for images)<\/code><code> <\/code><\/section><section><code>x = self.tanh(self.deconv3(x))<\/code><code> <\/code><code> <\/code><\/section><section>\r\n<\/section><section><code>return x<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u8be5 Generator \u7c7b\u8d1f\u8d23\u6839\u636e\u968f\u673a\u566a\u58f0\u548c\u6587\u672c\u5d4c\u5165\u7684\u7ec4\u5408\u521b\u5efa\u89c6\u9891\u5e27\uff0c\u65e8\u5728\u6839\u636e\u7ed9\u5b9a\u7684\u6587\u672c\u63cf\u8ff0\u751f\u6210\u903c\u771f\u7684\u89c6\u9891\u5e27\u3002\u8be5\u7f51\u7edc\u4ece\u5b8c\u5168\u8fde\u63a5\u5c42 (nn.Linear) \u5f00\u59cb\uff0c\u5c06\u566a\u58f0\u5411\u91cf\u548c\u6587\u672c\u5d4c\u5165\u7ec4\u5408\u6210\u5355\u4e2a\u7279\u5f81\u5411\u91cf\u3002\u7136\u540e\uff0c\u8be5\u5411\u91cf\u88ab\u91cd\u65b0\u6574\u5f62\u5e76\u7ecf\u8fc7\u4e00\u7cfb\u5217\u7684\u8f6c\u7f6e\u5377\u79ef\u5c42 (nn.ConvTranspose2d)\uff0c\u8fd9\u4e9b\u5c42\u5c06\u7279\u5f81\u56fe\u9010\u6b65\u4e0a\u91c7\u6837\u5230\u6240\u9700\u7684\u89c6\u9891\u5e27\u5927\u5c0f\u3002<\/section>\n<section><\/section>\n<section>\u8fd9\u4e9b\u5c42\u4f7f\u7528 ReLU \u6fc0\u6d3b (nn.ReLU) \u5b9e\u73b0\u975e\u7ebf\u6027\uff0c\u6700\u540e\u4e00\u5c42\u4f7f\u7528 Tanh \u6fc0\u6d3b (nn.Tanh) \u5c06\u8f93\u51fa\u7f29\u653e\u5230 [-1, 1] \u7684\u8303\u56f4\u3002\u56e0\u6b64\uff0c\u751f\u6210\u5668\u5c06\u62bd\u8c61\u7684\u9ad8\u7ef4\u8f93\u5165\u8f6c\u6362\u4e3a\u4ee5\u89c6\u89c9\u65b9\u5f0f\u8868\u793a\u8f93\u5165\u6587\u672c\u7684\u8fde\u8d2f\u89c6\u9891\u5e27\u3002<\/section>\n<section><\/section>\n<section><strong>\u5b9e\u73b0\u5224\u522b\u5668\u5c42<\/strong><\/section>\n<section><\/section>\n<section>\u5728\u7f16\u5199\u5b8c\u751f\u6210\u5668\u5c42\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u5b9e\u73b0\u53e6\u4e00\u534a\uff0c\u5373\u5224\u522b\u5668\u90e8\u5206\u3002<\/section>\n<section>\n<pre data-lang=\"ruby\"><section><code>class Discriminator(nn.Module):<\/code><\/section><section><code>    def __init__(self):<\/code><\/section><section><code>        super(Discriminator, self).__init__()<\/code><code>       <\/code><\/section><section><code>\u00a0<\/code><code>\u00a0 \u00a0  <\/code><\/section><section><code>\u00a0 \u00a0 \u00a0  \u00a0<\/code><code># Convolutional layers to process input images<\/code><code>        <\/code><\/section><section><code>\u00a0 \u00a0 \u00a0 \u00a0 self.conv1 = nn.Conv2d(3, 64, 4, 2, 1) \u00a0 # 3 input channels (RGB), 64 output channels, kernel size 4x4, stride 2, padding 1<\/code><\/section><section><code>        self.conv2 = nn.Conv2d(64, 128, 4, 2, 1) # 64 input channels, 128 output channels, kernel size 4x4, stride 2, padding 1<\/code><\/section><section><code>        self.conv3 = nn.Conv2d(128, 256, 4, 2, 1) # 128 input channels, 256 output channels, kernel size 4x4, stride 2, padding 1<\/code><\/section><section><code>\u00a0 \u00a0 \u00a0 \u00a0<\/code><\/section><section><code>\u00a0 \u00a0 \u00a0 \u00a0\u00a0<\/code><code>\u00a0# Fully connected layer for classification<\/code><\/section><section><code>        self.fc1 = nn.Linear(256 * 8 * 8, 1)  # Input size 256x8x8 (output size of last convolution), output size 1 (binary classification)<\/code><code>       <\/code><\/section><section>\r\n<\/section><section><code>\u00a0<\/code><code>        # Activation functions<\/code><\/section><section><code>        self.leaky_relu = nn.LeakyReLU(0.2, inplace=True)  # Leaky ReLU activation with negative slope 0.2<\/code><\/section><section><code>        self.sigmoid = nn.Sigmoid()  # Sigmoid activation for final output (probability)<\/code><\/section><section><code>\r\n<\/code><code>    def forward(self, input):<\/code><\/section><section><code>        # Pass input through convolutional layers with LeakyReLU activation<\/code><\/section><section><code>        x = self.leaky_relu(self.conv1(input))<\/code><\/section><section><code>        x = self.leaky_relu(self.conv2(x))<\/code><\/section><section><code>        x = self.leaky_relu(self.conv3(x))<\/code><code>        <\/code><\/section><section>\r\n<\/section><section><code>        # Flatten the output of convolutional layers<\/code><\/section><section><code>        x = x.view(-1, 256 * 8 * 8)<\/code><code>        <\/code><\/section><section>\r\n<\/section><section><code>        # Pass through fully connected layer with Sigmoid activation for binary classification<\/code><\/section><section><code>        x = self.sigmoid(self.fc1(x))<\/code><code>       <\/code><\/section><section>\r\n<\/section><section><code>\u00a0<\/code><code>\u00a0 \u00a0 \u00a0 \u00a0return x<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u5224\u522b\u5668\u7c7b\u7528\u4f5c\u4e8c\u5143\u5206\u7c7b\u5668\uff0c\u533a\u5206\u771f\u5b9e\u89c6\u9891\u5e27\u548c\u751f\u6210\u7684\u89c6\u9891\u5e27\u3002\u76ee\u7684\u662f\u8bc4\u4f30\u89c6\u9891\u5e27\u7684\u771f\u5b9e\u6027\uff0c\u4ece\u800c\u6307\u5bfc\u751f\u6210\u5668\u4ea7\u751f\u66f4\u771f\u5b9e\u7684\u8f93\u51fa\u3002\u8be5\u7f51\u7edc\u7531\u5377\u79ef\u5c42 (nn.Conv2d) \u7ec4\u6210\uff0c\u8fd9\u4e9b\u5377\u79ef\u5c42\u4ece\u8f93\u5165\u89c6\u9891\u5e27\u4e2d\u63d0\u53d6\u5206\u5c42\u7279\u5f81\uff0c Leaky ReLU \u6fc0\u6d3b (nn.LeakyReLU) \u589e\u52a0\u975e\u7ebf\u6027\uff0c\u540c\u65f6\u5141\u8bb8\u8d1f\u503c\u7684\u5c0f\u68af\u5ea6\u3002<\/section>\n<section><\/section>\n<section>\u7136\u540e\uff0c\u7279\u5f81\u56fe\u88ab\u5c55\u5e73\u5e76\u901a\u8fc7\u5b8c\u5168\u8fde\u63a5\u5c42 (nn.Linear)\uff0c\u6700\u7ec8\u4ee5 S \u5f62\u6fc0\u6d3b (nn.Sigmoid) \u8f93\u51fa\u6307\u793a\u5e27\u662f\u771f\u5b9e\u8fd8\u662f\u5047\u7684\u6982\u7387\u5206\u6570\u3002<\/section>\n<section><\/section>\n<section>\u901a\u8fc7\u8bad\u7ec3\u5224\u522b\u5668\u51c6\u786e\u5730\u5bf9\u5e27\u8fdb\u884c\u5206\u7c7b\uff0c\u751f\u6210\u5668\u540c\u65f6\u63a5\u53d7\u8bad\u7ec3\u4ee5\u521b\u5efa\u66f4\u4ee4\u4eba\u4fe1\u670d\u7684\u89c6\u9891\u5e27\uff0c\u4ece\u800c\u9a97\u8fc7\u5224\u522b\u5668\u3002<\/section>\n<section><\/section>\n<section><strong>\u7f16\u5199\u8bad\u7ec3\u53c2\u6570<\/strong><\/section>\n<section><\/section>\n<section>\u6211\u4eec\u5fc5\u987b\u8bbe\u7f6e\u7528\u4e8e\u8bad\u7ec3 GAN \u7684\u57fa\u7840\u7ec4\u4ef6\uff0c\u4f8b\u5982\u635f\u5931\u51fd\u6570\u3001\u4f18\u5316\u5668\u7b49\u3002<\/section>\n<section>\n<pre data-lang=\"makefile\"><section><code># Check for GPU<\/code><\/section><section><code>device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")<\/code><\/section><section><code>\r\n<\/code><code># Create a simple vocabulary for text prompts<\/code><\/section><section><code>all_prompts = [prompt for prompt, _, _ in prompts_and_movements]  # Extract all prompts from prompts_and_movements list<\/code><\/section><section><code>vocab = {word: idx for idx, word in enumerate(set(\" \".join(all_prompts).split()))}  # Create a vocabulary dictionary where each unique word is assigned an index<\/code><\/section><section><code>vocab_size = len(vocab)  # Size of the vocabulary<\/code><\/section><section><code>embed_size = 10  # Size of the text embedding vector<\/code><\/section><section><code>\r\n<\/code><code>def encode_text(prompt):<\/code><\/section><section><code>    # Encode a given prompt into a tensor of indices using the vocabulary<\/code><\/section><section><code>    return torch.tensor([vocab[word] for word in prompt.split()])<\/code><\/section><section><code>\r\n<\/code><code># Initialize models, loss function, and optimizers<\/code><\/section><section><code>text_embedding = TextEmbedding(vocab_size, embed_size).to(device)  # Initialize TextEmbedding model with vocab_size and embed_size<\/code><\/section><section><code>netG = Generator(embed_size).to(device)  # Initialize Generator model with embed_size<\/code><\/section><section><code>netD = Discriminator().to(device)  # Initialize Discriminator model<\/code><\/section><section><code>criterion = nn.BCELoss().to(device)  # Binary Cross Entropy loss function<\/code><\/section><section><code>optimizerD = optim.Adam(netD.parameters(), lr=0.0002, betas=(0.5, 0.999))  # Adam optimizer for Discriminator<\/code><\/section><section><code>optimizerG = optim.Adam(netG.parameters(), lr=0.0002, betas=(0.5, 0.999))  # Adam optimizer for Generator<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u8fd9\u662f\u6211\u4eec\u5fc5\u987b\u8f6c\u6362\u4ee3\u7801\u4ee5\u5728 GPU \u4e0a\u8fd0\u884c\u7684\u90e8\u5206\uff08\u5982\u679c\u53ef\u7528\uff09\u3002\u6211\u4eec\u5df2\u7ecf\u7f16\u5199\u4e86\u4ee3\u7801\u6765\u67e5\u627e vocab_size\uff0c\u5e76\u4e14\u6211\u4eec\u6b63\u5728\u4e3a\u751f\u6210\u5668\u548c\u5224\u522b\u5668\u4f7f\u7528 ADAM \u4f18\u5316\u5668\u3002\u4f60\u53ef\u4ee5\u9009\u62e9\u81ea\u5df1\u7684\u4f18\u5316\u5668\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u5b66\u4e60\u7387\u8bbe\u7f6e\u4e3a\u8f83\u5c0f\u7684\u503c 0.0002\uff0c\u5d4c\u5165\u5927\u5c0f\u4e3a 10\uff0c\u8fd9\u6bd4\u5176\u4ed6\u53ef\u4f9b\u516c\u4f17\u4f7f\u7528\u7684 Hugging Face \u6a21\u578b\u8981\u5c0f\u5f97\u591a\u3002<\/section>\n<section><\/section>\n<section><strong>\u7f16\u5199\u8bad\u7ec3 loop<\/strong><\/section>\n<section><\/section>\n<section>\u5c31\u50cf\u5176\u4ed6\u795e\u7ecf\u7f51\u7edc\u4e00\u6837\uff0c\u6211\u4eec\u5c06\u4ee5\u7c7b\u4f3c\u7684\u65b9\u5f0f\u5bf9 GAN \u67b6\u6784\u8bad\u7ec3\u8fdb\u884c\u7f16\u7801\u3002<\/section>\n<section>\n<pre data-lang=\"python\"><section><code># Number of epochs<\/code><\/section><section><code>num_epochs = 13<\/code><\/section><section><code>\r\n<\/code><code># Iterate over each epoch<\/code><\/section><section><code>for epoch in range(num_epochs):<\/code><\/section><section><code>    # Iterate over each batch of data<\/code><\/section><section><code>    for i, (data, prompts) in enumerate(dataloader):<\/code><\/section><section><code>        # Move real data to device<\/code><\/section><section><code>        real_data = data.to(device)<\/code><code>        <\/code><\/section><section>\r\n<\/section><section><code>        # Convert prompts to list<\/code><\/section><section><code>        prompts = [prompt for prompt in prompts]<\/code><\/section><section><code>\r\n<\/code><code>        # Update Discriminator<\/code><\/section><section><code>        netD.zero_grad()  # Zero the gradients of the Discriminator<\/code><\/section><section><code>        batch_size = real_data.size(0)  # Get the batch size<\/code><\/section><section><code>        labels = torch.ones(batch_size, 1).to(device)  # Create labels for real data (ones)<\/code><\/section><section><code>        output = netD(real_data)  # Forward pass real data through Discriminator<\/code><\/section><section><code>        lossD_real = criterion(output, labels)  # Calculate loss on real data<\/code><\/section><section><code>        lossD_real.backward()  # Backward pass to calculate gradients<\/code><code>       <\/code><code> <\/code><\/section><section><code> <\/code><\/section><section><code>\u00a0 \u00a0 \u00a0 \u00a0 # Generate fake data<\/code><\/section><section><code>        noise = torch.randn(batch_size, 100).to(device)  # Generate random noise<\/code><\/section><section><code>        text_embeds = torch.stack([text_embedding(encode_text(prompt).to(device)).mean(dim=0) for prompt in prompts])  # Encode prompts into text embeddings<\/code><\/section><section><code>        fake_data = netG(noise, text_embeds)  # Generate fake data from noise and text embeddings<\/code><\/section><section><code>        labels = torch.zeros(batch_size, 1).to(device)  # Create labels for fake data (zeros)<\/code><\/section><section><code>        output = netD(fake_data.detach())  # Forward pass fake data through Discriminator (detach to avoid gradients flowing back to Generator)<\/code><\/section><section><code>        lossD_fake = criterion(output, labels)  # Calculate loss on fake data<\/code><\/section><section><code>        lossD_fake.backward()  # Backward pass to calculate gradients<\/code><\/section><section><code>        optimizerD.step()  # Update Discriminator parameters<\/code><\/section><section><code>\r\n<\/code><code>        # Update Generator<\/code><\/section><section><code>        netG.zero_grad()  # Zero the gradients of the Generator<\/code><\/section><section><code>        labels = torch.ones(batch_size, 1).to(device)  # Create labels for fake data (ones) to fool Discriminator<\/code><\/section><section><code>        output = netD(fake_data)  # Forward pass fake data (now updated) through Discriminator<\/code><\/section><section><code>        lossG = criterion(output, labels)  # Calculate loss for Generator based on Discriminator's response<\/code><\/section><section><code>        lossG.backward()  # Backward pass to calculate gradients<\/code><\/section><section><code>        optimizerG.step()  # Update Generator parameters<\/code><code>    <\/code><code>    <\/code><\/section><section>\r\n<\/section><section><code># Print epoch information<\/code><\/section><section><code>print(f\"Epoch [{epoch + 1}\/{num_epochs}] Loss D: {lossD_real + lossD_fake}, Loss G: {lossG}\")<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u901a\u8fc7\u53cd\u5411\u4f20\u64ad\uff0c\u6211\u4eec\u7684\u635f\u5931\u5c06\u9488\u5bf9\u751f\u6210\u5668\u548c\u5224\u522b\u5668\u8fdb\u884c\u8c03\u6574\u3002\u6211\u4eec\u5728\u8bad\u7ec3 loop \u4e2d\u4f7f\u7528\u4e86 13 \u4e2a epoch\u3002\u6211\u4eec\u6d4b\u8bd5\u4e86\u4e0d\u540c\u7684\u503c\uff0c\u4f46\u5982\u679c epoch \u9ad8\u4e8e\u8fd9\u4e2a\u503c\uff0c\u7ed3\u679c\u5e76\u6ca1\u6709\u592a\u5927\u5dee\u5f02\u3002\u6b64\u5916\uff0c\u8fc7\u5ea6\u62df\u5408\u7684\u98ce\u9669\u5f88\u9ad8\u3002\u5982\u679c\u6211\u4eec\u7684\u6570\u636e\u96c6\u66f4\u52a0\u591a\u6837\u5316\uff0c\u5305\u542b\u66f4\u591a\u52a8\u4f5c\u548c\u5f62\u72b6\uff0c\u5219\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u66f4\u9ad8\u7684 epoch\uff0c\u4f46\u5728\u8fd9\u91cc\u6ca1\u6709\u8fd9\u6837\u505a\u3002<\/section>\n<section><\/section>\n<section>\u5f53\u6211\u4eec\u8fd0\u884c\u6b64\u4ee3\u7801\u65f6\uff0c\u5b83\u4f1a\u5f00\u59cb\u8bad\u7ec3\uff0c\u5e76\u5728\u6bcf\u4e2a epoch \u4e4b\u540e print \u751f\u6210\u5668\u548c\u5224\u522b\u5668\u7684\u635f\u5931\u3002<\/section>\n<section>\n<pre data-lang=\"css\"><section><code>## OUTPUT ##<\/code><\/section><section><code>\r\n<\/code><code>Epoch [1\/13] Loss D: 0.8798642754554749, Loss G: 1.300612449645996<\/code><\/section><section><code>Epoch [2\/13] Loss D: 0.8235711455345154, Loss G: 1.3729925155639648<\/code><\/section><section><code>Epoch [3\/13] Loss D: 0.6098687052726746, Loss G: 1.3266581296920776<\/code><\/section><section><code>\r\n<\/code><code>...<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section><strong>\u4fdd\u5b58\u8bad\u7ec3\u7684\u6a21\u578b<\/strong><\/section>\n<section><\/section>\n<section>\u8bad\u7ec3\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u4fdd\u5b58\u8bad\u7ec3\u597d\u7684 GAN \u67b6\u6784\u7684\u5224\u522b\u5668\u548c\u751f\u6210\u5668\uff0c\u8fd9\u53ea\u9700\u4e24\u884c\u4ee3\u7801\u5373\u53ef\u5b9e\u73b0\u3002<\/section>\n<section>\n<pre data-lang=\"bash\"><section><code># Save the Generator model's state dictionary to a file named 'generator.pth'<\/code><\/section><section><code>torch.save(netG.state_dict(), 'generator.pth')<\/code><\/section><section><code>\r\n<\/code><code># Save the Discriminator model's state dictionary to a file named 'discriminator.pth'<\/code><\/section><section><code>torch.save(netD.state_dict(), 'discriminator.pth')<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section><strong>\u751f\u6210 AI \u89c6\u9891<\/strong><\/section>\n<section><\/section>\n<section>\u6b63\u5982\u6211\u4eec\u6240\u8ba8\u8bba\u7684\uff0c\u6211\u4eec\u5728\u672a\u89c1\u8fc7\u7684\u6570\u636e\u4e0a\u6d4b\u8bd5\u6a21\u578b\u7684\u65b9\u6cd5\u4e0e\u6211\u4eec\u8bad\u7ec3\u6570\u636e\u4e2d\u6d89\u53ca\u72d7\u53d6\u7403\u548c\u732b\u8ffd\u8001\u9f20\u7684\u793a\u4f8b\u7c7b\u4f3c\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u7684\u6d4b\u8bd5 prompt \u53ef\u80fd\u6d89\u53ca\u732b\u53d6\u7403\u6216\u72d7\u8ffd\u8001\u9f20\u7b49\u573a\u666f\u3002<\/section>\n<section><\/section>\n<section>\u5728\u6211\u4eec\u7684\u7279\u5b9a\u60c5\u51b5\u4e0b\uff0c\u5706\u5708\u5411\u4e0a\u79fb\u52a8\u7136\u540e\u5411\u53f3\u79fb\u52a8\u7684\u8fd0\u52a8\u5728\u8bad\u7ec3\u6570\u636e\u4e2d\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u6a21\u578b\u4e0d\u719f\u6089\u8fd9\u79cd\u7279\u5b9a\u8fd0\u52a8\u3002\u4f46\u662f\uff0c\u6a21\u578b\u5df2\u7ecf\u5728\u5176\u4ed6\u52a8\u4f5c\u4e0a\u8fdb\u884c\u4e86\u8bad\u7ec3\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u6b64\u52a8\u4f5c\u4f5c\u4e3a prompt \u6765\u6d4b\u8bd5\u6211\u4eec\u8bad\u7ec3\u8fc7\u7684\u6a21\u578b\u5e76\u89c2\u5bdf\u5176\u6027\u80fd\u3002<\/section>\n<section>\n<pre data-lang=\"python\"><code># Inference function to generate a video based on a given text promptdef generate_video(text_prompt, num_frames=10):    # Create a directory for the generated video frames based on the text prompt    os.makedirs(f'generated_video_{text_prompt.replace(\" \", \"_\")}', exist_ok=True)        # Encode the text prompt into a text embedding tensor    text_embed = text_embedding(encode_text(text_prompt).to(device)).mean(dim=0).unsqueeze(0)        # Generate frames for the video    for frame_num in range(num_frames):        # Generate random noise        noise = torch.randn(1, 100).to(device)                # Generate a fake frame using the Generator network        with torch.no_grad():            fake_frame = netG(noise, text_embed)                # Save the generated fake frame as an image file        save_image(fake_frame, f'generated_video_{text_prompt.replace(\" \", \"_\")}\/frame_{frame_num}.png')# usage of the generate_video function with a specific text promptgenerate_video('circle moving up-right')<\/code><\/pre>\n<\/section>\n<section><\/section>\n<section>\u5f53\u6211\u4eec\u8fd0\u884c\u4e0a\u8ff0\u4ee3\u7801\u65f6\uff0c\u5b83\u5c06\u751f\u6210\u4e00\u4e2a\u76ee\u5f55\uff0c\u5176\u4e2d\u5305\u542b\u6211\u4eec\u751f\u6210\u89c6\u9891\u7684\u6240\u6709\u5e27\u3002\u6211\u4eec\u9700\u8981\u4f7f\u7528\u4e00\u4e9b\u4ee3\u7801\u5c06\u6240\u6709\u8fd9\u4e9b\u5e27\u5408\u5e76\u4e3a\u4e00\u4e2a\u77ed\u89c6\u9891\u3002<\/section>\n<section>\n<pre data-lang=\"makefile\"><section><code># Define the path to your folder containing the PNG frames<\/code><\/section><section><code>folder_path = 'generated_video_circle_moving_up-right'<\/code><code>\r\n<\/code><code>\r\n<\/code><code># Get the list of all PNG files in the folder<\/code><\/section><section><code>image_files = [f for f in os.listdir(folder_path) if f.endswith('.png')]<\/code><\/section><section><code>\r\n<\/code><code># Sort the images by name (assuming they are numbered sequentially)<\/code><\/section><section><code>image_files.sort()<\/code><\/section><section><code>\r\n<\/code><code># Create a list to store the frames<\/code><\/section><section><code>frames = []<\/code><\/section><section><code>\r\n<\/code><code># Read each image and append it to the frames list<\/code><\/section><section><code>for image_file in image_files:<\/code><\/section><section><code> image_path = os.path.join(folder_path, image_file)<\/code><\/section><section><code> frame = cv2.imread(image_path)<\/code><\/section><section><code> frames.append(frame)<\/code><\/section><section><code>\r\n<\/code><code># Convert the frames list to a numpy array for easier processing<\/code><\/section><section><code>frames = np.array(frames)<\/code><\/section><section><code>\r\n<\/code><code># Define the frame rate (frames per second)<\/code><\/section><section><code>fps = 10<\/code><\/section><section><code>\r\n<\/code><code># Create a video writer object<\/code><\/section><section><code>fourcc = cv2.VideoWriter_fourcc(*'XVID')<\/code><\/section><section><code>out = cv2.VideoWriter('generated_video.avi', fourcc, fps, (frames[0].shape[1], frames[0].shape[0]))<\/code><\/section><section><code>\r\n<\/code><code># Write each frame to the video<\/code><\/section><section><code>for frame in frames:<\/code><\/section><section><code>out.write(frame)<\/code><\/section><section><code>\r\n<\/code><code># Release the video writer<\/code><\/section><section><code>out.release()<\/code><\/section><\/pre>\n<\/section>\n<section><\/section>\n<section>\u786e\u4fdd\u6587\u4ef6\u5939\u8def\u5f84\u6307\u5411\u4f60\u65b0\u751f\u6210\u7684\u89c6\u9891\u6240\u5728\u7684\u4f4d\u7f6e\u3002\u8fd0\u884c\u6b64\u4ee3\u7801\u540e\uff0c\u4f60\u5c06\u6210\u529f\u521b\u5efa AI \u89c6\u9891\u3002\u8ba9\u6211\u4eec\u770b\u770b\u5b83\u662f\u4ec0\u4e48\u6837\u5b50\u3002<\/section>\n<section><a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-04588d23aa057b100165ee359956f927.gif\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-04588d23aa057b100165ee359956f927.gif\"><\/a><\/section>\n<section>\u6211\u4eec\u8fdb\u884c\u4e86\u591a\u6b21\u8bad\u7ec3\uff0c\u8bad\u7ec3\u6b21\u6570\u76f8\u540c\u3002\u5728\u4e24\u79cd\u60c5\u51b5\u4e0b\uff0c\u5706\u5708\u90fd\u662f\u4ece\u5e95\u90e8\u5f00\u59cb\uff0c\u51fa\u73b0\u4e00\u534a\u3002\u597d\u6d88\u606f\u662f\uff0c\u6211\u4eec\u7684\u6a21\u578b\u5728\u4e24\u79cd\u60c5\u51b5\u4e0b\u90fd\u5c1d\u8bd5\u6267\u884c\u76f4\u7acb\u8fd0\u52a8\u3002<\/section>\n<section><\/section>\n<section>\u4f8b\u5982\uff0c\u5728\u5c1d\u8bd5 1 \u4e2d\uff0c\u5706\u5708\u6cbf\u5bf9\u89d2\u7ebf\u5411\u4e0a\u79fb\u52a8\uff0c\u7136\u540e\u6267\u884c\u5411\u4e0a\u8fd0\u52a8\uff0c\u800c\u5728\u5c1d\u8bd5 2 \u4e2d\uff0c\u5706\u5708\u6cbf\u5bf9\u89d2\u7ebf\u79fb\u52a8\uff0c\u540c\u65f6\u5c3a\u5bf8\u7f29\u5c0f\u3002\u5728\u4e24\u79cd\u60c5\u51b5\u4e0b\uff0c\u5706\u5708\u90fd\u6ca1\u6709\u5411\u5de6\u79fb\u52a8\u6216\u5b8c\u5168\u6d88\u5931\uff0c\u8fd9\u662f\u4e00\u4e2a\u597d\u5146\u5934\u3002<\/section>\n<section><\/section>\n<section>\u6700\u540e\uff0c\u4f5c\u8005\u8868\u793a\u5df2\u7ecf\u6d4b\u8bd5\u4e86\u8be5\u67b6\u6784\u7684\u5404\u4e2a\u65b9\u9762\uff0c\u53d1\u73b0\u8bad\u7ec3\u6570\u636e\u662f\u5173\u952e\u3002\u901a\u8fc7\u5728\u6570\u636e\u96c6\u4e2d\u5305\u542b\u66f4\u591a\u52a8\u4f5c\u548c\u5f62\u72b6\uff0c\u4f60\u53ef\u4ee5\u589e\u52a0\u53ef\u53d8\u6027\u5e76\u63d0\u9ad8\u6a21\u578b\u7684\u6027\u80fd\u3002\u7531\u4e8e\u6570\u636e\u662f\u901a\u8fc7\u4ee3\u7801\u751f\u6210\u7684\uff0c\u56e0\u6b64\u751f\u6210\u66f4\u591a\u6837\u7684\u6570\u636e\u4e0d\u4f1a\u82b1\u8d39\u592a\u591a\u65f6\u95f4\uff1b\u76f8\u53cd\uff0c\u4f60\u53ef\u4ee5\u4e13\u6ce8\u4e8e\u5b8c\u5584\u903b\u8f91\u3002<\/section>\n<section><\/section>\n<section>\u6b64\u5916\uff0c\u6587\u7ae0\u4e2d\u8ba8\u8bba\u7684 GAN \u67b6\u6784\u76f8\u5bf9\u7b80\u5355\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u96c6\u6210\u9ad8\u7ea7\u6280\u672f\u6216\u4f7f\u7528\u8bed\u8a00\u6a21\u578b\u5d4c\u5165 (LLM) \u800c\u4e0d\u662f\u57fa\u672c\u795e\u7ecf\u7f51\u7edc\u5d4c\u5165\u6765\u4f7f\u5176\u66f4\u590d\u6742\u3002\u6b64\u5916\uff0c\u8c03\u6574\u5d4c\u5165\u5927\u5c0f\u7b49\u53c2\u6570\u4f1a\u663e\u8457\u5f71\u54cd\u6a21\u578b\u7684\u6709\u6548\u6027\u3002<\/section>\n<section><\/section>\n<section><sup>\u539f\u6587\u94fe\u63a5\uff1ahttps:\/\/levelup.gitconnected.com\/building-an-ai-text-to-video-model-from-scratch-using-python-35b4eb4002de<\/sup><\/section>\n<p>\u6587\u7ae0\u6765\u6e90\u4e8e\u4e92\u8054\u7f51:<a href=\"https:\/\/www.jiqizhixin.com\/articles\/2024-07-01-6\" target=\"_blank\">\u4ece\u96f6\u5f00\u59cb\uff0c\u7528\u82f1\u4f1f\u8fbeT4\u3001A10\u8bad\u7ec3\u5c0f\u578b\u6587\u751f\u89c6\u9891\u6a21\u578b\uff0c\u51e0\u5c0f\u65f6\u641e\u5b9a<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6765\u6e90\u4e8e\u4e92\u8054\u7f51:\u4ece\u96f6\u5f00\u59cb\uff0c\u7528\u82f1\u4f1f\u8fbeT4 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[27],"tags":[41,52,55,65],"class_list":["post-34305","post","type-post","status-publish","format-standard","hentry","category-news","tag-matplotlib","tag-numpy","tag-55","tag-65"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4ece\u96f6\u5f00\u59cb\uff0c\u7528\u82f1\u4f1f\u8fbeT4\u3001A10\u8bad\u7ec3\u5c0f\u578b\u6587\u751f\u89c6\u9891\u6a21\u578b\uff0c\u51e0\u5c0f\u65f6\u641e\u5b9a - \u4e00\u8d77AI\u6280\u672f<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/17aitech.com\/?p=34305\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/17aitech.com\/?p=34305\",\"url\":\"https:\/\/17aitech.com\/?p=34305\",\"name\":\"\u4ece\u96f6\u5f00\u59cb\uff0c\u7528\u82f1\u4f1f\u8fbeT4\u3001A10\u8bad\u7ec3\u5c0f\u578b\u6587\u751f\u89c6\u9891\u6a21\u578b\uff0c\u51e0\u5c0f\u65f6\u641e\u5b9a - \u4e00\u8d77AI\u6280\u672f\",\"isPartOf\":{\"@id\":\"https:\/\/17aitech.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/17aitech.com\/?p=34305#primaryimage\"},\"image\":{\"@id\":\"https:\/\/17aitech.com\/?p=34305#primaryimage\"},\"thumbnailUrl\":\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-673ce5fc5892c93d834e1b30cc343669.png\",\"datePublished\":\"2024-12-03T22:01:57+00:00\",\"author\":{\"@id\":\"https:\/\/17aitech.com\/#\/schema\/person\/60225458499e817ae0af73e67e440b9d\"},\"breadcrumb\":{\"@id\":\"https:\/\/17aitech.com\/?p=34305#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/17aitech.com\/?p=34305\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/17aitech.com\/?p=34305#primaryimage\",\"url\":\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-673ce5fc5892c93d834e1b30cc343669.png\",\"contentUrl\":\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-673ce5fc5892c93d834e1b30cc343669.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/17aitech.com\/?p=34305#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/17aitech.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4ece\u96f6\u5f00\u59cb\uff0c\u7528\u82f1\u4f1f\u8fbeT4\u3001A10\u8bad\u7ec3\u5c0f\u578b\u6587\u751f\u89c6\u9891\u6a21\u578b\uff0c\u51e0\u5c0f\u65f6\u641e\u5b9a\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/17aitech.com\/#website\",\"url\":\"https:\/\/17aitech.com\/\",\"name\":\"\u4e00\u8d77AI\u6280\u672f\",\"description\":\"\u8ba9AI\u77e5\u8bc6\u89e6\u624b\u53ef\u53ca\",\"alternateName\":\"\u4e00\u8d77AI\u6280\u672f\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/17aitech.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/17aitech.com\/#\/schema\/person\/60225458499e817ae0af73e67e440b9d\",\"name\":\"AI\u5c0f\u52a9\u624b\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/17aitech.com\/#\/schema\/person\/image\/\",\"url\":\"\/\/17aitech.com\/wp-content\/uploads\/2024\/04\/robot_3.png\",\"contentUrl\":\"\/\/17aitech.com\/wp-content\/uploads\/2024\/04\/robot_3.png\",\"caption\":\"AI\u5c0f\u52a9\u624b\"},\"description\":\"\u8fd9\u4e2a\u4eba\u5f88\u61d2\uff0c\u4ec0\u4e48\u90fd\u6ca1\u6709\u7559\u4e0b\uff5e\",\"url\":\"https:\/\/17aitech.com\/?page_id=33738&user=3\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4ece\u96f6\u5f00\u59cb\uff0c\u7528\u82f1\u4f1f\u8fbeT4\u3001A10\u8bad\u7ec3\u5c0f\u578b\u6587\u751f\u89c6\u9891\u6a21\u578b\uff0c\u51e0\u5c0f\u65f6\u641e\u5b9a - \u4e00\u8d77AI\u6280\u672f","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/17aitech.com\/?p=34305","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/17aitech.com\/?p=34305","url":"https:\/\/17aitech.com\/?p=34305","name":"\u4ece\u96f6\u5f00\u59cb\uff0c\u7528\u82f1\u4f1f\u8fbeT4\u3001A10\u8bad\u7ec3\u5c0f\u578b\u6587\u751f\u89c6\u9891\u6a21\u578b\uff0c\u51e0\u5c0f\u65f6\u641e\u5b9a - \u4e00\u8d77AI\u6280\u672f","isPartOf":{"@id":"https:\/\/17aitech.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/17aitech.com\/?p=34305#primaryimage"},"image":{"@id":"https:\/\/17aitech.com\/?p=34305#primaryimage"},"thumbnailUrl":"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-673ce5fc5892c93d834e1b30cc343669.png","datePublished":"2024-12-03T22:01:57+00:00","author":{"@id":"https:\/\/17aitech.com\/#\/schema\/person\/60225458499e817ae0af73e67e440b9d"},"breadcrumb":{"@id":"https:\/\/17aitech.com\/?p=34305#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/17aitech.com\/?p=34305"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/17aitech.com\/?p=34305#primaryimage","url":"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-673ce5fc5892c93d834e1b30cc343669.png","contentUrl":"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/07\/frc-673ce5fc5892c93d834e1b30cc343669.png"},{"@type":"BreadcrumbList","@id":"https:\/\/17aitech.com\/?p=34305#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/17aitech.com\/"},{"@type":"ListItem","position":2,"name":"\u4ece\u96f6\u5f00\u59cb\uff0c\u7528\u82f1\u4f1f\u8fbeT4\u3001A10\u8bad\u7ec3\u5c0f\u578b\u6587\u751f\u89c6\u9891\u6a21\u578b\uff0c\u51e0\u5c0f\u65f6\u641e\u5b9a"}]},{"@type":"WebSite","@id":"https:\/\/17aitech.com\/#website","url":"https:\/\/17aitech.com\/","name":"\u4e00\u8d77AI\u6280\u672f","description":"\u8ba9AI\u77e5\u8bc6\u89e6\u624b\u53ef\u53ca","alternateName":"\u4e00\u8d77AI\u6280\u672f","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/17aitech.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/17aitech.com\/#\/schema\/person\/60225458499e817ae0af73e67e440b9d","name":"AI\u5c0f\u52a9\u624b","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/17aitech.com\/#\/schema\/person\/image\/","url":"\/\/17aitech.com\/wp-content\/uploads\/2024\/04\/robot_3.png","contentUrl":"\/\/17aitech.com\/wp-content\/uploads\/2024\/04\/robot_3.png","caption":"AI\u5c0f\u52a9\u624b"},"description":"\u8fd9\u4e2a\u4eba\u5f88\u61d2\uff0c\u4ec0\u4e48\u90fd\u6ca1\u6709\u7559\u4e0b\uff5e","url":"https:\/\/17aitech.com\/?page_id=33738&user=3"}]}},"_links":{"self":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts\/34305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34305"}],"version-history":[{"count":0,"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts\/34305\/revisions"}],"wp:attachment":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}