Pretrained ofxTensorFlow2 models?

Does anyone know good resources for pretrained Tensorflow models, except Tensorhub: TensorFlow Hub?
I am especially interested in models for colorization, midiBert(music generation), and word to image, but others would also be nice.
I found one pretrained .h5 model (“my_model_colorization.h5” from: GitHub - pvitoria/ChromaGAN: Official Implementation of ChromaGAN: An Adversarial Approach for Picture Colorization) for colorization and tried to convert it to .pb.
ChromaGAN_pretrainedWeights - Google Drive
python - How to export Keras .h5 to tensorflow .pb? - Stack Overflow
Loading the converted model is successful, but it only outputs a tensor with shape {1,1000} (and should output something like {0, 256,256,3}, I guess). It would be nice to know what I am doing wrong.
Another question: Is it possible to convert Magenta pretrained models (.mag) to ofxTensorFlow2 pretrained models (.pb)?

This is how I try to run the colorization model:

void ofApp::setup() {
	if (!ofxTF2::setGPUMaxMemory(ofxTF2::GPU_PERCENT_70, true)) {
		ofLogError() << "failed to set GPU Memory options!";
	// load first model, bail out on error
	if(!model.load("model2")) {
	model.setup({ "serving_default_input_1"} , { "StatefulPartitionedCall"});
	input = cppflow::decode_jpeg(cppflow::read_file(std::string(ofToDataPath("wave.jpg"))));
	input = cppflow::expand_dims(input, 0);
	input = cppflow::resize_bicubic(input, cppflow::tensor({ 224, 224 }), true);
	input = cppflow::cast(input, TF_UINT8, TF_FLOAT);
	input = cppflow::div(input, cppflow::tensor({ 255.f }));

void ofApp::update() {
	if (videoPlayer.isFrameNew()) {
		input2 = ofxTF2::pixelsToTensor(videoPlayer.getPixels());
		input2 = cppflow::expand_dims(input2, 0);
		input2 = cppflow::cast(input2, TF_UINT8, TF_FLOAT);
		input2 = cppflow::div(input2, cppflow::tensor({ 255.f }));
		output = model.runModel(input);
		shape = ofxTF2::getTensorShape(output);
		std::cout << ofToString(shape) << endl;
		imgOut.allocate(224, 224, OF_IMAGE_COLOR);
		//ofxTF2::tensorToImage(output, imgOut);

void ofApp::draw() {
	//imgOut.draw(0, 0, shape[2], shape[1]);
1 Like

Hey Jona,

does the python model return the same kind of data?

I’d love to try but the Colab from the authors doesn’t load any longer. Probably a wrong package version somewhere.

Regarding more pre-trained models you could have a look here, but the models are not exclusively Tensorflow.

1 Like

@felixd thanks. I have to try it with the python model. Meanwhile I found another model, that works with OF: Image colorization with ofxTensorFlow2