<p>You would like to combine the pretrained model labels with your own labels, or in other words you are augmenting the pretrained model with new classes. The practical approach is to use the basis of transfer learning.</p>

<p>But let me tell you this, this is still a hot research topic. It is easier to retrain with your own classes than to add additional classes. Hard, not impossible!</p>

<p>What you should be doing: One way to do this is to change the last softmax layer to identify more classes than it is designed to label. <strong>Network surgery</strong>. You will have to train the model again and it will take more time.</p>

<p>Another way is to create a new custom model with all 1020 labels and train it on the whole dataset, which is not very efficient and you cannot exploit the weights from the pretrained model and you have to perform full training again.</p>

<p>A hack can be to use the checkpoint which already predicts 1000 classes. Add your data for the new class. Now you should combine the new class' data along with Imagenet data set, create TFRecords for all 1020 classes and train from the network checkpoint. </p>

<p>What you are trying to do is called "<strong>learning without forgetting</strong>". Please refer to the below paper for more information about how to implement this.</p>

<p><a href="https://arxiv.org/abs/1606.09282" rel="nofollow noreferrer">https://arxiv.org/abs/1606.09282</a></p>

<p>And the matlab code is available here.</p>

<p><a href="https://github.com/lizhitwo/LearningWithoutForgetting" rel="nofollow noreferrer">https://github.com/lizhitwo/LearningWithoutForgetting</a></p>

<p>You may also try tweaking the below file to get the result want.</p>

<p><a href="https://github.com/tensorflow/hub/blob/master/examples/image_retraining/retrain.py" rel="nofollow noreferrer">https://github.com/tensorflow/hub/blob/master/examples/image_retraining/retrain.py</a></p>

<p>Additionally, 
To get more information on retraining with pretrained models refer to the below link.</p>

<p><a href="https://www.tensorflow.org/tutorials/images/hub_with_keras" rel="nofollow noreferrer">https://www.tensorflow.org/tutorials/images/hub_with_keras</a></p>

<p>Now coming to the answer,</p>

<p>How do we do it:</p>

<p>Rebuild the same model with increased number of labels in the final classification layer then restore all weights from the pretrained inception V3 except the final layer and fine tune the model.</p>

<p>We need specify two flags for this: </p>

<pre><code>1. --pretrained_model_checkpoint_path
2. --fine_tune
</code></pre>

<p>The code will looks like this.</p>

<pre><code># Build the model. Note that we need to make sure the TensorFlow is ready to
# use before this as this command will not build TensorFlow.
cd tensorflow-models/inception
bazel build //inception:custom_train

# Path to the downloaded Inception-v3 model.
MODEL_PATH="${INCEPTION_MODEL_DIR}/inception-v3/model.ckpt-1456935"

# Directory where the data resides.
DATA_DIR=/tmp/custom-data/

# Directory where to save the checkpoint and events files.
TRAIN_DIR=/tmp/custom_train/

# Run the fine-tuning on the flowers data set starting from the pre-trained
# Imagenet-v3 model.
bazel-bin/inception/flowers_train \
  --train_dir="${TRAIN_DIR}" \
  --data_dir="${DATA_DIR}" \
  --pretrained_model_checkpoint_path="${MODEL_PATH}" \
  --fine_tune=True \
  --initial_learning_rate=0.001 \
  --input_queue_memory_factor=1
</code></pre>

<p>Refer to the below documentation for more information.</p>

<p><a href="https://github.com/tensorflow/models/tree/master/research/inception" rel="nofollow noreferrer">https://github.com/tensorflow/models/tree/master/research/inception</a></p>
Combining two Pre Trained models with 2 different classes (dataset) for Prediction
<p>I have two Pre-Trained and saved Inception Models.</p>

<p>Model 1 = Inception Model with Imagenet Classes - It can predict an image in 1000 classes.</p>

<p>Model 2 = Inception Model with my own classiciation (20 Classes) - It can predict an image in 20 classes. Performed transfer learning and saved the model.</p>

<p>I would like to combine this both to predict images with 1020 Classes.</p>

<pre><code>Model1 = inception_v3.InceptionV3(weights='imagenet')
</code></pre>

<p>Predicts image in 1000 classes</p>

<pre><code>predictions1 = Model1.predict(processed_image)

Model2 = InceptionV3(weights='imagenet',
              include_top=False,
              input_shape=(224, 224, 3))
</code></pre>

<p>I have performed transfer learning with my own 20 classes. Same input shape for both models. Predicts image in 20 classes</p>

<pre><code>predictions = Model2.predict_classes(precessed_image)
</code></pre>

<h1>How do I combine 2 Pre-Trained Inception Model to predict Imagenet classes (1000) and my own classifiers (20 Classes) = predict images on 1020 classes?</h1>

<p>Please give me your solution with a small snippet(code) as an example for better understanding. I am pretty new to Keras.</p>