We had many issues about a pure TFHub approach but I don’t know if we have something in the TFHub roadmap:

  

      github.com/tensorflow/hub
  

  
    
  
	  
  

  
    
      Fine-tunable object detection model (e.g.Coco SSD MobileNet) 6
    

    
      
        opened 
        
          
        
        Jan 14, 2020
      
      

        
          closed 
        
          
        
        Jan 28, 2020
      
        

      
        
          
          JesseWebDotCom
        
      
    

    
        type:module request
        type:support
        stat:contributions welcome
        subtype:image-classification
        subtype:request open
    
  


  
    How can I use the make_image_classifier with Coco SSD MobileNet models?
  

  

  
    
    
  

  



  

      github.com/tensorflow/hub
  

  
    
  
	  
  

  
    
      Make Object detection models fine-tunable 6
    

    
      
        opened 
        
          
        
        Sep 23, 2020
      
      

        
          closed 
        
          
        
        Jun 9, 2021
      
        

      
        
          
          RobinBaumann
        
      
    

    
        type:module request
        type:feature
    
  


  
    As I understand from #473, it is not possible to fine-tune object detection mode…ls fetched from TF Hub directly. It would be nice to have this as a feature. E.g., with the already existing Keras integration via hub.KerasLayer, it would be nice to enable a workflow similar to:

1. Load Model (e.g. https://tfhub.dev/tensorflow/ssd_mobilenet_v2/fpnlite_640x640/1 via TF Hub as hub.KerasLayer)
2. Add new input and output layers (In the [Retrain an Image classifier guide](https://www.tensorflow.org/hub/tutorials/tf2_image_retraining), this is done in a Sequential model, I think we need the functional API because the resulting hub.KerasLayer will have multiple outputs).
3. Build a new Keras Model with the desired inputs and outputs and fine tune it on custom dataset.

Please correct me if this is already possible. I played around with TF Hub the past few days and this is what I tried until now:

```python
import tensorflow as tf
import tensorflow_hub as hub
MODULE_HANDLE = "https://tfhub.dev/tensorflow/ssd_mobilenet_v2/fpnlite_640x640/1" 

# Try to set shapes for new dataset, which contains 10 foreground classes, note that this somehow does not work
shapes = {
    'num_detections': (None),
    'detection_boxes': (None, 4),
    'detection_classes': (None),
    'detection_scores': (None),
    'raw_detection_boxes': (None, 4),
    'raw_detection_scores': (None, 10),
    'detection_anchor_indices': (None),
    'detection_multiclass_scores': (None, 11)
}

module = hub.KerasLayer(MODULE_HANDLE, trainable=True, output_shape=shapes)
```


Results in 

> ERROR:absl:hub.KerasLayer is trainable but has zero trainable weights.
> ValueError: Tensor's shape (1, 100, 91) is not compatible with supplied shape (1, None, 11)


**Expected behavior (Feature Request):**

Regarding the workflow described above, in (pseudo-ish) code something like the following would be nice:


```python
MODULE_HANDLE = "https://tfhub.dev/tensorflow/ssd_mobilenet_v2/fpnlite_640x640/1" 
input_layer = tf.keras.layers.InputLayer(input_shape=(None, None, 3), dtype=tf.float32)
# instead of output_shape, it would be nice if the option exists to only provide the number of predicted classes of the new dataset
module = hub.KerasLayer(MODULE_HANDLE, trainable=True, num_classes=NEW_CLASSES)(input_layer)

model = tf.keras.Model(inputs=input_layer, outputs=[module['detection_boxes'], module['detection_scores']])
model.compile(...)
```
  

  

  
    
    
  

  



  

      github.com/tensorflow/hub
  

  
    
  
	  
  

  
    
      Finetune tfhub object detection model on Custom data (TensorFlow 2) 9
    

    
      
        opened 
        
          
        
        Apr 17, 2021
      
      

        
          closed 
        
          
        
        May 3, 2021
      
        

      
        
          
          ameyparanjape
        
      
    

    
        type:support
        type:docs
        stat:awaiting response
        subtype:Image Retraining
        subtype:image-feature-vector
        hub
    
  


  
    I am interested in training object detectors using efficientdet models. I was ab…le to train the model using the official repo, but I could not train the efficientdet-lite models using the official repo. So I'm interested in using tfhub lite model/feature vector to finetune/retrain on custom data. It seems possible, but I could not find any documentation/notes on how to retrain tfhub object detector. All the docs show the inference only. Any help on this would be greatly appreciated!