<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Buckun on Medium]]></title>
        <description><![CDATA[Stories by Buckun on Medium]]></description>
        <link>https://medium.com/@buckun4223?source=rss-33e7d55ccecd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*B6NIfHzAn-Q0k5Q_</url>
            <title>Stories by Buckun on Medium</title>
            <link>https://medium.com/@buckun4223?source=rss-33e7d55ccecd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:05:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@buckun4223/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Android Çizim Uygulamasına Yapay Zeka Entegrasyonu: TensorFlow Lite ile Offline AI Özellikleri]]></title>
            <link>https://medium.com/@buckun4223/android-%C3%A7izim-uygulamas%C4%B1na-yapay-zeka-entegrasyonu-tensorflow-lite-ile-offline-ai-%C3%B6zellikleri-b479b30c59f0?source=rss-33e7d55ccecd------2</link>
            <guid isPermaLink="false">https://medium.com/p/b479b30c59f0</guid>
            <dc:creator><![CDATA[Buckun]]></dc:creator>
            <pubDate>Sun, 04 Jan 2026 22:01:33 GMT</pubDate>
            <atom:updated>2026-01-04T22:01:33.309Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B3IacUCD0KQJPMtisZ19BQ.png" /></figure><p>Çocuklar için geliştirdiğimiz çizim uygulamasına, tamamen offline çalışan yapay zeka özellikleri nasıl entegre ettik? TensorFlow Lite, tensor shape problemleri, GPU optimization ve daha fazlası…</p><h3>Giriş</h3><p>Çocuklar için geliştirdiğimiz “Learn to Draw” Android uygulamasına, tamamen <strong>offline çalışan</strong> yapay zeka özellikleri ekledik. Bu yazıda, TensorFlow Lite kullanarak mobil cihazlarda nasıl gerçek zamanlı AI özellikleri geliştirdiğimizi, karşılaştığımız zorlukları ve çözümleri detaylıca paylaşacağım.</p><h3>Projenin Hedefleri</h3><ul><li><strong>%100 Offline Çalışma</strong> — İnternet bağlantısı gerektirmeyen AI özellikleri</li><li><strong>Hızlı İşlem Süresi</strong> — 50–200ms arası inference süreleri</li><li><strong>Düşük Bellek Kullanımı</strong> — Mobil cihazlara optimize edilmiş</li><li><strong>GPU Hızlandırma</strong> — Destekleyen cihazlarda donanım hızlandırma</li><li><strong>Kullanıcı Dostu</strong> — Çocukların kolayca kullanabileceği arayüz</li></ul><h3>Feature #1: Style Transfer Engine</h3><p>TensorFlow Lite kullanarak, kullanıcıların çizimlerine <strong>gerçek zamanlı olarak</strong> 6 farklı sanatsal stil (suluboya, yağlı boya, anime, vb.) uygulayan bir motor geliştirdik.</p><p><strong>Teknik Mimari</strong></p><p><strong>İki aşamalı stil transfer sistemi:</strong></p><ol><li><strong>Style Prediction Model</strong> — Stil referans görselini 100 boyutlu bir vektöre (bottleneck) dönüştürür</li><li><strong>Style Transform Model</strong> — Content imajı ve stil bottleneck’i alarak stilize edilmiş çıktı üretir</li></ol><h3>Desteklenen Stiller</h3><ul><li>🎭 <strong>Cartoon</strong> — Çizgi film efekti</li><li>💧 <strong>Watercolor</strong> — Suluboya efekti</li><li>🖌️ <strong>Oil Painting</strong> — Yağlı boya efekti</li><li>✏️ <strong>Sketch</strong> — Karakalem efekti</li><li>🎌 <strong>Anime</strong> — Anime tarzı</li><li>💫 <strong>Neon</strong> — Neon ışık efekti</li></ul><p><strong>Kod İmplementasyonu</strong></p><pre>public class RealStyleTransferEngine {<br>    private static final int IMAGE_SIZE = 384;<br>    private static final int STYLE_IMAGE_SIZE = 256;<br>    private static final int BOTTLENECK_SIZE = 100;<br>    <br>    public Bitmap applyStyle(Bitmap inputBitmap, ArtStyle style) {<br>        float[] styleBottleneck = styleBottlenecks.get(style.getStyleName());<br>        <br>        ByteBuffer inputBuffer = preprocessImage(inputBitmap, IMAGE_SIZE);<br>        <br>        float[][][][] styleBottleneck4D = new float[1][1][1][BOTTLENECK_SIZE];<br>        System.arraycopy(styleBottleneck, 0, <br>                        styleBottleneck4D[0][0][0], 0, BOTTLENECK_SIZE);<br>        <br>        Object[] inputs = {inputBuffer, styleBottleneck4D};<br>        styleTransformer.runForMultipleInputsOutputs(inputs, outputs);<br>        <br>        return convertBufferToBitmap(outputBuffer, IMAGE_SIZE, IMAGE_SIZE);<br>    }<br>}</pre><p>🐛<strong> Karşılaştığımız Sorunlar</strong></p><p>Problem #1: GPU Uyumluluk</p><p>Bazı cihazlarda GPU delegate yüklenmiyordu.</p><p><strong>Çözüm: Graceful Fallback</strong></p><pre>try {<br>    CompatibilityList compatList = new CompatibilityList();<br>    if (compatList.isDelegateSupportedOnThisDevice()) {<br>        GpuDelegate.Options options = compatList.getBestOptionsForThisDevice();<br>        gpuDelegate = new GpuDelegate(options);<br>        interpreterOptions.addDelegate(gpuDelegate);<br>        useGPU = true;<br>        Log.d(TAG, &quot;✅ GPU acceleration enabled&quot;);<br>    }<br>} catch (Exception e) {<br>    Log.w(TAG, &quot;GPU not available, using CPU&quot;);<br>    useGPU = false;<br>}</pre><h4>GPU vs CPU Performans</h4><p><strong>Flagship (SD 888):</strong> CPU 120ms → GPU 45ms (<strong>2.7x hızlanma</strong>) <strong>Mid-range (SD 720G):</strong> CPU 180ms → GPU 65ms (<strong>2.8x hızlanma</strong>) <strong>Budget (SD 662):</strong> CPU 250ms → GPU 95ms (<strong>2.6x hızlanma</strong>)</p><p><strong>GPU kullanımı ortalama 3x hızlanma sağladı!</strong></p><h3>Feature #2: Magic Drawing Assistant</h3><p>Magic Drawing Assistant, kullanıcının çizimini analiz eder ve çizimi olduğu gibi bırakmak yerine <strong>ideal haline bir adım daha yaklaştırır.</strong></p><p>Titreyen çizgileri düzeltir<br>Şekli tamamlar<br>Oranı, merkezi ve simetriyi korur</p><p>Sonuç olarak çocuk “yardım aldığını” değil, <strong>daha iyi çizmeyi öğrendiğini</strong> hisseder.</p><h3>Özellikler</h3><p><strong>1. Otomatik Şekil Algılama</strong></p><p>Kullanıcının ne çizmeye çalıştığını tespit eder:</p><ul><li>Daire</li><li>Kare/Dikdörtgen</li><li>Üçgen</li><li>Yıldız</li><li>Kalp</li><li>Çiçek</li></ul><pre>public DrawingShape detectShape(List&lt;PointF&gt; points) {<br>    float centerX = (minX + maxX) / 2;<br>    float centerY = (minY + maxY) / 2;<br>    <br>    float avgRadius = 0;<br>    for (PointF p : points) {<br>        float dx = p.x - centerX;<br>        float dy = p.y - centerY;<br>        avgRadius += Math.sqrt(dx * dx + dy * dy);<br>    }<br>    avgRadius /= points.size();<br>    <br>    float variance = calculateVariance(points, centerX, centerY, avgRadius);<br>    <br>    if (variance &lt; avgRadius * avgRadius * 0.1) {<br>        return DrawingShape.CIRCLE;<br>    }<br>    <br>}</pre><p><strong>2. Çizgi Düzeltme</strong></p><p>Gaussian-like smoothing algoritması ile çizgileri yumuşatır:</p><pre>private List&lt;PointF&gt; smoothPoints(List&lt;PointF&gt; points) {<br>    List&lt;PointF&gt; smoothed = new ArrayList&lt;&gt;();<br>    smoothed.add(points.get(0));<br>    <br>    for (int i = 1; i &lt; points.size() - 1; i++) {<br>        PointF prev = points.get(i - 1);<br>        PointF curr = points.get(i);<br>        PointF next = points.get(i + 1);<br>        <br>        float smoothX = prev.x * 0.25f + curr.x * 0.5f + next.x * 0.25f;<br>        float smoothY = prev.y * 0.25f + curr.y * 0.5f + next.y * 0.25f;<br>        <br>        smoothed.add(new PointF(smoothX, smoothY));<br>    }<br>    <br>    smoothed.add(points.get(points.size() - 1));<br>    return smoothed;<br>}</pre><h4>Feature #3: Color Harmony Engine</h4><p>Renk teorisine dayalı uyumlu renk paletleri öneren bir motor.</p><h4>Renk Uyum Tipleri</h4><ol><li><strong>Complementary (Tamamlayıcı)</strong> — Renk çarkında karşıt renkler</li><li><strong>Analogous (Benzer)</strong> — Renk çarkında komşu renkler</li><li><strong>Triadic (Üçlü)</strong> — Renk çarkında eşit aralıklı 3 renk</li></ol><pre>case COMPLEMENTARY:<br>    colors.add(baseColor);<br>    colors.add(rotateHue(baseHSV, 180));  // Karşıt renk<br>    colors.add(adjustSaturation(baseColor, 0.7f));<br>    colors.add(adjustBrightness(baseColor, 1.2f));<br>    break;<br><br>case ANALOGOUS:<br>    colors.add(baseColor);<br>    colors.add(rotateHue(baseHSV, 30));   // +30°<br>    colors.add(rotateHue(baseHSV, -30));  // -30°<br>    colors.add(rotateHue(baseHSV, 60));   // +60°<br>    break;<br><br>case TRIADIC:<br>    colors.add(baseColor);<br>    colors.add(rotateHue(baseHSV, 120));  // +120°<br>    colors.add(rotateHue(baseHSV, 240));  // +240°<br>    break;</pre><h3>Sistem Mimarisi</h3><h4>AI Features Manager</h4><p>Tüm AI motorlarını merkezi olarak yöneten singleton sınıf:</p><pre>public class AIFeaturesManager {<br>    private static AIFeaturesManager instance;<br>    <br>    private RealStyleTransferEngine realStyleTransferEngine;<br>    private StyleTransferEngine styleTransferEngine; <br>    private MagicDrawingAssistant magicDrawingAssistant;<br>    private ColorHarmonyEngine colorHarmonyEngine;<br>    <br>    public void initialize() {<br>        try {<br>            realStyleTransferEngine = new RealStyleTransferEngine(context);<br>            if (realStyleTransferEngine.initialize()) {<br>                useRealModels = true;<br>                Log.d(TAG, &quot;✅ Using REAL ML models!&quot;);<br>            }<br>        } catch (Exception e) {<br>            Log.w(TAG, &quot;⚠️ Real models failed, using fallback&quot;);<br>            useRealModels = false;<br>        }<br>        <br>        magicDrawingAssistant = new MagicDrawingAssistant(context);<br>        colorHarmonyEngine = new ColorHarmonyEngine(context);<br>    }<br>}</pre><h4>Performans Optimizasyonları</h4><h4>1. Memory Management</h4><pre>private ByteBuffer preprocessImage(Bitmap bitmap, int size) {<br>    Bitmap resized = Bitmap.createScaledBitmap(bitmap, size, size, true);<br>    <br>    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * size * size * 3);<br>    byteBuffer.order(ByteOrder.nativeOrder());<br>    <br>    int[] pixels = new int[size * size];<br>    resized.getPixels(pixels, 0, size, 0, 0, size, size);<br>    <br>    for (int pixel : pixels) {<br>        byteBuffer.putFloat(((pixel &gt;&gt; 16) &amp; 0xFF) / 255.0f);<br>        byteBuffer.putFloat(((pixel &gt;&gt; 8) &amp; 0xFF) / 255.0f);<br>        byteBuffer.putFloat((pixel &amp; 0xFF) / 255.0f);<br>    }<br>    <br>    if (resized != bitmap) {<br>        resized.recycle();<br>    }<br>    <br>    return byteBuffer;<br>}</pre><h4>2. Pre-computed Style Bottlenecks</h4><p>Stil bottleneck’lerini önceden hesaplayarak runtime’da işlem süresini azalttık.</p><h4>3. Background Thread Management</h4><p>UI thread’i bloklamadan işlemleri arka planda yürütüyoruz.</p><h3>Performans Metrikleri</h3><h4>Memory Usage</h4><p><strong>Model Loading:</strong> ~15MB <br><strong>Single Inference:</strong> ~25MB<br><strong>GPU Delegate:</strong> +8MB<br><strong>Total Peak:</strong> ~48MB</p><h4>Battery Impact</h4><p><strong>10 stil transfer (CPU):</strong> ~2% <br><strong>10 stil transfer (GPU):</strong> ~1.5% <br><strong>Idle (modeller yüklü):</strong> &lt;0.1%</p><h3>Öğrendiklerimiz</h3><h4>TensorFlow Lite ile Çalışma</h4><ol><li><strong>Model boyutları önemli</strong> — Mobil için 5MB altı idealdir</li><li><strong>Quantization kaçınılmaz</strong> — Float16 veya Int8 kullanılmalı</li><li><strong>GPU her zaman hızlı değil</strong> — Küçük modellerde CPU daha hızlı olabilir</li><li><strong>Tensor shape’leri kritik</strong> — Boyut uyuşmazlıkları runtime’da hata verir</li><li><strong>Fallback mekanizması şart</strong> — Her cihazda çalışma garantisi yok</li></ol><h4>Android Optimizasyonu</h4><ol><li><strong>Background thread kullanımı şart</strong> — UI thread’i bloklamayın</li><li><strong>Bitmap recycling önemli</strong> — Bellek sızıntılarından kaçının</li><li><strong>Lifecycle awareness</strong> — Activity/Fragment lifecycle’ını takip edin</li><li><strong>Progressive loading</strong> — Büyük modelleri parça parça yükleyin</li><li><strong>User feedback</strong> — İşlem süresi gösterin, kullanıcıyı bilgilendirin</li></ol><h4>UX için En İyi Pratikler</h4><ol><li><strong>Offline-first yaklaşım</strong> — Hızlı ve güvenilir</li><li><strong>Instant feedback</strong> — İşlemin başladığını hemen gösterin</li><li><strong>Error recovery</strong> — Hata durumunda graceful degradation</li><li><strong>Performance visibility</strong> — Kullanıcı ne kadar hızlı olduğunu görsün</li><li><strong>Progressive enhancement</strong> — Temel özellikler herkeste çalışsın</li></ol><h3>Sonuç</h3><p>Bu projede, Android uygulamamıza <strong>tamamen offline çalışan</strong> yapay zeka özellikleri entegre ettik. TensorFlow Lite kullanarak:</p><p>✅ Real-time style transfer (50–200ms)<br>✅ Intelligent drawing assistance<br>✅ Color harmony suggestions <br>✅ GPU acceleration support <br>✅ Low memory footprint (~48MB peak) <br>✅ Graceful fallback mechanisms</p><p>Karşılaştığımız her problemi çözdük ve production-ready bir AI sistemi oluşturduk. En önemlisi, <strong>çocukların kullanabileceği kadar basit</strong> bir arayüz ile sunduk.</p><h3>Kaynaklar</h3><p><strong>TensorFlow Lite:</strong></p><ul><li>TensorFlow Lite Guide: <a href="https://ai.google.dev/edge/litert?hl=tr">https://ai.google.dev/edge/litert?hl=tr</a></li><li>TensorFlow Lite Android Quickstart: <a href="https://ai.google.dev/edge/litert/android?hl=tr">https://ai.google.dev/edge/litert/android?hl=tr</a></li><li>GPU Delegate: <a href="https://ai.google.dev/edge/litert/performance/gpu?hl=tr">https://ai.google.dev/edge/litert/performance/gpu?hl=tr</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b479b30c59f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>