Comments (8)
There should be a warning after from keras_cv_attention_models import *
import tensorflow as tf
from keras_cv_attention_models import *
# [WARNING] Setting TF_USE_LEGACY_KERAS=1. Make sure this is ahead of importing tensorflow or keras.
Setting export TF_USE_LEGACY_KERAS=1
, or run as:
from keras_cv_attention_models import *
import tensorflow as tf
model = tf.keras.models.load_model('eva_giant_patch14_224_imagenet21k-ft1k.h5')
Besides, should better creating model and loading weights, instead of loading h5 directly:
from keras_cv_attention_models import eva
model = eva.EvaGiantPatch14()
from keras_cv_attention_models.
thank you, it worked.
from keras_cv_attention_models.
the model is loading now, but facing this error while retraining
TypeError: Tensors in list passed to 'values' of 'ConcatV2' Op have types [float32, float32, float16, ..float16]
logits data type and input data type have the same dtype, float32, but still getting this error
Logits Data Type: <dtype: 'float32'>
Logits Shape: (4, 1500)
Logits Data Type: <dtype: 'float32'>
Input Data Types: <dtype: 'float32'> <dtype: 'int32'>
Logits Data Type: <dtype: 'float32'>
Logits Shape: (4, 1500)
Logits Data Type: <dtype: 'float32'>
Input Data Types: <dtype: 'float32'> <dtype: 'int32'>
Logits Data Type: <dtype: 'float32'>
Logits Shape: (4, 1500)
Logits Data Type: <dtype: 'float32'>
Input Data Types: <dtype: 'float32'> <dtype: 'int32'>
Logits Data Type: <dtype: 'float32'>
Logits Shape: (4, 1500)
Logits Data Type: <dtype: 'float32'>
from keras_cv_attention_models.
Can you show a detail usage of that concat? If not sure which data causing that error, just call a cast
on all data for concat
.
import tensorflow as tf
xx = [tf.random.uniform([4, 100]) for _ in range(4)]
xx.append(tf.random.uniform([4, 100], dtype='float16'))
print(tf.concat([tf.cast(ii, 'float32') for ii in xx], axis=-1).shape)
from keras_cv_attention_models.
I am not using the concat operation anywhere in the program, I did try casting the data like this but gives the same error every time
x_batch_train = tf.cast(x_batch_train, tf.float32)
y_batch_train = tf.cast(y_batch_train, tf.float32)
from keras_cv_attention_models.
Here is the data loading code
the data loading part of the code
def dataset(path, batch_size, class_labels):
def configure_for_performance(dataset, batch_size):
dataset = dataset.repeat()
dataset = dataset.batch(batch_size)
dataset = dataset.prefetch(buffer_size=tf.data.experimental.AUTOTUNE)
return dataset
def read_filename(filename):
image = tf.io.read_file(filename)
image = tf.io.decode_jpeg(image, channels=3)
image = tf.image.resize(image, [224, 224])
return image
def custom_tf_dataset(path, batch_size, class_labels):
classes = os.listdir(path)
for cls in classes:
if cls not in class_labels:
class_labels[cls] = len(class_labels)
save_class_labels('class_labels.json', class_labels)
num_classes = len(class_labels)
print("number of classes are", num_classes)
filenames = glob(path + '/*/*')
num_examples = len(filenames)
print("number of examples are", num_examples)
random.shuffle(filenames)
labels = [class_labels[name.split('/')[-2]] for name in filenames]
labels = tf.data.Dataset.from_tensor_slices(labels)
image_data = tf.data.Dataset.from_tensor_slices(filenames)
image_data = image_data.map(read_filename)
image_label_dataset = tf.data.Dataset.zip((image_data, labels))
image_label_dataset = configure_for_performance(image_label_dataset, batch_size)
return image_label_dataset, num_classes, num_examples
return custom_tf_dataset(path, batch_size, class_labels)
class_labels = load_class_labels('class_labels.json')
train_ds, num_train_class, num_train_examples = dataset(train_dir, train_batch_size, class_labels)
from keras_cv_attention_models.
error
Traceback (most recent call last):
File "/data-mount-2/eva_giant/eva_giant_train.py", line 286, in <module>
result = distributed_train_step(dataset_inputs=batch)
File "/home/keertika/miniconda3/envs/keras_cv/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/tmp/__autograph_generated_file6lqoz13m.py", line 10, in tf__distributed_train_step
per_replica_losses = ag__.converted_call(ag__.ld(strategy).run, (ag__.ld(train_step),), dict(args=(ag__.ld(dataset_inputs),)), fscope)
File "/tmp/__autograph_generated_file3a8z_8fi.py", line 12, in tf___all_reduce_sum_fn
retval_ = ag__.converted_call(ag__.ld(distribution).extended.batch_reduce_to, (ag__.ld(tf).distribute.ReduceOp.SUM, ag__.ld(grads_and_vars)), None, fscope)
TypeError: in user code:
File "/data-mount-2/eva_giant/eva_giant_train.py", line 238, in distributed_train_step *
per_replica_losses = strategy.run(train_step, args=(dataset_inputs,))
File "/home/keertika/miniconda3/envs/keras_cv/lib/python3.9/site-packages/tf_keras/src/optimizers/utils.py", line 173, in _all_reduce_sum_fn *
tf.distribute.ReduceOp.SUM, grads_and_vars
TypeError: Tensors in list passed to 'values' of 'ConcatV2' Op have types [float32, float32, float16, float16, float16, float16, float16, float16, float16, float16, float16, float16, float16, float16, float16,................float16, float16, float16, float16, float16, float16, float16, float16, float16, float16, float16, float16, float16, float16]
from keras_cv_attention_models.
- I'm not sure the root cause, and just done some basic tests kecam_test.ipynb, the last
Training test
part, but cannot reproduce this error. I think maybe it's something related with loss function? Your data loading part looks just fine. - Is it running on multi GPUs? How about a single GPU?
from keras_cv_attention_models.
Related Issues (20)
- RepViT Models HOT 2
- Efficientnet EdgeTpu Models HOT 1
- Training custom model HOT 10
- Converting EfficientFormer into tflite doesn't work HOT 11
- EfficientVit-L Models HOT 3
- Amazing HOT 3
- feature extractor HOT 2
- will you have models for Fastsam and Mobilesam in the future? HOT 3
- coco_eval_script script with yolov7_w6_coco.h5 leads to low AP HOT 3
- CSPNeXt HOT 5
- PyTorch backend doesn't work in Kaggle notebook HOT 4
- Request To Add FlashInternImage Models HOT 3
- CLIP Testing Script HOT 2
- TFLite conversion for llama2 tiny models HOT 2
- problem to infer properly on custom trained yolov8 HOT 2
- yolov8 instance segmentation HOT 5
- About Denoising Vision Transformers HOT 1
- Shapes dont match if resolution other than default 640 HOT 1
- BEIT-3 Support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras_cv_attention_models.