sayakpaul HF staff commited on
Commit
a1008bd
1 Parent(s): e548249

fix: formatting.

Browse files
Files changed (3) hide show
  1. app.py +7 -1
  2. hub_utils/readme.py +4 -3
  3. hub_utils/repo.py +1 -3
app.py CHANGED
@@ -30,10 +30,16 @@ def run(hf_token, text_encoder_weights, unet_weights, repo_prefix):
30
  pipeline = run_conversion(text_encoder_weights, unet_weights)
31
  output_path = "kerascv_sd_diffusers_pipeline"
32
  pipeline.save_pretrained(output_path)
 
 
 
 
 
 
33
  save_model_card(
34
  base_model=PRETRAINED_CKPT,
35
  repo_folder=output_path,
36
- weight_paths=[text_encoder_weights, unet_weights],
37
  )
38
  push_str = push_to_hub(hf_token, output_path, repo_prefix)
39
  return push_str
 
30
  pipeline = run_conversion(text_encoder_weights, unet_weights)
31
  output_path = "kerascv_sd_diffusers_pipeline"
32
  pipeline.save_pretrained(output_path)
33
+
34
+ weight_paths = []
35
+ if text_encoder_weights is not None:
36
+ weight_paths.append(text_encoder_weights)
37
+ if unet_weights is not None:
38
+ weight_paths.append(unet_weights)
39
  save_model_card(
40
  base_model=PRETRAINED_CKPT,
41
  repo_folder=output_path,
42
+ weight_paths=weight_paths,
43
  )
44
  push_str = push_to_hub(hf_token, output_path, repo_prefix)
45
  return push_str
hub_utils/readme.py CHANGED
@@ -1,8 +1,9 @@
1
  import os
 
2
 
3
 
4
  # Copied from https://github.com/huggingface/diffusers/blob/31be42209ddfdb69d9640a777b32e9b5c6259bf0/examples/text_to_image/train_text_to_image_lora.py#L55
5
- def save_model_card(base_model=str, repo_folder=None, weight_paths=None):
6
  yaml = f"""
7
  ---
8
  license: creativeml-openrail-m
@@ -22,8 +23,8 @@ The pipeline contained in this repository was created using [this Space](https:/
22
 
23
  """
24
 
25
- if weight_paths is not None:
26
- model_card += "Following weight paths (KerasCV) were used: {weight_paths}"
27
 
28
  with open(os.path.join(repo_folder, "README.md"), "w") as f:
29
  f.write(yaml + model_card)
 
1
  import os
2
+ from typing import List
3
 
4
 
5
  # Copied from https://github.com/huggingface/diffusers/blob/31be42209ddfdb69d9640a777b32e9b5c6259bf0/examples/text_to_image/train_text_to_image_lora.py#L55
6
+ def save_model_card(base_model=str, repo_folder=None, weight_paths: List = None):
7
  yaml = f"""
8
  ---
9
  license: creativeml-openrail-m
 
23
 
24
  """
25
 
26
+ if len(weight_paths) > 0:
27
+ model_card += f"Following weight paths (KerasCV) were used \n: {weight_paths}"
28
 
29
  with open(os.path.join(repo_folder, "README.md"), "w") as f:
30
  f.write(yaml + model_card)
hub_utils/repo.py CHANGED
@@ -14,9 +14,7 @@ def push_to_hub(hf_token: str, push_dir: str, repo_prefix: None) -> str:
14
  else f"{user}/{repo_prefix}-{push_dir}"
15
  )
16
  _ = create_repo(repo_id=repo_id, token=hf_token, exist_ok=True)
17
- url = hf_api.upload_folder(
18
- folder_path=push_dir, repo_id=repo_id
19
- )
20
  return f"Model successfully pushed: [{url}]({url})"
21
  except Exception as e:
22
  return f"{e}"
 
14
  else f"{user}/{repo_prefix}-{push_dir}"
15
  )
16
  _ = create_repo(repo_id=repo_id, token=hf_token, exist_ok=True)
17
+ url = hf_api.upload_folder(folder_path=push_dir, repo_id=repo_id)
 
 
18
  return f"Model successfully pushed: [{url}]({url})"
19
  except Exception as e:
20
  return f"{e}"