{"id":26019,"date":"2022-12-21T07:00:00","date_gmt":"2022-12-21T14:00:00","guid":{"rendered":"https:\/\/cloudinary.com\/blog\/?p=26019"},"modified":"2023-12-28T12:53:18","modified_gmt":"2023-12-28T20:53:18","slug":"how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging","title":{"rendered":"How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging"},"content":{"rendered":"\n<p>Product recommendations on your e-commerce site can be a great way to increase customer satisfaction and boost sales.<\/p>\n\n\n\n<p>But identifying large volumes of unseen product images so that they can be easily matched with user preferences is an unwieldy, time-consuming task. The good news is that AI can make this manageable by doing all of the organizing, sorting, and labeling for you.<\/p>\n\n\n\n<p>Imagine a platform that can automatically recognize the content of your product images and tag them accordingly. Your images would be classified and described in no time. Using the auto-tags, you\u2019d be able to easily track which product images a customer has been selecting, and you\u2019d be able to pick out and display product images that match the customer\u2019s activities.<\/p>\n\n\n\n<p>Sound too good to be true? It\u2019s real. Cloudinary makes it possible.&nbsp;<\/p>\n\n\n\n<p>Using add-ons driven by deep neural network models that analyze images at scale with a very high precision rate, Cloudinary helps you easily keep track of customer behavior to make intelligent product recommendations.<\/p>\n\n\n\n<p>Let\u2019s dive into a demo of how Cloudinary can help you offer e-commerce product recommendations using python by automatically identifying, tagging, labeling, and categorizing all your images.&nbsp;<\/p>\n\n\n<div class='c-callout  c-callout--inline-title c-callout--note'><strong class='c-callout__title'>Note:<\/strong> <p>When you\u2019re done, you can see Cloudinary\u2019s <a href=\"https:\/\/cloudinary.com\/documentation\/django_integration\">Python SDK documentation<\/a> for more information.<\/p>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Coding Your Product Recommendation Solution<\/h2>\n\n\n\n<p>This is the logic your code will follow:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/cloudinary-res.cloudinary.com\/image\/upload\/v1670982288\/blog\/product_recommendations.png\" alt=\"Offer e-commerce product recommendations using python\"\/><\/figure>\n\n\n\n<p><a href=\"#view_the_completed_code\">View<\/a> the completed code. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisite<\/h2>\n\n\n\n<p>To perform the steps in this demo, you&#8217;ll need:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>A Cloudinary account. <\/strong>If you don&#8217;t have one yet, you can quickly <a href=\"https:\/\/cloudinary.com\/users\/register_free\">register for free<\/a>.<\/li>\n\n\n\n<li><strong>One of the automatic tagging <\/strong><a href=\"https:\/\/console.cloudinary.com\/settings\/addons\"><strong>add-ons<\/strong><\/a><strong>. <\/strong>You can register for one <a href=\"https:\/\/console.cloudinary.com\/settings\/addons\">here<\/a>. (This blog uses Amazon Rekognition for the purposes of demonstration).<\/li>\n\n\n\n<li><strong>Your product environment credentials. <\/strong>You can find your <a href=\"https:\/\/cloudinary.com\/documentation\/how_to_integrate_cloudinary#account_details\">credentials<\/a> in the Dashboard page of your <a href=\"https:\/\/console.cloudinary.com\/console\">Cloudinary Console<\/a>.<\/li>\n\n\n\n<li><strong>A working Python development environment<\/strong> with a <a href=\"https:\/\/github.com\/cloudinary\/pycloudinary#Version-Support\">supported version<\/a> of Python.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Set Up and Configuration<\/h2>\n\n\n\n<p>In a terminal in your Python3 environment, run the following code:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs shcb-wrap-lines\">pip3 install cloudinary<\/code><\/span><\/pre>\n\n\n<p>In your project, create a new file called <code>my_products.py<\/code>. Next, copy and paste the following into this file, and replace the <code>&lt;cloud_name&gt;<\/code>,<code> &lt;api_key&gt;<\/code>, and <code>&lt;api_secret&gt;<\/code> with your product environment credentials:<\/p>\n\n\n<div class='c-callout  c-callout--inline-title c-callout--warning'><strong class='c-callout__title'>Caution:<\/strong> <p>When writing your own applications, follow your organization\u2019s policy on storing secrets and don\u2019t expose your API secret.<\/p>\n<\/div>\n\n\n<p><code>my_products.py<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\"><span class=\"hljs-comment\"># Set your Cloudinary credentials<\/span>\n<span class=\"hljs-comment\"># ==============================<\/span>\ncloudinary.config(\n  cloud_name = <span class=\"hljs-string\">\"&lt;cloud_name&gt;\"<\/span>,\n  api_key = <span class=\"hljs-string\">\"&lt;api_key&gt;\"<\/span>,\n  api_secret = <span class=\"hljs-string\">\"&lt;api_secret&gt;\"<\/span>,\n  api_proxy = <span class=\"hljs-string\">\"\"<\/span>\n)\n\n<span class=\"hljs-comment\"># import Cloudinary libraries<\/span>\nimport cloudinary\nfrom cloudinary import uploader\nimport cloudinary.api\nfrom cloudinary.utils import cloudinary_url\n\n<span class=\"hljs-comment\"># import other libraries<\/span>\nimport os\nimport threading\nfrom collections import Counter\nfrom urllib.request import urlopen\nimport ssl\nimport json\nfrom flask import Flask, render_template, request\n\napp = Flask(__name__)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Step 2: Upload images to Cloudinary with auto-tagging<\/h2>\n\n\n\n<p>First, create a folder called <code>Images<\/code> in the same directory as <code>my_products.py<\/code>. Then, fill that folder with the images you want to use for this project.<\/p>\n\n\n<div class='c-callout  c-callout--inline-title c-callout--note'><strong class='c-callout__title'>Note:<\/strong> <p>The <code>Images<\/code> folder is all set up with sample images when you download the project from <a href=\"https:\/\/github.com\/cloudinary-devs\/python_product_recommendations\">GitHub<\/a>.<\/p>\n<\/div>\n\n\n<p>Copy the following code to <code>my_products.py<\/code> to upload all the images from the <code>Images<\/code> folder and automatically tag those images using Amazon Rekognition&#8217;s <a href=\"https:\/\/cloudinary.com\/guides\/image-effects\/simplify-your-life-with-automatic-image-tagging\">automatic image tagging<\/a> capabilities. Only tags that meet or exceed the specified confidence level of 0.7 are assigned to the image.<\/p>\n\n\n\n<p><code>my_products.py<\/code> (con&#8217;t):<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">def img_upload():\n  <span class=\"hljs-comment\"># Get your images stored in a local directory.<\/span>\n  listOfImgs = os.listdir(os.path.join(os.getcwd()+<span class=\"hljs-string\">'\/Images'<\/span>))\n\n  <span class=\"hljs-comment\"># Upload all those images to Cloudinary with auto-tagging.<\/span>\n  <span class=\"hljs-keyword\">for<\/span> key,row in enumerate(listOfImgs):\n    resp=cloudinary.uploader.upload(<span class=\"hljs-string\">'Images\/'<\/span>+row,\n      categorization = <span class=\"hljs-string\">\"aws_rek_tagging\"<\/span>, \n      auto_tagging = <span class=\"hljs-number\">0.8<\/span>,\n      use_filename = <span class=\"hljs-keyword\">True<\/span>,\n      unique_filename = <span class=\"hljs-keyword\">False<\/span>,\n      overwrite = <span class=\"hljs-keyword\">True<\/span>,\n      folder = <span class=\"hljs-string\">\"tagged_images\"<\/span>,\n      transformation = <span class=\"hljs-string\">\"\/c_fill,g_auto,w_250,h_250\/f_auto\/q_auto\"<\/span>,\n      <span class=\"hljs-comment\"># You\u2019ll use the my_products tag to retrieve all the images.<\/span>\n      tag=<span class=\"hljs-string\">\"my_products\"<\/span>\n      )<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<div class='c-callout  c-callout--inline-title c-callout--note'><strong class='c-callout__title'>Note:<\/strong> <p>Call this function only the first time you run the program so that the images are uploaded just once.\u00a0<\/p>\n<\/div>\n\n\n<p>For the purposes of this demo, we&#8217;re auto-tagging freshly uploaded images. However, you can just as easily auto-tag any images that are already stored in Cloudinary using the <code><a href=\"https:\/\/cloudinary.com\/documentation\/admin_api#update_details_of_an_existing_resource\">update<\/a><\/code> method of the Admin API.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Display product images and keep track of user selections<\/h2>\n\n\n\n<p>Use a Flask form to display your product images for your users to select.&nbsp;<\/p>\n\n\n\n<p>Then, use the same form to capture which product images the user chose.<\/p>\n\n\n\n<p>Copy the following code to <code>my_products.py<\/code>.<\/p>\n\n\n\n<p><code>my_products.py<\/code> (con&#8217;t):<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">@app.route(<span class=\"hljs-string\">\"\/\"<\/span>, methods=&#91;<span class=\"hljs-string\">'GET'<\/span>])\ndef index():\n  <span class=\"hljs-comment\"># Only call the img_upload function to upload your images <\/span>\n  <span class=\"hljs-comment\"># the first time you run this program:<\/span>\n\n  <span class=\"hljs-comment\"># thread = threading.Thread(target=img_upload)<\/span>\n  <span class=\"hljs-comment\"># thread.start() <\/span>\n  <span class=\"hljs-comment\"># wait here for the result to be available before continuing<\/span>\n  <span class=\"hljs-comment\"># thread.join()<\/span>\n \n  <span class=\"hljs-comment\"># Get all the images you uploaded and display the first ten of them in \u2018index.html\u2019.  <\/span>\n  result = all_images()\n  imgs=&#91;]\n  count=<span class=\"hljs-number\">1<\/span>\n  <span class=\"hljs-keyword\">for<\/span> asset in result&#91;<span class=\"hljs-string\">'resources'<\/span>]:\n    <span class=\"hljs-comment\"># Build the delivery URL for the asset.<\/span>\n    url=<span class=\"hljs-string\">\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/f_auto\/q_auto\/c_fill_pad,g_auto,w_100,h_100\/v\"<\/span>+str(asset&#91;<span class=\"hljs-string\">\"version\"<\/span>])+<span class=\"hljs-string\">\"\/\"<\/span> +asset&#91;<span class=\"hljs-string\">\"public_id\"<\/span>]\n    <span class=\"hljs-comment\"># Add image information, including image url and public ID, to an array for <\/span>\n    <span class=\"hljs-comment\"># displaying all the images in index.html.<\/span>\n    img_entry={<span class=\"hljs-string\">'url'<\/span>:url, <span class=\"hljs-string\">'id'<\/span>:<span class=\"hljs-string\">\"myCheckbox\"<\/span>+str(count), <span class=\"hljs-string\">'public_id'<\/span>:asset&#91;<span class=\"hljs-string\">'public_id'<\/span>]}\n    imgs.append(img_entry)\n    <span class=\"hljs-keyword\">if<\/span> count==<span class=\"hljs-number\">10<\/span>:\n      <span class=\"hljs-keyword\">break<\/span>\n    count+=<span class=\"hljs-number\">1<\/span>   \n  <span class=\"hljs-keyword\">return<\/span> render_template(<span class=\"hljs-string\">'index.html'<\/span>, imgs=imgs)\n \ndef all_images():\n  <span class=\"hljs-comment\"># Return a JSON with  all the images you uploaded using the cloudinary_url method from the<\/span>\n  <span class=\"hljs-comment\"># cloudinary.utils library. <\/span>\n  <span class=\"hljs-comment\"># You can also use the resources method from the admin API (rate-limited).<\/span>\n  cloudinary_url(<span class=\"hljs-string\">\"my_products.json\"<\/span>, type=<span class=\"hljs-string\">\"list\"<\/span>)\n  context = ssl._create_unverified_context()\n  response = urlopen(<span class=\"hljs-string\">\"https:\/\/res.cloudinary.com\/demo\/image\/list\/my_products.json\"<\/span>, context=context)\n  result = json.loads(response.read())\n  <span class=\"hljs-keyword\">return<\/span> result<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Copy the following code to <code>template\/index.html<\/code>. This is the HTML file your users interact with to view and select product images.<\/p>\n\n\n\n<p><code>template\/index.html<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\"><span class=\"hljs-meta\">&lt;!DOCTYPE <span class=\"hljs-meta-keyword\">html<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span> <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\">\"en\"<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta<\/span> <span class=\"hljs-attr\">charset<\/span>=<span class=\"hljs-string\">\"UTF-8\"<\/span> \/&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>Product Recommendations<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">link<\/span> <span class=\"hljs-attr\">rel<\/span>=<span class=\"hljs-string\">\"stylesheet\"<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"text\/css\"<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"\/static\/main.css\"<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"container\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>Please select some products<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n\n <span class=\"hljs-comment\">&lt;!--This form displays the product images and returns user selections to the backend.--&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">form<\/span> <span class=\"hljs-attr\">method<\/span>=<span class=\"hljs-string\">\"POST\"<\/span> <span class=\"hljs-attr\">action<\/span>=<span class=\"hljs-string\">\"{{ url_for('output')}}\"<\/span>&gt;<\/span>\n\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">ul<\/span>&gt;<\/span>\n      {% for i in imgs %}\n\n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">li<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"checkbox\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"selected_imgs\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"{{i&#91;'id']}}\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">\"{{i&#91;'public_id']}}\"<\/span> \/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span> <span class=\"hljs-attr\">for<\/span>=<span class=\"hljs-string\">\"{{i&#91;'id']}}\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">img<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"{{i&#91;'url']}}\"<\/span> \/&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">li<\/span>&gt;<\/span>\n\n      {% endfor %}\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">ul<\/span>&gt;<\/span>\n\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"submit\"<\/span>&gt;<\/span>Submit<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">form<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Copy the following CSS code to <code>static\/main.css<\/code> to style your webpage.<\/p>\n\n\n\n<p><code>static\/main.css<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">h1<\/span> {\n    <span class=\"hljs-attribute\">margin-left<\/span>: <span class=\"hljs-number\">62px<\/span>;\n    <span class=\"hljs-attribute\">font-family<\/span>: <span class=\"hljs-string\">'Arial'<\/span>;\n    <span class=\"hljs-attribute\">font-style<\/span>: normal;\n    <span class=\"hljs-attribute\">font-weight<\/span>: <span class=\"hljs-number\">500<\/span>;\n    <span class=\"hljs-attribute\">font-size<\/span>: <span class=\"hljs-number\">18px<\/span>;\n    <span class=\"hljs-attribute\">line-height<\/span>: <span class=\"hljs-number\">22px<\/span>;\n    <span class=\"hljs-attribute\">color<\/span>: <span class=\"hljs-number\">#0A0C0F<\/span>;\n }\n\n<span class=\"hljs-selector-tag\">container<\/span> {\n    <span class=\"hljs-attribute\">display<\/span>: flex;\n }\n\n<span class=\"hljs-selector-tag\">ul<\/span> {\n    <span class=\"hljs-attribute\">list-style-type<\/span>: none;\n }\n\n<span class=\"hljs-selector-tag\">li<\/span> {\n    <span class=\"hljs-attribute\">display<\/span>: inline-block;\n }\n\n<span class=\"hljs-selector-tag\">input<\/span><span class=\"hljs-selector-attr\">&#91;type=<span class=\"hljs-string\">\"checkbox\"<\/span>]<\/span><span class=\"hljs-selector-attr\">&#91;id^=<span class=\"hljs-string\">\"myCheckbox\"<\/span>]<\/span> {\n    <span class=\"hljs-attribute\">display<\/span>: none;\n }\n\n<span class=\"hljs-selector-tag\">label<\/span> {\n    <span class=\"hljs-attribute\">border<\/span>: <span class=\"hljs-number\">1px<\/span> solid <span class=\"hljs-number\">#fff<\/span>;\n    <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">10px<\/span>;\n    <span class=\"hljs-attribute\">display<\/span>: block;\n    <span class=\"hljs-attribute\">position<\/span>: relative;\n    <span class=\"hljs-attribute\">margin<\/span>: <span class=\"hljs-number\">10px<\/span>;\n    <span class=\"hljs-attribute\">cursor<\/span>: pointer;\n }\n\n<span class=\"hljs-selector-tag\">label<\/span><span class=\"hljs-selector-pseudo\">:before<\/span> {\n    <span class=\"hljs-attribute\">background-color<\/span>: white;\n    <span class=\"hljs-attribute\">color<\/span>: white;\n    <span class=\"hljs-attribute\">content<\/span>: <span class=\"hljs-string\">\" \"<\/span>;\n    <span class=\"hljs-attribute\">display<\/span>: block;\n    <span class=\"hljs-attribute\">border-radius<\/span>: <span class=\"hljs-number\">50%<\/span>;\n    <span class=\"hljs-attribute\">border<\/span>: <span class=\"hljs-number\">1px<\/span> solid grey;\n    <span class=\"hljs-attribute\">position<\/span>: absolute;\n    <span class=\"hljs-attribute\">top<\/span>: -<span class=\"hljs-number\">5px<\/span>;\n    <span class=\"hljs-attribute\">left<\/span>: -<span class=\"hljs-number\">5px<\/span>;\n    <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">25px<\/span>;\n    <span class=\"hljs-attribute\">height<\/span>: <span class=\"hljs-number\">25px<\/span>;\n    <span class=\"hljs-attribute\">text-align<\/span>: center;\n    <span class=\"hljs-attribute\">line-height<\/span>: <span class=\"hljs-number\">28px<\/span>;\n    <span class=\"hljs-attribute\">transition-duration<\/span>: <span class=\"hljs-number\">0.4s<\/span>;\n    <span class=\"hljs-attribute\">transform<\/span>: <span class=\"hljs-built_in\">scale<\/span>(<span class=\"hljs-number\">0<\/span>);\n }\n\n<span class=\"hljs-selector-tag\">label<\/span> <span class=\"hljs-selector-tag\">img<\/span> {\n    <span class=\"hljs-attribute\">height<\/span>: <span class=\"hljs-number\">100px<\/span>;\n    <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">100px<\/span>;\n    <span class=\"hljs-attribute\">transition-duration<\/span>: <span class=\"hljs-number\">0.2s<\/span>;\n    <span class=\"hljs-attribute\">transform-origin<\/span>: <span class=\"hljs-number\">50%<\/span> <span class=\"hljs-number\">50%<\/span>;\n }\n\n<span class=\"hljs-selector-pseudo\">:checked+label<\/span> {\n    <span class=\"hljs-attribute\">border-color<\/span>: <span class=\"hljs-number\">#ddd<\/span>;\n }\n\n<span class=\"hljs-selector-pseudo\">:checked+label<\/span><span class=\"hljs-selector-pseudo\">:before<\/span> {\n    <span class=\"hljs-attribute\">content<\/span>: <span class=\"hljs-string\">\"\u2713\"<\/span>;\n    <span class=\"hljs-attribute\">background-color<\/span>: grey;\n    <span class=\"hljs-attribute\">transform<\/span>: <span class=\"hljs-built_in\">scale<\/span>(<span class=\"hljs-number\">1<\/span>);\n }\n\n<span class=\"hljs-selector-pseudo\">:checked+label<\/span> <span class=\"hljs-selector-tag\">img<\/span> {\n    <span class=\"hljs-attribute\">transform<\/span>: <span class=\"hljs-built_in\">scale<\/span>(<span class=\"hljs-number\">0.9<\/span>);\n    <span class=\"hljs-comment\">\/* box-shadow: 0 0 5px #333; *\/<\/span>\n    <span class=\"hljs-attribute\">z-index<\/span>: -<span class=\"hljs-number\">1<\/span>;\n }\n\n<span class=\"hljs-selector-tag\">button<\/span> {\n    <span class=\"hljs-attribute\">background<\/span>: <span class=\"hljs-number\">#3448C5<\/span>;\n    <span class=\"hljs-attribute\">border-radius<\/span>: <span class=\"hljs-number\">4px<\/span>;\n    <span class=\"hljs-attribute\">display<\/span>: flex;\n    <span class=\"hljs-attribute\">flex-direction<\/span>: row;\n    <span class=\"hljs-attribute\">justify-content<\/span>: center;\n    <span class=\"hljs-attribute\">align-items<\/span>: center;\n    <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">12px<\/span> <span class=\"hljs-number\">16px<\/span>;\n    <span class=\"hljs-attribute\">gap<\/span>: <span class=\"hljs-number\">8px<\/span>;\n    <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">298px<\/span>;\n    <span class=\"hljs-attribute\">height<\/span>: <span class=\"hljs-number\">40px<\/span>;\n    <span class=\"hljs-attribute\">margin-left<\/span>: <span class=\"hljs-number\">62px<\/span>;\n    <span class=\"hljs-attribute\">font-family<\/span>: <span class=\"hljs-string\">'Arial'<\/span>;\n    <span class=\"hljs-attribute\">font-style<\/span>: normal;\n    <span class=\"hljs-attribute\">font-weight<\/span>: <span class=\"hljs-number\">500<\/span>;\n    <span class=\"hljs-attribute\">font-size<\/span>: <span class=\"hljs-number\">14px<\/span>;\n    <span class=\"hljs-attribute\">line-height<\/span>: <span class=\"hljs-number\">14px<\/span>;\n    <span class=\"hljs-attribute\">color<\/span>: <span class=\"hljs-number\">#FFFFFF<\/span>;\n }\n\n<span class=\"hljs-selector-tag\">button<\/span><span class=\"hljs-selector-pseudo\">:active<\/span> {\n    <span class=\"hljs-attribute\">background<\/span>: gray;\n }\n\n<span class=\"hljs-selector-tag\">button<\/span><span class=\"hljs-selector-pseudo\">:focus<\/span> {\n    <span class=\"hljs-attribute\">background<\/span>: gray;\n }<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Step 4: Find out which categories interest your users<\/h2>\n\n\n\n<p>Copy the following code to <code>my_products.py<\/code> to extract the three most popular tags from the image(s) your user selected.<\/p>\n\n\n\n<p><code>my_products.py<\/code> (con&#8217;t):<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">def most_frequent(<span class=\"hljs-keyword\">List<\/span>):\n    c = Counter(<span class=\"hljs-keyword\">List<\/span>)\n    <span class=\"hljs-keyword\">return<\/span> c.most_common(<span class=\"hljs-number\">3<\/span>)\n \n@app.route(<span class=\"hljs-string\">\"\/output\"<\/span>, methods=&#91;<span class=\"hljs-string\">'POST'<\/span>])\ndef output():\n  <span class=\"hljs-comment\"># Capture the public IDs of the selected images.<\/span>\n  selected_imgs = request.form.getlist(<span class=\"hljs-string\">\"selected_imgs\"<\/span>)\n \n  <span class=\"hljs-comment\"># Display an error message if no images were selected.<\/span>\n  <span class=\"hljs-keyword\">if<\/span> not selected_imgs:\n    message=<span class=\"hljs-string\">\"Select at least one product image.\"<\/span>\n    recommendations=&#91;]\n  <span class=\"hljs-keyword\">else<\/span>:\n    <span class=\"hljs-comment\"># If one or more images were selected, find the 3 most frequent tags for those images.<\/span>\n    result = all_images()\n    tags=&#91;]\n    tag_list=&#91;]\n    <span class=\"hljs-comment\"># Look up the details for each selected image.<\/span>\n    <span class=\"hljs-keyword\">for<\/span> img in selected_imgs:\n      <span class=\"hljs-keyword\">for<\/span> asset in result&#91;<span class=\"hljs-string\">'resources'<\/span>]:\n        <span class=\"hljs-keyword\">if<\/span> asset&#91;<span class=\"hljs-string\">'public_id'<\/span>]==img:\n          img_details = cloudinary.api.resource(img)\n          <span class=\"hljs-comment\"># Keep a list of all the tags from all selected images. <\/span>\n          <span class=\"hljs-keyword\">for<\/span> tag in img_details&#91;<span class=\"hljs-string\">'tags'<\/span>]:\n            <span class=\"hljs-comment\"># Remove irrelevant tags<\/span>\n            <span class=\"hljs-keyword\">if<\/span> tag != <span class=\"hljs-string\">\"adult\"<\/span> <span class=\"hljs-keyword\">and<\/span> tag != <span class=\"hljs-string\">\"my_products\"<\/span>:\n              tag_list.append(tag)\n    <span class=\"hljs-comment\"># Get the 3 most popular tags.<\/span>\n    most_frequent_tags=most_frequent(tag_list)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Step 5: Recommend other products your user may be interested in<\/h2>\n\n\n\n<p>Copy the following code to <code>my_products.py<\/code> to recommend other images that contain the 3 most popular tags.<\/p>\n\n\n\n<p><code>my_products.py<\/code> (con&#8217;t):<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">    recommendations=&#91;]\n    <span class=\"hljs-comment\"># Find the images that contain each of the 3 most popular tags.<\/span>\n    <span class=\"hljs-keyword\">for<\/span> frequent_tag in most_frequent_tags:\n      <span class=\"hljs-comment\"># Go through each of the uploaded images.<\/span>\n      <span class=\"hljs-keyword\">for<\/span> asset in result&#91;<span class=\"hljs-string\">'resources'<\/span>]:\n        show=<span class=\"hljs-string\">\"yes\"<\/span>\n        <span class=\"hljs-comment\"># Get the details of each image.<\/span>\n        img_details = cloudinary.api.resource(asset&#91;<span class=\"hljs-string\">'public_id'<\/span>])\n        <span class=\"hljs-keyword\">for<\/span> i in selected_imgs:\n          <span class=\"hljs-comment\"># Don\u2019t recommend an image that the user's already selected.<\/span>\n          <span class=\"hljs-keyword\">if<\/span> i == asset&#91;<span class=\"hljs-string\">'public_id'<\/span>]:\n            show=<span class=\"hljs-string\">\"no\"<\/span>\n          <span class=\"hljs-comment\"># If the image contains a popular tag, add its URL to recommendations.<\/span>\n          <span class=\"hljs-keyword\">if<\/span> frequent_tag&#91;<span class=\"hljs-number\">0<\/span>] in img_details&#91;<span class=\"hljs-string\">'tags'<\/span>] <span class=\"hljs-keyword\">and<\/span> show==<span class=\"hljs-string\">\"yes\"<\/span>:\n            <span class=\"hljs-comment\"># Add transformations to the URL to fit the image in the thumbnail.  <\/span>\n         url=<span class=\"hljs-string\">\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/f_auto\/q_auto\/c_fill_pad,g_auto,w_100,h_100\/v\"<\/span>+str(asset&#91;<span class=\"hljs-string\">\"version\"<\/span>])+<span class=\"hljs-string\">\"\/\"<\/span> +asset&#91;<span class=\"hljs-string\">\"public_id\"<\/span>]\n            <span class=\"hljs-comment\"># Exclude doubles.<\/span>\n            <span class=\"hljs-keyword\">if<\/span> url not in recommendations:\n              recommendations.append(url)\n    message=<span class=\"hljs-string\">\"We thought you might like to try these:\"<\/span>\n  <span class=\"hljs-comment\"># Display the product recommendations in \u2018output.html\u2019<\/span>\n  <span class=\"hljs-keyword\">return<\/span> render_template(<span class=\"hljs-string\">'output.html'<\/span>, recommendations=recommendations, msg=message)\n  \n<span class=\"hljs-keyword\">if<\/span> __name__ == <span class=\"hljs-string\">\"__main__\"<\/span>:\n  app.run()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Copy the following code to <code>template\/output.html<\/code> to display the recommended images.<\/p>\n\n\n\n<p><code>template\/output.html<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\"><span class=\"hljs-meta\">&lt;!DOCTYPE <span class=\"hljs-meta-keyword\">html<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span> <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\">\"en\"<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta<\/span> <span class=\"hljs-attr\">charset<\/span>=<span class=\"hljs-string\">\"UTF-8\"<\/span> \/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>Product Recommendations<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">link<\/span> <span class=\"hljs-attr\">rel<\/span>=<span class=\"hljs-string\">\"stylesheet\"<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"text\/css\"<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"\/static\/main.css\"<\/span>&gt;<\/span>\n\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">style<\/span>&gt;<\/span><span class=\"css\">\n      <span class=\"hljs-selector-tag\">h1<\/span>{\n         <span class=\"hljs-attribute\">margin-left<\/span>:<span class=\"hljs-number\">40px<\/span>; \n     }\n     <span class=\"hljs-selector-tag\">button<\/span>{\n        <span class=\"hljs-attribute\">margin-left<\/span>:<span class=\"hljs-number\">40px<\/span>;\n     }\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">style<\/span>&gt;<\/span>\n\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n       <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n           <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>{{msg}}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n           <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">ul<\/span>&gt;<\/span>\n                {% for p in recommendations %}\n                <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">li<\/span>&gt;<\/span>\n                     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">img<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"{{p}}\"<\/span>&gt;<\/span>\n                <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">li<\/span>&gt;<\/span>\n                {% endfor %}\n          <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">ul<\/span>&gt;<\/span>\n       <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n       <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">form<\/span> <span class=\"hljs-attr\">method<\/span>=<span class=\"hljs-string\">\"GET\"<\/span>  <span class=\"hljs-attr\">action<\/span>=<span class=\"hljs-string\">\"{{ url_for('index')}}\"<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"submit\"<\/span>&gt;<\/span>Choose Products<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n       <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">form<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">View the Completed Code<\/h2>\n\n\n\n<p>See the code above in action using this code playground:<\/p>\n\n\n\n<!-- Copy and Paste Me -->\n<div class=\"glitch-embed-wrap\" style=\"height: 420px; width: 100%;\">\n  <iframe src=\"https:\/\/glitch.com\/embed\/#!\/embed\/python-product-recommendations?path=templates\/index.html&amp;previewSize=0\" title=\"python-product-recommendations on Glitch\" allow=\"geolocation; microphone; camera; midi; encrypted-media; xr-spatial-tracking; fullscreen\" allowfullscreen=\"\" style=\"height: 100%; width: 100%; border: 0;\">\n  <\/iframe>\n<\/div>\n\n\n\n<p>This code is also available on <a href=\"https:\/\/github.com\/cloudinary-devs\/python_product_recommendations\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Else Can You Do?<\/h2>\n\n\n\n<p>This is just one example of the many Cloudinary capabilities you can implement to offer e-commerce product recommendations using Python. Other actions you could consider include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Experimenting with other automatic tagging add-ons, or using them in combination.<\/li>\n\n\n\n<li>Creating a matrix to tailor the automatic tagging according to particular terms and concepts your business uses. For example, all images tagged with \u201cfemale\u201d and \u201cdress\u201d can be customized as \u201cwomen\u2019s apparel.\u201d<\/li>\n\n\n\n<li>Building an algorithm to determine what\u2019s considered a matching tag. For example, instead of displaying product images with identical tags, you can display images with associated tags to what the user has selected (e.g., displaying \u201ctoothpaste\u201d when the user has selected \u201ctoothbrush\u201d).<\/li>\n\n\n\n<li>Saving user selections in a database so that you can learn more about the user over time.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>This demo shows a simple Python code solution for providing e-commerce product recommendations to users based on their previous selections. There\u2019s so much more you can do to develop this solution to suit your organization\u2019s particular needs.&nbsp;<\/p>\n\n\n\n<p>With Cloudinary, identifying user selections and recommending product images to match, based on a huge volume of unseen images, is now feasible. Cloudinary\u2019s AI capabilities provide the foundation, and from there, the sky\u2019s the limit. I invite you to customize your own solution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Product recommendations on your e-commerce site can be a great way to increase customer satisfaction and boost sales. But identifying large volumes of unseen product images so that they can be easily matched with user preferences is an unwieldy, time-consuming task. The good news is that AI can make this manageable by doing all of [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":26052,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[25,98],"class_list":["post-26019","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-asset-management","tag-e-commerce"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging<\/title>\n<meta name=\"description\" content=\"Learn how to offer e-commerce product recommendations using Python and Cloudinary\u2019s AI auto-tagging capabilities.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging\" \/>\n<meta property=\"og:description\" content=\"Learn how to offer e-commerce product recommendations using Python and Cloudinary\u2019s AI auto-tagging capabilities.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-21T14:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-28T20:53:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python-png?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"2000\" \/>\n\t<meta property=\"og:image:height\" content=\"1100\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"sharonyelenik\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging\"},\"author\":{\"name\":\"sharonyelenik\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/dc4e70df8d22a9cfdad676a82fa92a73\"},\"headline\":\"How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging\",\"datePublished\":\"2022-12-21T14:00:00+00:00\",\"dateModified\":\"2023-12-28T20:53:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging\"},\"wordCount\":840,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python.png?_i=AA\",\"keywords\":[\"Asset Management\",\"E-commerce\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2022\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging\",\"url\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging\",\"name\":\"How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python.png?_i=AA\",\"datePublished\":\"2022-12-21T14:00:00+00:00\",\"dateModified\":\"2023-12-28T20:53:18+00:00\",\"description\":\"Learn how to offer e-commerce product recommendations using Python and Cloudinary\u2019s AI auto-tagging capabilities.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python.png?_i=AA\",\"width\":2000,\"height\":1100},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/dc4e70df8d22a9cfdad676a82fa92a73\",\"name\":\"sharonyelenik\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6565cdd768a04e9b6ea3932764886209dd9de8baeeef1504eaad8fe776677f92?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6565cdd768a04e9b6ea3932764886209dd9de8baeeef1504eaad8fe776677f92?s=96&d=mm&r=g\",\"caption\":\"sharonyelenik\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging","description":"Learn how to offer e-commerce product recommendations using Python and Cloudinary\u2019s AI auto-tagging capabilities.","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:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging","og_locale":"en_US","og_type":"article","og_title":"How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging","og_description":"Learn how to offer e-commerce product recommendations using Python and Cloudinary\u2019s AI auto-tagging capabilities.","og_url":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging","og_site_name":"Cloudinary Blog","article_published_time":"2022-12-21T14:00:00+00:00","article_modified_time":"2023-12-28T20:53:18+00:00","og_image":[{"width":2000,"height":1100,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python-png?_i=AA","type":"image\/png"}],"author":"sharonyelenik","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging"},"author":{"name":"sharonyelenik","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/dc4e70df8d22a9cfdad676a82fa92a73"},"headline":"How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging","datePublished":"2022-12-21T14:00:00+00:00","dateModified":"2023-12-28T20:53:18+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging"},"wordCount":840,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python.png?_i=AA","keywords":["Asset Management","E-commerce"],"inLanguage":"en-US","copyrightYear":"2022","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging","url":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging","name":"How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python.png?_i=AA","datePublished":"2022-12-21T14:00:00+00:00","dateModified":"2023-12-28T20:53:18+00:00","description":"Learn how to offer e-commerce product recommendations using Python and Cloudinary\u2019s AI auto-tagging capabilities.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python.png?_i=AA","width":2000,"height":1100},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/how-to-offer-e-commerce-product-recommendations-using-python-and-auto-tagging#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Offer E-Commerce Product Recommendations Using Python and Auto-tagging"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/dc4e70df8d22a9cfdad676a82fa92a73","name":"sharonyelenik","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6565cdd768a04e9b6ea3932764886209dd9de8baeeef1504eaad8fe776677f92?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6565cdd768a04e9b6ea3932764886209dd9de8baeeef1504eaad8fe776677f92?s=96&d=mm&r=g","caption":"sharonyelenik"}}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1670620589\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python\/Cld_Blog_FeatImg_Dec2k22_product-reco-Python.png?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/26019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=26019"}],"version-history":[{"count":31,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/26019\/revisions"}],"predecessor-version":[{"id":32301,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/26019\/revisions\/32301"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/26052"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=26019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=26019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=26019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}