Categories
Misc

uploading app with TensorFlow filter to Heroku cause memory exceeded

Recently I’ve uploaded an application to Heroku with TensorFlow,

the problem is the basic memory that you get from Heroku is 512MB,

which causes the server to crash after loading images into the TensorFlow model when the images are high quality.

Process running mem=934M(182.5%)

Error R14 (Memory quota exceeded)

​

Process running mem=1108M(216.5%)

Error R15 (Memory quota vastly exceeded)

​

Then, a few times I exceeded over 1.2GB when using this model, so I bought 1GB.And then it used over 2.2GB

​

CODE:

import tensorflow_hub

import tensorflow

import numpy

import cv2

​

model = hub.load(‘https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2‘)

​

def load_image(img_path):

img = tensorflow.io.read_file(img_path)

img = tensorflow.image.decode_image(img, channels=3)

img = tensorflow.image.convert_image_dtype(img, tf.tensorflow)

img = img[tensorflow.newaxis, :]

return img

​

def stylize_img(content_image_path,style_image_path):

content_image = load_image(content_image_path)

style_image = load_image(style_image_path)

cv2.imwrite(‘styled_img.jpg’, cv2.cvtColor(np.squeeze(stylized_image)*255, cv2.COLOR_BGR2RGB))

img = tensorflow.io.read_file(‘styled_img.jpg’)

remove(‘styled_img.jpg’)

return img

​

how can I solve the memory issue?

submitted by /u/Open-Glove-5238
[visit reddit] [comments]

Categories
Misc

tf.squeseze or tf.squeeze ?

tf.squeseze or tf.squeeze ?

I dont think there is a function as ” tf.squeseze ” but it should be ” tf.squeeze “. Correct me if I am wrong.

On page: tf.einsum | TensorFlow Core v2.8.0

​

https://preview.redd.it/4qc6ahevsrh81.png?width=882&format=png&auto=webp&s=3bc5a96a8f85eed6b3b14ea1622fdc2e543d2e03

submitted by /u/theenhanceddemon
[visit reddit] [comments]

Categories
Misc

Map image to vector data using deep learning

I’m working on a project where basically I would like to take a relatively small binary image and train a DL model to produce a vector of 360 outputs, one for each angle (i.e. the amplitude response at every angle produced by the image in question). I’m trying to figure out how to best build this from a model perspective. I think some convolutional layers might make sense, but I’m not sure whether I should just build a dense layer with 360 outputs, one for each angle, or something else entirely (perhaps a convolutional AE or RNN/LSTM or something like that, since we’re looking at sequence data?) And I’m not sure how the fact angles are involved might change anything either. Any ideas are appreciated!

submitted by /u/engndesign74
[visit reddit] [comments]

Categories
Misc

Weird Assertion Error: AssertionError: Duplicate registrations for type ‘experimentalOptimizer’

Hi, I am working on a simple ML project and I am getting an error I can’t seem to resolve. I am getting: AssertionError: Duplicate registrations for type ‘experimentalOptimizer’ when I try to run any TensorFlow program that has an optimizer. I uninstalled Python, TensorFlow, and Keras and then reinstalled all three. The Adam optimizer file is present as well as several other optimizers. I couldn’t find any other documentation on this error elsewhere so any help would be greatly appreciated, thanks.

submitted by /u/MartinW1255
[visit reddit] [comments]

Categories
Misc

How to upload files in a trained model to use it?

Hi,

The title says the question. Here is the code which works in a colab. How can I convert it to make it work in the local env?:

import numpy as np
from google.colab import files
from keras.preprocessing import image
uploaded = files.upload()
for fn in uploaded.keys():

# predicting images
path = ‘/content/’ + fn
img = image.load_img(path, target_size=(300, 300))
x = image.img_to_array(img)
x = x / 255
x = np.expand_dims(x, axis=0)
images = np.vstack([x])
classes = model.predict(images, batch_size=10)
print(classes[0])
if classes[0]>0.5:
print(fn + ” is a human”)
else:
print(fn + ” is a horse”)

submitted by /u/StarLan7
[visit reddit] [comments]

Categories
Misc

I can’t seem to get Tensor Flow working on my 3070 for NLP or CNN

I have been using tensor flow for a while now but I just recently ran into a problem with one of my programs. While trying to create a convolutional network I got the error

Epoch 1/4 Process finished with exit code -1073740791 (0xC0000409) 

where I have never had this error before. I have all of the updated CUDA’s and CUDD’s and have them in the right folder so I don’t know what the problem is. Anything helps thanks.

#from keras.datasets import imdb from keras.preprocessing import sequence import tensorflow as tf VOCAB_SIZE = 88584 MAXLEN = 250 BATCH_SIZE = 64 (train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=VOCAB_SIZE) train_data = sequence.pad_sequences(train_data, MAXLEN) test_data = sequence.pad_sequences(test_data, MAXLEN) model = tf.keras.Sequential([ tf.keras.layers.Embedding(VOCAB_SIZE, 32), # Graph vector form, 32 dimensions tf.keras.layers.LSTM(32), # Long-Short term memory tf.keras.layers.Dense(1, activation="sigmoid") # Between 0-1 ]) model.compile(optimizer=tf.keras.optimizers.RMSprop(), loss="mean_squared_error", metrics=[tf.keras.metrics.RootMeanSquaredError()]) history = model.fit(x=train_data, y=train_labels, batch_size=128, epochs=10) 

submitted by /u/Cheif_Cheese
[visit reddit] [comments]

Categories
Misc

📢 New Course on TensorFlow and Keras by OpenCV

📢 New Course on TensorFlow and Keras by OpenCV submitted by /u/spmallick
[visit reddit] [comments]
Categories
Misc

2022-02-11 16:51:01.357924: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1900] Ignoring visible gpu device (device: 0, name: GeForce 820M, pci bus id: 0000:04:00.0, compute capability: 2.1) with Cuda compute capability 2.1. The minimum required Cuda capability is 3.5.

Hello everyone.

Is there a way to bypass this without having to only use my CPU?

Thanks

submitted by /u/dalpendre
[visit reddit] [comments]

Categories
Misc

Slow initialization of model with dynamic batch size in the C API

I’m experiencing very slow loading times (5 minutes) with an EfficientNet architecture I converted from PyTorch (PT -> ONNX_TF -> TF).

The problem is only present when I load the model with the `v1.compat` mode or with the C API, which is my final goal. However, it loads fast in the standard TF v2 mode In Python (< 1s). After loading the models, the inference seems equally fast and correct in all the cases. I’m using `v1.compat` only for debugging, as it seems to behave similar to the C API.

I’ve noticed that the issue disappears when I export the model from PyTorch with a fixed batch size of 1, however I would prefer to have dynamic batch size.

I created a topic in the TensorFlow forum with access to the models, and details to reproduce.

I’m looking for ideas on what could be the issue, and if the resulting SavedModels could be modified in a way the loading is as fast in the C API as in TF v2.

submitted by /u/pablo_alonso
[visit reddit] [comments]

Categories
Misc

Is there a way to lock seed so training a network will always return same results?

submitted by /u/Ninja181
[visit reddit] [comments]