Manu commited on
Commit
54c0759
·
1 Parent(s): b06662f

updated files

Browse files
.gitignore CHANGED
@@ -1,3 +1,3 @@
1
- /saved_model
2
  .env
3
  /downloaded_models
 
1
+ /saved_models
2
  .env
3
  /downloaded_models
push-model-to-huggingface-with-cli.sh CHANGED
@@ -4,4 +4,4 @@
4
  # commit message is not customizable
5
  # https://huggingface.co/docs/huggingface_hub/guides/upload
6
 
7
- huggingface-cli upload manufy/mnist_model_keras saved_model . --commit-description "Uploaded folder using CLI" --token $HUGGINGFACE_TOKEN
 
4
  # commit message is not customizable
5
  # https://huggingface.co/docs/huggingface_hub/guides/upload
6
 
7
+ huggingface-cli upload manufy/mnist_model_keras saved_models . --commit-description "Uploaded folder using CLI" --token $HUGGINGFACE_TOKEN
push-model-to-huggingface-with-commit.py CHANGED
@@ -22,15 +22,31 @@ load_dotenv(find_dotenv())
22
  token = os.getenv("HUGGINGFACE_TOKEN")
23
  formatted_now = datetime.now().strftime("%d/%m/%Y, %H:%M:%S")
24
  ic("--- Importing HF API ---")
25
- from huggingface_hub import HfApi, CommitOperationAdd, CommitOperationDelete
26
- ic("--- Executing commit with custom message ---")
27
- api = HfApi()
28
- operations = [
29
- CommitOperationAdd(path_in_repo="saved_model", path_or_fileobj="mnist_model.keras")
30
- ]
31
- api.create_commit(
32
- repo_id="manufy/mnist_model_keras",
33
- operations=operations,
34
- commit_message=f"Updated model at {formatted_now}.",
35
- token=token
36
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  token = os.getenv("HUGGINGFACE_TOKEN")
23
  formatted_now = datetime.now().strftime("%d/%m/%Y, %H:%M:%S")
24
  ic("--- Importing HF API ---")
25
+ from huggingface_hub import HfApi, CommitOperationAdd, Repository
26
+
27
+ # Crear una instancia del repositorio
28
+ ic("--- Creating repository instance ---")
29
+ repo = Repository(local_dir="saved_models")
30
+
31
+ # Iterar sobre cada archivo en el directorio 'saved_models'
32
+ for root, dirs, files in os.walk("saved_models"):
33
+ for file in files:
34
+ file_path = os.path.join(root, file)
35
+ # Agregar cada archivo al commit
36
+ repo.add(CommitOperationAdd(path_in_repo=file_path, path_or_fileobj=file_path))
37
+
38
+ # Realizar el commit
39
+ repo.commit("Commit message")
40
+
41
+ #ic("--- Executing commit with custom message ---")
42
+ #api = HfApi()∫
43
+ #operations = [∫
44
+ # CommitOperationAdd(path_in_repo="saved_models", path_or_fileobj="saved_models")
45
+ # #CommitOperationAdd(path_in_repo="saved_models", path_or_fileobj="saved_models/keras/mnist_model.h5")
46
+ #]
47
+ #api.create_commit(
48
+ ## repo_id="manufy/mnist_model_keras",
49
+ # operations=operations,
50
+ # commit_message=f"Updated models at {formatted_now}.",
51
+ # token=token
52
+ #)
push-model-to-huggingface-with-upload-folder.py CHANGED
@@ -46,9 +46,9 @@ ic ("--- Importing HF API ---")
46
  from huggingface_hub import HfApi
47
  ic("--- Settig up HF API ---")
48
  HuggingFace_api = HfApi()
49
- ic("--- Uploading model ---")
50
  HuggingFace_api.upload_folder(
51
- folder_path="saved_model/",
52
  repo_id="manufy/mnist_model_keras",
53
  repo_type="model",
54
  token=token)
 
46
  from huggingface_hub import HfApi
47
  ic("--- Settig up HF API ---")
48
  HuggingFace_api = HfApi()
49
+ ic("--- Uploading models ---")
50
  HuggingFace_api.upload_folder(
51
+ folder_path="saved_models/",
52
  repo_id="manufy/mnist_model_keras",
53
  repo_type="model",
54
  token=token)
training.py CHANGED
@@ -67,8 +67,8 @@ ic("------ Training model ------")
67
  # save model
68
 
69
  ic("------ Saving .h5 model ------")
70
- model.save('saved_model/keras/mnist_model.h5')
71
  ic("------ Saving .keras model ------")
72
- model.save('saved_model/keras/mnist_model.keras')
73
  ic("------ Exporting .keras model ------")
74
- model.export('saved_model/exported')
 
67
  # save model
68
 
69
  ic("------ Saving .h5 model ------")
70
+ model.save('saved_models/keras/mnist_model.h5')
71
  ic("------ Saving .keras model ------")
72
+ model.save('saved_models/keras/mnist_model.keras')
73
  ic("------ Exporting .keras model ------")
74
+ model.export('saved_models/exported')