AI Photo Gallery Classification for Mobile App

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
AI Photo Gallery Classification for Mobile App
Medium
~5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    761
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    649
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1071
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    884
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    466

AI-Powered Photo Gallery Classification for Mobile Apps

Photo classification in a gallery is one of the few AI tasks where on-device processing is the standard, not an exception. Apple Photos, Google Photos — both use on-device ML. Uploading personal user photos to a server for classification is technically redundant and wrong from a privacy perspective.

On-Device Classification: What Works Out of the Box

On iOS, use the Vision framework with VNClassifyImageRequest. No third-party models needed — built-in classification covers 1000+ categories:

import Vision

func classifyPhoto(cgImage: CGImage, completion: @escaping ([String]) -> Void) {
    let request = VNClassifyImageRequest { request, error in
        guard let results = request.results as? [VNClassificationObservation] else { return }
        // Take categories with confidence > 0.5
        let labels = results
            .filter { $0.confidence > 0.5 }
            .map { $0.identifier }
        completion(labels)
    }
    try? VNImageRequestHandler(cgImage: cgImage, options: [:]).perform([request])
}

Inference time is 5–15 ms per photo depending on device. On iPhone 13+ Neural Engine processes an entire 1000-photo gallery in ~15–20 seconds as a background task.

On Android, use ML Kit ImageLabeler with ImageLabelerOptions:

val labeler = ImageLabeling.getClient(
    ImageLabelerOptions.Builder()
        .setConfidenceThreshold(0.5f)
        .build()
)

labeler.process(InputImage.fromBitmap(bitmap, 0))
    .addOnSuccessListener { labels ->
        val categories = labels.map { it.text }
        // "Dog", "Outdoor", "Sky", "Food", etc.
    }

ML Kit supports 400+ categories on-device without network.

Processing Entire Gallery: PHFetchResult and Batching

Problem: a gallery can contain 50,000+ photos. Iterating through all of them at once blocks the main thread and drains battery.

Right approach: PHFetchResult + incremental processing via DispatchQueue.global(qos: .background):

func classifyGallery() {
    let fetchOptions = PHFetchOptions()
    fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
    let allPhotos = PHAsset.fetchAssets(with: .image, options: fetchOptions)

    let batchSize = 50
    let processingQueue = DispatchQueue(label: "photo.classification", qos: .background)

    processingQueue.async {
        var offset = 0
        while offset < allPhotos.count {
            let batch = (offset..<min(offset + batchSize, allPhotos.count))
                .map { allPhotos.object(at: $0) }
            self.processBatch(assets: batch)
            offset += batchSize
            Thread.sleep(forTimeInterval: 0.1) // Let the system breathe
        }
    }
}

Thread.sleep(0.1) between batches is critical — without it, CPU throttles after 2–3 minutes and speed drops 3–5x.

Storing Classification Results

Save results locally, not on server. Use Core Data with NSPersistentContainer:

// Entity: PhotoClassification
// Attributes: assetLocalIdentifier (String), labels (Transformable: [String]), classifiedAt (Date)

Index on assetLocalIdentifier + index on labels for fast search. For 50k photos, table weighs ~5–10 MB.

When opening gallery, pull classifications from local DB, display. New photos (added after last session) classify incrementally via PHPhotoLibraryChangeObserver.

Custom Categories via CoreML

Built-in Vision doesn't always cover needed categories. For custom ones (e.g., "recipe", "document screenshot", "receipt", "visa") — train a CreateML model:

// CreateML: 5–10 examples per category sufficient for basic accuracy
let dataSource = MLImageClassifier.DataSource.labeledDirectories(at: trainingDir)
let model = try MLImageClassifier(trainingData: dataSource)
try model.write(to: modelURL)

Accuracy on custom categories with 20+ examples — 85–95%. Model in CoreML format — 5–15 MB. Can be delivered via Core ML Model Deployment without app update.

Common Mistakes

Classifying on main thread — most frequent. VNImageRequestHandler.perform executes synchronously. Always use background queue.

Requesting full-resolution for classification — unnecessary. PHAsset requestImage with targetSize: CGSize(width: 224, height: 224) is enough — this is standard input for most classification models.

Not updating classifications on gallery changesPHPhotoLibraryChangeObserver should trigger incremental processing only for new/modified photos.

Timelines

Basic classification with Vision + Core Data storage — 4–6 days. Full implementation with custom categories, incremental updates, and fast tag search — 2–3 weeks. Cost calculated individually.