<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: William Li</title>
    <description>The latest articles on DEV Community by William Li (@petportraitstudio).</description>
    <link>https://dev.to/petportraitstudio</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4028784%2F5d45b5a4-e22e-4684-bcaf-da53edd35a22.png</url>
      <title>DEV Community: William Li</title>
      <link>https://dev.to/petportraitstudio</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/petportraitstudio"/>
    <language>en</language>
    <item>
      <title>How I Built an AI Pet Portrait Generator That Turns Photos Into Art</title>
      <dc:creator>William Li</dc:creator>
      <pubDate>Tue, 14 Jul 2026 13:02:50 +0000</pubDate>
      <link>https://dev.to/petportraitstudio/how-i-built-an-ai-pet-portrait-generator-that-turns-photos-into-art-20ag</link>
      <guid>https://dev.to/petportraitstudio/how-i-built-an-ai-pet-portrait-generator-that-turns-photos-into-art-20ag</guid>
      <description>&lt;h1&gt;
  
  
  How I Built an AI Pet Portrait Generator That Turns Photos Into Art
&lt;/h1&gt;

&lt;p&gt;Ever wondered what your dog would look like as a watercolor painting? Or your cat as a royal portrait? I built a web app that does exactly that - &lt;a href="https://www.custompetart.store" rel="noopener noreferrer"&gt;Pet Portrait Studio&lt;/a&gt; transforms pet photos into custom artwork using AI.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Traditional pet portraits cost $200-500 and take 2-4 weeks. I wanted to create something that delivers in minutes, starting from $9.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Backend&lt;/strong&gt;: Python + Flask + SQLAlchemy&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI Engine&lt;/strong&gt;: Multimodal models for image analysis + image generation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage&lt;/strong&gt;: Alibaba Cloud OSS for image hosting&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Payment&lt;/strong&gt;: PayPal REST API&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email&lt;/strong&gt;: Alibaba Cloud Enterprise Email&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Photo Analysis
&lt;/h3&gt;

&lt;p&gt;When a user uploads a pet photo, the system uses a multimodal AI model to detect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;analyze_pet_image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ImageAnalysis&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Analyze a pet image to extract features.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="c1"&gt;# Priority: AI Vision → Local Analysis → Smart Defaults
&lt;/span&gt;    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;call_modelscope_vision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;image_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Identify pet type, breed, and color in JSON format&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;ImageAnalysis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;species&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;species&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;breed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;breed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;color&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;confidence&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;confidence&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This auto-fills the form fields, so users don't have to manually select their pet's breed.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Prompt Engineering
&lt;/h3&gt;

&lt;p&gt;The core of the system is the prompt engine that generates style-specific prompts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Watercolor&lt;/strong&gt;: "Soft, flowing watercolor painting with gentle washes..."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Oil Painting&lt;/strong&gt;: "Classical oil painting with rich textures and warm tones..."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cartoon&lt;/strong&gt;: "Fun, Pixar-style cartoon with vibrant colors..."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each style has 100+ prompt variations to ensure uniqueness.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Quality Scoring
&lt;/h3&gt;

&lt;p&gt;Generated portraits are scored by a separate AI model on 4 dimensions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Image clarity (25%)&lt;/li&gt;
&lt;li&gt;Artistic style consistency (25%)&lt;/li&gt;
&lt;li&gt;Pet feature accuracy (25%)&lt;/li&gt;
&lt;li&gt;Overall aesthetics (25%)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Only portraits scoring above 7/10 are delivered.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Delivery
&lt;/h3&gt;

&lt;p&gt;Portraits are delivered via email with download links. The system supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Priority queue (paid orders process first)&lt;/li&gt;
&lt;li&gt;Revisions (Pro: 1, Deluxe: 3)&lt;/li&gt;
&lt;li&gt;HD upscaling for Deluxe tier&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Technical Decisions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why Flask over Django?&lt;/strong&gt; The app is primarily a single-purpose tool, not a complex platform. Flask's simplicity fits better.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why self-hosted AI?&lt;/strong&gt; Using Alibaba Cloud's DashScope API gives us control over model selection and cost. We can switch models without changing the application code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why SQLite?&lt;/strong&gt; For a solo operator with &amp;lt;1000 orders/day, SQLite with WAL mode handles the load fine. PostgreSQL migration is planned for when traffic grows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;30 SEO landing pages targeting long-tail keywords&lt;/li&gt;
&lt;li&gt;14 blog posts for content marketing&lt;/li&gt;
&lt;li&gt;Conversion rate: ~60% (small sample)&lt;/li&gt;
&lt;li&gt;Average delivery time: 5-15 minutes&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;Upload your pet photo at &lt;a href="https://www.custompetart.store" rel="noopener noreferrer"&gt;custompetart.store&lt;/a&gt; - registered users get 3 free portraits.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>webdev</category>
      <category>pet</category>
    </item>
  </channel>
</rss>
