VOOZH about

URL: https://www.analyticsvidhya.com/blog/2018/04/add-objects-paintings-images-seamlessly-amazing-python-script/

⇱ Add Objects to Paintings and Images seamlessly with this Amazing Python Script


India's Most Futuristic AI Conference Is Back – Bigger, Sharper, Bolder

  • d
  • :
  • h
  • :
  • m
  • :
  • s

Add Objects to Paintings and Images seamlessly with this Amazing Python Script

Pranav Dar Last Updated : 19 Apr, 2018
3 min read

Overview

  • A developer has created an algorithm that adds an external element to a painting and makes it look undistinguishable from the original
  • The algorithm is a convolutional neural network (CNN) that was trained on a dataset of 80,000 paintings
  • Check out the examples in the article below, read up on the paper and download the python code

Introduction

If you have ever tried inserting images of objects into a photo, you would know that the most difficult task is to make the boundaries merge with the original photo. Even when you do manage it, the resulting photo clearly looks like it’s been photoshopped. But with deep learning, this is slowly being overcome.

We covered NVIDIA’s β€˜FastPhotoStyle’ library that makes styling photos simpler and now a developer has come up with an algorithm that takes a painting, adds an external element to it, and harmonizes it to make it look almost undistinguishable from the original painting.

The developer trained a VGG convolutional neural network (CNN) on a dataset of 80,000 paintings which he collected from wikiart.org. The CNN estimates the stylization level of a painting and then adjusts the weights accordingly. Since they have not yet released any pre-trained model for this, you will have to adjust the weights manually if you use this on an image.

It is a two-pass algorithm, an improvisaatoin on the previously used single-pass approach. In order to make the object merge with the painting, VGG neural network is used.

Below is the breakdown of the algorithm behind this:

  • The input image and style are processed with the VGG network to produce a set of activation values. These capture the statistics that represent the style of each image
  • The style activations are then mapped to the input ones, using either the entire set, or nearest neighbors neural patches
  • Once that is done, the output image is reconstructed through an optimization process, by preserve the content of the input image and simultaneously matching the visual appearance of the style image

This algorithm produces far more precise results than photo compositing or global stylization techniques and it achieves levels of edits that have so far been very difficult to achieve.

Check out some of the images below that utilized this model. The original painting is on the left, the naive composite in the middle and the final output is on the right.

πŸ‘ Image
πŸ‘ Image
πŸ‘ Image
πŸ‘ Image

You can read the paper in full here and also check out the GitHub respository to get the python codes.

Our take on this

This is one of the coolest things we have covered on AVBytes. Some of the stylized images did not turn out as well but most of them are deeply impressive. This is the first example I’ve seen of such an idea that can be packaged into a business idea (perhaps as a filter in tools like Photoshop). But the developer has mentioned that this is only intended for personal and not commercial use so he must have something in mind there!

Go ahead and try it out on your machines. Let us know your experience in the comments section below!

Subscribe to AVBytes here to get regular data science, machine learning and AI updates in your inbox!

Senior Editor at Analytics Vidhya.Data visualization practitioner who loves reading and delving deeper into the data science and machine learning arts. Always looking for new ways to improve processes using ML and AI.

Login to continue reading and enjoy expert-curated content.

Free Courses

Generative AI - A Way of Life

Explore Generative AI for beginners: create text and images, use top AI tools, learn practical skills, and ethics.

Getting Started with Large Language Models

Master Large Language Models (LLMs) with this course, offering clear guidance in NLP and model training made simple.

Building LLM Applications using Prompt Engineering

This free course guides you on building LLM apps, mastering prompt engineering, and developing chatbots with enterprise data.

Improving Real World RAG Systems: Key Challenges & Practical Solutions

Explore practical solutions, advanced retrieval strategies, and agentic RAG systems to improve context, relevance, and accuracy in AI-driven applications.

Microsoft Excel: Formulas & Functions

Master MS Excel for data analysis with key formulas, functions, and LookUp tools in this comprehensive course.

Responses From Readers

Flagship Programs

GenAI Pinnacle Program| GenAI Pinnacle Plus Program| AI/ML BlackBelt Program| Agentic AI Pioneer Program

Free Courses

Generative AI| DeepSeek| OpenAI Agent SDK| LLM Applications using Prompt Engineering| DeepSeek from Scratch| Stability.AI| SSM & MAMBA| RAG Systems using LlamaIndex| Building LLMs for Code| Python| Microsoft Excel| Machine Learning| Deep Learning| Mastering Multimodal RAG| Introduction to Transformer Model| Bagging & Boosting| Loan Prediction| Time Series Forecasting| Tableau| Business Analytics| Vibe Coding in Windsurf| Model Deployment using FastAPI| Building Data Analyst AI Agent| Getting started with OpenAI o3-mini| Introduction to Transformers and Attention Mechanisms

Popular Categories

AI Agents| Generative AI| Prompt Engineering| Generative AI Application| News| Technical Guides| AI Tools| Interview Preparation| Research Papers| Success Stories| Quiz| Use Cases| Listicles

Generative AI Tools and Techniques

GANs| VAEs| Transformers| StyleGAN| Pix2Pix| Autoencoders| GPT| BERT| Word2Vec| LSTM| Attention Mechanisms| Diffusion Models| LLMs| SLMs| Encoder Decoder Models| Prompt Engineering| LangChain| LlamaIndex| RAG| Fine-tuning| LangChain AI Agent| Multimodal Models| RNNs| DCGAN| ProGAN| Text-to-Image Models| DDPM| Document Question Answering| Imagen| T5 (Text-to-Text Transfer Transformer)| Seq2seq Models| WaveNet| Attention Is All You Need (Transformer Architecture) | WindSurf| Cursor

Popular GenAI Models

Llama 4| Llama 3.1| GPT 4.5| GPT 4.1| GPT 4o| o3-mini| Sora| DeepSeek R1| DeepSeek V3| Janus Pro| Veo 2| Gemini 2.5 Pro| Gemini 2.0| Gemma 3| Claude Sonnet 3.7| Claude 3.5 Sonnet| Phi 4| Phi 3.5| Mistral Small 3.1| Mistral NeMo| Mistral-7b| Bedrock| Vertex AI| Qwen QwQ 32B| Qwen 2| Qwen 2.5 VL| Qwen Chat| Grok 3

AI Development Frameworks

n8n| LangChain| Agent SDK| A2A by Google| SmolAgents| LangGraph| CrewAI| Agno| LangFlow| AutoGen| LlamaIndex| Swarm| AutoGPT

Data Science Tools and Techniques

Python| R| SQL| Jupyter Notebooks| TensorFlow| Scikit-learn| PyTorch| Tableau| Apache Spark| Matplotlib| Seaborn| Pandas| Hadoop| Docker| Git| Keras| Apache Kafka| AWS| NLP| Random Forest| Computer Vision| Data Visualization| Data Exploration| Big Data| Common Machine Learning Algorithms| Machine Learning| Google Data Science Agent
πŸ‘ Av Logo White

Continue your learning for FREE

Forgot your password?
πŸ‘ Av Logo White

Enter OTP sent to

Edit

Wrong OTP.

Enter the OTP

Resend OTP

Resend OTP in 45s

πŸ‘ Popup Banner
πŸ‘ AI Popup Banner