Spaces:
Running
Running
Oleg Shulyakov
commited on
Commit
·
6475b9d
1
Parent(s):
fa221c9
Update _upload_file
Browse files
app.py
CHANGED
|
@@ -121,17 +121,17 @@ class HuggingFaceModelProcessor:
|
|
| 121 |
"""Extract model name from model ID."""
|
| 122 |
return model_id.split('/')[-1]
|
| 123 |
|
| 124 |
-
def _upload_file(self,
|
| 125 |
"""Upload a file to Hugging Face repository."""
|
| 126 |
if self.RUN_LOCALLY == "1":
|
| 127 |
print("Skipping upload...")
|
| 128 |
return
|
| 129 |
|
| 130 |
-
api = HfApi(token=token)
|
| 131 |
api.upload_file(
|
| 132 |
path_or_fileobj=path_or_fileobj,
|
| 133 |
path_in_repo=path_in_repo,
|
| 134 |
-
repo_id=
|
| 135 |
)
|
| 136 |
|
| 137 |
def _generate_importance_matrix(self, model_path: str, train_data_path: str, output_path: str) -> None:
|
|
@@ -409,7 +409,7 @@ llama-server --hf-repo "{new_repo_id}" --hf-file "{gguf_name}" -c 4096
|
|
| 409 |
else:
|
| 410 |
try:
|
| 411 |
print(f"Uploading quantized model: {os.path.abspath(quant_config.quantized_gguf)}")
|
| 412 |
-
self._upload_file(processing_config
|
| 413 |
except Exception as e:
|
| 414 |
raise GGUFConverterError(f"Error uploading quantized model: {e}")
|
| 415 |
|
|
@@ -417,13 +417,13 @@ llama-server --hf-repo "{new_repo_id}" --hf-file "{gguf_name}" -c 4096
|
|
| 417 |
if quant_config.use_imatrix and os.path.isfile(quant_config.imatrix_file):
|
| 418 |
try:
|
| 419 |
print(f"Uploading imatrix.dat: {os.path.abspath(quant_config.imatrix_file)}")
|
| 420 |
-
self._upload_file(processing_config
|
| 421 |
except Exception as e:
|
| 422 |
raise GGUFConverterError(f"Error uploading imatrix.dat: {e}")
|
| 423 |
|
| 424 |
# Upload README.md
|
| 425 |
readme_path = self._generate_readme(processing_config.outdir, processing_config.token, processing_config.model_id, processing_config.new_repo_id, output_config.filename)
|
| 426 |
-
self._upload_file(processing_config
|
| 427 |
|
| 428 |
print(f"Uploaded successfully with {quant_config.imatrix_method if quant_config.use_imatrix else quant_config.method} option!")
|
| 429 |
|
|
|
|
| 121 |
"""Extract model name from model ID."""
|
| 122 |
return model_id.split('/')[-1]
|
| 123 |
|
| 124 |
+
def _upload_file(self, processing_config: ModelProcessingConfig, path_or_fileobj: str, path_in_repo: str) -> None:
|
| 125 |
"""Upload a file to Hugging Face repository."""
|
| 126 |
if self.RUN_LOCALLY == "1":
|
| 127 |
print("Skipping upload...")
|
| 128 |
return
|
| 129 |
|
| 130 |
+
api = HfApi(token=processing_config.token)
|
| 131 |
api.upload_file(
|
| 132 |
path_or_fileobj=path_or_fileobj,
|
| 133 |
path_in_repo=path_in_repo,
|
| 134 |
+
repo_id=processing_config.new_repo_id,
|
| 135 |
)
|
| 136 |
|
| 137 |
def _generate_importance_matrix(self, model_path: str, train_data_path: str, output_path: str) -> None:
|
|
|
|
| 409 |
else:
|
| 410 |
try:
|
| 411 |
print(f"Uploading quantized model: {os.path.abspath(quant_config.quantized_gguf)}")
|
| 412 |
+
self._upload_file(processing_config, quant_config.quantized_gguf, output_config.filename)
|
| 413 |
except Exception as e:
|
| 414 |
raise GGUFConverterError(f"Error uploading quantized model: {e}")
|
| 415 |
|
|
|
|
| 417 |
if quant_config.use_imatrix and os.path.isfile(quant_config.imatrix_file):
|
| 418 |
try:
|
| 419 |
print(f"Uploading imatrix.dat: {os.path.abspath(quant_config.imatrix_file)}")
|
| 420 |
+
self._upload_file(processing_config, quant_config.imatrix_file, f"{processing_config.model_name}-imatrix.dat")
|
| 421 |
except Exception as e:
|
| 422 |
raise GGUFConverterError(f"Error uploading imatrix.dat: {e}")
|
| 423 |
|
| 424 |
# Upload README.md
|
| 425 |
readme_path = self._generate_readme(processing_config.outdir, processing_config.token, processing_config.model_id, processing_config.new_repo_id, output_config.filename)
|
| 426 |
+
self._upload_file(processing_config, readme_path, "README.md")
|
| 427 |
|
| 428 |
print(f"Uploaded successfully with {quant_config.imatrix_method if quant_config.use_imatrix else quant_config.method} option!")
|
| 429 |
|