Dean commited on
Commit
09be2fb
2 Parent(s): ec2a2c2 a1c754b

PR conflict resolution plus making HF upload more generic

Browse files
.github/workflows/sync_to_hub.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face hub
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+
7
+ # to run this workflow manually from the Actions tab
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ sync-to-hub:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ with:
16
+ fetch-depth: 0
17
+ - name: Push to hub
18
+ env:
19
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
20
+ run: git push --force https://gagan3012:$HF_TOKEN@huggingface.co/spaces/gagan3012/t5-summarisation
.gitignore CHANGED
@@ -97,4 +97,5 @@ summarization-dagshub/
97
  /models
98
  default/
99
  artifacts/
100
- mlruns/
 
97
  /models
98
  default/
99
  artifacts/
100
+ mlruns/
101
+ hf_model/
README.md CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  summarization
2
  ==============================
3
 
1
+ ---
2
+ title: T5-Summarisation
3
+ emoji: ✌
4
+ colorFrom: yellow
5
+ colorTo: red
6
+ sdk: streamlit
7
+ app_file: app.py
8
+ pinned: false
9
+ ---
10
+
11
  summarization
12
  ==============================
13
 
dvc.lock CHANGED
@@ -10,8 +10,8 @@ stages:
10
  md5: 6069153a075b00dfb6d9e0843dd2da89
11
  size: 52739
12
  - path: model_params.yml
13
- md5: 9fcf006ee30f2b751078598a3fba9bb5
14
- size: 235
15
  - path: src/models/train_model.py
16
  md5: f7d1121426c3d5530c2b9697cb7ac74a
17
  size: 951
@@ -21,7 +21,7 @@ stages:
21
  size: 243476333
22
  nfiles: 5
23
  - path: reports/training_metrics.csv
24
- md5: 0b6c1518aed802bea976e883caac2a90
25
  size: 320
26
  eval:
27
  cmd: python src/models/evaluate_model.py
@@ -30,8 +30,8 @@ stages:
30
  md5: 3eec94ac211c76363a3d968663b82d02
31
  size: 39574
32
  - path: model_params.yml
33
- md5: 9fcf006ee30f2b751078598a3fba9bb5
34
- size: 235
35
  - path: models
36
  md5: fc37870a93db61b94af9f0847577f09b.dir
37
  size: 243476333
@@ -41,7 +41,7 @@ stages:
41
  size: 705
42
  outs:
43
  - path: reports/evaluation_metrics.csv
44
- md5: a5fa12e6df10884217614c007d146a26
45
  size: 2122
46
  process_data:
47
  cmd: python src/data/process_data.py
@@ -88,9 +88,18 @@ stages:
88
  size: 243476333
89
  nfiles: 5
90
  - path: src/visualization/visualize.py
91
- md5: a71303fef593a9fd275fc4964623baf8
92
- size: 814
93
- outs:
94
- - path: reports/visualization_metrics.txt
95
- md5: fd7b6bb170dbaa9ef1076bc8be7e7593
96
- size: 2144
 
 
 
 
 
 
 
 
 
10
  md5: 6069153a075b00dfb6d9e0843dd2da89
11
  size: 52739
12
  - path: model_params.yml
13
+ md5: 1bf2edf25e851cc9cd3be75fbd9905a3
14
+ size: 177
15
  - path: src/models/train_model.py
16
  md5: f7d1121426c3d5530c2b9697cb7ac74a
17
  size: 951
21
  size: 243476333
22
  nfiles: 5
23
  - path: reports/training_metrics.csv
24
+ md5: 3b309def91a32e521acd23b163742522
25
  size: 320
26
  eval:
27
  cmd: python src/models/evaluate_model.py
30
  md5: 3eec94ac211c76363a3d968663b82d02
31
  size: 39574
32
  - path: model_params.yml
33
+ md5: 1bf2edf25e851cc9cd3be75fbd9905a3
34
+ size: 177
35
  - path: models
36
  md5: fc37870a93db61b94af9f0847577f09b.dir
37
  size: 243476333
41
  size: 705
42
  outs:
43
  - path: reports/evaluation_metrics.csv
44
+ md5: eaa3bf017026aa1be31560f308fff78e
45
  size: 2122
46
  process_data:
47
  cmd: python src/data/process_data.py
88
  size: 243476333
89
  nfiles: 5
90
  - path: src/visualization/visualize.py
91
+ md5: 4226e4148abb5ac186c0ab8c1d87b228
92
+ size: 671
93
+ push_to_hf_hub:
94
+ cmd: python src/models/hf_upload.py
95
+ deps:
96
+ - path: model_params.yml
97
+ md5: 1bf2edf25e851cc9cd3be75fbd9905a3
98
+ size: 177
99
+ - path: models
100
+ md5: fc37870a93db61b94af9f0847577f09b.dir
101
+ size: 243476333
102
+ nfiles: 5
103
+ - path: src/models/hf_upload.py
104
+ md5: a953816a3eb7bef702313544103a1c11
105
+ size: 1290
model_params.yml CHANGED
@@ -9,6 +9,3 @@ num_workers: 2
9
  model_dir: models
10
  metric: rouge
11
  source_dir: src
12
- visualise: True
13
- hf_username: gagan3012
14
- upload_to_hf: False
9
  model_dir: models
10
  metric: rouge
11
  source_dir: src
 
 
 
reports/evaluation_metrics.csv CHANGED
@@ -1,37 +1,37 @@
1
  Name,Value,Timestamp,Step
2
- "Rouge_1 Low Precision",0.23786550570641482,1628194352980,1
3
- "Rouge_1 Low recall",0.23355396379384713,1628194352980,1
4
- "Rouge_1 Low F1",0.23602599457077003,1628194352980,1
5
- "Rouge_1 Mid Precision",0.3569471852499436,1628194352980,1
6
- "Rouge_1 Mid recall",0.31915939075819916,1628194352980,1
7
- "Rouge_1 Mid F1",0.3317618573023773,1628194352980,1
8
- "Rouge_1 High Precision",0.4726861301480842,1628194352980,1
9
- "Rouge_1 High recall",0.4019654200001146,1628194352980,1
10
- "Rouge_1 High F1",0.4298956952594035,1628194352980,1
11
- "Rouge_2 Low Precision",0.06184772400193972,1628194352980,1
12
- "Rouge_2 Low recall",0.05626972412346313,1628194352980,1
13
- "Rouge_2 Low F1",0.058680298802341754,1628194352980,1
14
- "Rouge_2 Mid Precision",0.1367034298993256,1628194352980,1
15
- "Rouge_2 Mid recall",0.11953160646342464,1628194352980,1
16
- "Rouge_2 Mid F1",0.12485064123505887,1628194352980,1
17
- "Rouge_2 High Precision",0.22739029631016827,1628194352980,1
18
- "Rouge_2 High recall",0.18851628169809986,1628194352980,1
19
- "Rouge_2 High F1",0.20306657551189072,1628194352980,1
20
- "Rouge_L Low Precision",0.18248956154159507,1628194352980,1
21
- "Rouge_L Low recall",0.18048774357814204,1628194352980,1
22
- "Rouge_L Low F1",0.18151380309623336,1628194352980,1
23
- "Rouge_L Mid Precision",0.2614974838710314,1628194352980,1
24
- "Rouge_L Mid recall",0.24286688705755238,1628194352980,1
25
- "Rouge_L Mid F1",0.24674586991996245,1628194352980,1
26
- "Rouge_L High Precision",0.3574471638807763,1628194352980,1
27
- "Rouge_L High recall",0.30836083808542225,1628194352980,1
28
- "Rouge_L High F1",0.32385446385474176,1628194352980,1
29
- "rougeLsum Low Precision",0.21468633089019287,1628194352980,1
30
- "rougeLsum Low recall",0.2057771050364415,1628194352980,1
31
- "rougeLsum Low F1",0.21170611912426093,1628194352980,1
32
- "rougeLsum Mid Precision",0.3060593850789648,1628194352980,1
33
- "rougeLsum Mid recall",0.27733553744690076,1628194352980,1
34
- "rougeLsum Mid F1",0.28530501988436374,1628194352980,1
35
- "rougeLsum High Precision",0.4094614601758424,1628194352980,1
36
- "rougeLsum High recall",0.34640369291505535,1628194352980,1
37
- "rougeLsum High F1",0.36454440079714096,1628194352980,1
1
  Name,Value,Timestamp,Step
2
+ "Rouge_1 Low Precision",0.23786550570641482,1628587253223,1
3
+ "Rouge_1 Low recall",0.23355396379384713,1628587253223,1
4
+ "Rouge_1 Low F1",0.23602599457077003,1628587253223,1
5
+ "Rouge_1 Mid Precision",0.3569471852499436,1628587253223,1
6
+ "Rouge_1 Mid recall",0.31915939075819916,1628587253223,1
7
+ "Rouge_1 Mid F1",0.3317618573023773,1628587253223,1
8
+ "Rouge_1 High Precision",0.4726861301480842,1628587253223,1
9
+ "Rouge_1 High recall",0.4019654200001146,1628587253223,1
10
+ "Rouge_1 High F1",0.4298956952594035,1628587253223,1
11
+ "Rouge_2 Low Precision",0.06184772400193972,1628587253223,1
12
+ "Rouge_2 Low recall",0.05626972412346313,1628587253223,1
13
+ "Rouge_2 Low F1",0.058680298802341754,1628587253223,1
14
+ "Rouge_2 Mid Precision",0.1367034298993256,1628587253223,1
15
+ "Rouge_2 Mid recall",0.11953160646342464,1628587253223,1
16
+ "Rouge_2 Mid F1",0.12485064123505887,1628587253223,1
17
+ "Rouge_2 High Precision",0.22739029631016827,1628587253223,1
18
+ "Rouge_2 High recall",0.18851628169809986,1628587253223,1
19
+ "Rouge_2 High F1",0.20306657551189072,1628587253223,1
20
+ "Rouge_L Low Precision",0.18248956154159507,1628587253223,1
21
+ "Rouge_L Low recall",0.18048774357814204,1628587253223,1
22
+ "Rouge_L Low F1",0.18151380309623336,1628587253223,1
23
+ "Rouge_L Mid Precision",0.2614974838710314,1628587253223,1
24
+ "Rouge_L Mid recall",0.24286688705755238,1628587253223,1
25
+ "Rouge_L Mid F1",0.24674586991996245,1628587253223,1
26
+ "Rouge_L High Precision",0.3574471638807763,1628587253223,1
27
+ "Rouge_L High recall",0.30836083808542225,1628587253223,1
28
+ "Rouge_L High F1",0.32385446385474176,1628587253223,1
29
+ "rougeLsum Low Precision",0.21468633089019287,1628587253223,1
30
+ "rougeLsum Low recall",0.2057771050364415,1628587253223,1
31
+ "rougeLsum Low F1",0.21170611912426093,1628587253223,1
32
+ "rougeLsum Mid Precision",0.3060593850789648,1628587253223,1
33
+ "rougeLsum Mid recall",0.27733553744690076,1628587253223,1
34
+ "rougeLsum Mid F1",0.28530501988436374,1628587253223,1
35
+ "rougeLsum High Precision",0.4094614601758424,1628587253223,1
36
+ "rougeLsum High recall",0.34640369291505535,1628587253223,1
37
+ "rougeLsum High F1",0.36454440079714096,1628587253223,1
reports/training_metrics.csv CHANGED
@@ -1,9 +1,9 @@
1
  Name,Value,Timestamp,Step
2
- "val_loss",2.615034580230713,1628194199660,0
3
- "epoch",0,1628194199660,0
4
- "val_loss",2.6141018867492676,1628194229556,1
5
- "epoch",1,1628194229556,1
6
- "val_loss",2.6132164001464844,1628194259447,2
7
- "epoch",2,1628194259447,2
8
- "val_loss",2.612450361251831,1628194289914,3
9
- "epoch",3,1628194289914,3
1
  Name,Value,Timestamp,Step
2
+ "val_loss",2.615034580230713,1628591864766,0
3
+ "epoch",0,1628591864766,0
4
+ "val_loss",2.6141018867492676,1628591893945,1
5
+ "epoch",1,1628591893945,1
6
+ "val_loss",2.6132164001464844,1628591923101,2
7
+ "epoch",2,1628591923101,2
8
+ "val_loss",2.612450361251831,1628591951319,3
9
+ "epoch",3,1628591951319,3
src/__init__.py ADDED
File without changes
src/models/__init__.py ADDED
File without changes
src/models/hf_upload.py CHANGED
@@ -7,35 +7,34 @@ from model import Summarization
7
  from huggingface_hub import HfApi, Repository
8
 
9
 
10
- def upload(upload_model, model_name):
11
  hf_username = input("Enter your HuggingFace username:")
12
- hf_password = getpass("Enter your HuggingFace password:")
13
- if Path("./models").exists():
14
- shutil.rmtree("./models")
15
- token = HfApi().login(username=hf_username, password=hf_password)
16
- del hf_password
17
- model_url = HfApi().create_repo(token=token, name=model_name, exist_ok=True)
18
  model_repo = Repository(
19
- "./model",
20
  clone_from=model_url,
21
- use_auth_token=token,
22
  git_email=f"{hf_username}@users.noreply.huggingface.co",
23
  git_user=hf_username,
24
  )
25
 
 
26
  readme_txt = f"""
27
  ---
28
  Summarisation model {model_name}
29
  """.strip()
30
 
31
  (Path(model_repo.local_dir) / "README.md").write_text(readme_txt)
32
- upload_model.save_model()
33
  commit_url = model_repo.push_to_hub()
34
 
35
  print("Check out your model at:")
36
  print(commit_url)
37
  print(f"https://huggingface.co/{hf_username}/{model_name}")
38
 
 
 
 
39
 
40
  if __name__ == "__main__":
41
  with open("model_params.yml") as f:
@@ -44,4 +43,4 @@ if __name__ == "__main__":
44
  model = Summarization()
45
  model.load_model(model_dir="./models")
46
 
47
- upload(upload_model=model, model_name=params["name"])
7
  from huggingface_hub import HfApi, Repository
8
 
9
 
10
+ def upload(model_to_upload, model_name):
11
  hf_username = input("Enter your HuggingFace username:")
12
+ hf_token = getpass("Enter your HuggingFace token:")
13
+ model_url = HfApi().create_repo(token=hf_token, name=model_name, exist_ok=True)
 
 
 
 
14
  model_repo = Repository(
15
+ "./hf_model",
16
  clone_from=model_url,
17
+ use_auth_token=hf_token,
18
  git_email=f"{hf_username}@users.noreply.huggingface.co",
19
  git_user=hf_username,
20
  )
21
 
22
+ del hf_token
23
  readme_txt = f"""
24
  ---
25
  Summarisation model {model_name}
26
  """.strip()
27
 
28
  (Path(model_repo.local_dir) / "README.md").write_text(readme_txt)
 
29
  commit_url = model_repo.push_to_hub()
30
 
31
  print("Check out your model at:")
32
  print(commit_url)
33
  print(f"https://huggingface.co/{hf_username}/{model_name}")
34
 
35
+ if Path("./hf_model").exists():
36
+ shutil.rmtree("./hf_model")
37
+
38
 
39
  if __name__ == "__main__":
40
  with open("model_params.yml") as f:
43
  model = Summarization()
44
  model.load_model(model_dir="./models")
45
 
46
+ upload(model_to_upload=model, model_name=params["name"])