Felladrin PierreMesure commited on
Commit
afb14c6
·
verified ·
1 Parent(s): df30c7c

add-readme (#15)

Browse files

- Add README (eb74c3687027cecfca4b172726af9ad77f4cd89d)


Co-authored-by: Pierre Mesure <[email protected]>

Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -124,6 +124,12 @@ class ModelConverter:
124
  self.api.create_repo(output_model_id, exist_ok=True, private=False)
125
  model_folder_path = self.config.repo_path / "models" / input_model_id
126
 
 
 
 
 
 
 
127
  self.api.upload_folder(
128
  folder_path=str(model_folder_path), repo_id=output_model_id
129
  )
@@ -135,6 +141,19 @@ class ModelConverter:
135
 
136
  shutil.rmtree(model_folder_path, ignore_errors=True)
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  def main():
140
  """Main application entry point."""
 
124
  self.api.create_repo(output_model_id, exist_ok=True, private=False)
125
  model_folder_path = self.config.repo_path / "models" / input_model_id
126
 
127
+ readme_path = f"{model_folder_path}/README.md"
128
+
129
+ if not os.path.exists(readme_path):
130
+ with open(readme_path, "w") as file:
131
+ file.write(self.generate_readme(input_model_id))
132
+
133
  self.api.upload_folder(
134
  folder_path=str(model_folder_path), repo_id=output_model_id
135
  )
 
141
 
142
  shutil.rmtree(model_folder_path, ignore_errors=True)
143
 
144
+ def generate_readme(self, imi: str):
145
+ return (
146
+ "---\n"
147
+ "library_name: transformers.js\n"
148
+ "base_model:\n"
149
+ f"- {imi}\n"
150
+ "---\n\n"
151
+ f"# {imi.split('/')[-1]} (ONNX)\n\n"
152
+ f"This is an ONNX version of [{imi}](https://huggingface.co/{imi}). "
153
+ "It was automatically converted and uploaded using "
154
+ "[this space](https://huggingface.co/spaces/onnx-community/convert-to-onnx).\n"
155
+ )
156
+
157
 
158
  def main():
159
  """Main application entry point."""