okeowo1014 commited on
Commit
366474a
1 Parent(s): 4e71660

Update train.py

Browse files
Files changed (1) hide show
  1. train.py +5 -11
train.py CHANGED
@@ -1,14 +1,10 @@
1
  import os
2
  import tensorflow as tf
 
3
  from tensorflow.keras.preprocessing.image import ImageDataGenerator
4
  from tensorflow.keras.applications import VGG16
5
  from tensorflow.keras.layers import Flatten, Dense
6
- # from huggingface_hub import push_to_hub_keras
7
- from huggingface_hub import hf_hub_url, push_to_hub_keras
8
 
9
- # from huggingface_hub import upload_file
10
- from huggingface_hub import HfApi
11
- api = HfApi()
12
 
13
  # Environment variable for Hugging Face token
14
  sac = os.getenv('accesstoken')
@@ -94,20 +90,18 @@ print('Test accuracy:', test_acc)
94
  # Save model weights to local directory
95
  # model.save_pretrained("kerascatanddog")
96
  # model.savesave_format='tf'
97
- model.save('cat_dog_classifier2.h5',save_format='h5')
98
- new_model = tf.keras.models.load_model('cat_dog_classifier2.h5')
99
 
100
  # Show the model architecture
101
- new_model.summary()
102
 
103
  # Upload the model to your Hugging Face space repository
104
  push_to_hub_keras(
105
- new_model, # model, # Point to the SavedModel directory
106
  repo_id="okeowo1014/kerascatanddog",
107
  commit_message="cats and dog image classifier with transfer learning",
108
  tags=["image-classifier", "data-augmentation", "class-weights"],
109
  include_optimizer=True,
110
  token=sac,
111
  )
112
- # # Upload the SavedModel directory to Hugging Face Hub
113
- # api.upload_folder(folder_path=export_dir, repo_id="okeowo1014/catsanddogs", token=sac)
 
1
  import os
2
  import tensorflow as tf
3
+ from huggingface_hub import push_to_hub_keras
4
  from tensorflow.keras.preprocessing.image import ImageDataGenerator
5
  from tensorflow.keras.applications import VGG16
6
  from tensorflow.keras.layers import Flatten, Dense
 
 
7
 
 
 
 
8
 
9
  # Environment variable for Hugging Face token
10
  sac = os.getenv('accesstoken')
 
90
  # Save model weights to local directory
91
  # model.save_pretrained("kerascatanddog")
92
  # model.savesave_format='tf'
93
+ # model.save('cat_dog_classifier2.h5',save_format='h5')
94
+ # new_model = tf.keras.models.load_model('cat_dog_classifier2.h5')
95
 
96
  # Show the model architecture
97
+ model.summary()
98
 
99
  # Upload the model to your Hugging Face space repository
100
  push_to_hub_keras(
101
+ model, # model, # Point to the SavedModel directory
102
  repo_id="okeowo1014/kerascatanddog",
103
  commit_message="cats and dog image classifier with transfer learning",
104
  tags=["image-classifier", "data-augmentation", "class-weights"],
105
  include_optimizer=True,
106
  token=sac,
107
  )