ngxson HF staff commited on
Commit
f11fc50
1 Parent(s): 720f534

add check for peft adapter

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -117,6 +117,11 @@ def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_rep
117
  print(f"Current working directory: {os.getcwd()}")
118
  print(f"Model directory contents: {os.listdir(local_dir)}")
119
 
 
 
 
 
 
120
  conversion_script = "convert_hf_to_gguf.py"
121
  fp16_conversion = f"python llama.cpp/{conversion_script} {local_dir} --outtype f16 --outfile {fp16}"
122
  result = subprocess.run(fp16_conversion, shell=True, capture_output=True)
@@ -252,11 +257,11 @@ def process_model(model_id, q_method, use_imatrix, imatrix_q_method, private_rep
252
  print(f"Uploaded successfully with {imatrix_q_method if use_imatrix else q_method} option!")
253
 
254
  return (
255
- f'Find your repo <a href=\'{new_repo_url}\' target="_blank" style="text-decoration:underline">here</a>',
256
  "llama.png",
257
  )
258
  except Exception as e:
259
- return (f"Error: {e}", "error.png")
260
 
261
 
262
  css="""/* Custom CSS to allow scrolling */
 
117
  print(f"Current working directory: {os.getcwd()}")
118
  print(f"Model directory contents: {os.listdir(local_dir)}")
119
 
120
+ config_dir = local_dir/"config.json"
121
+ adapter_config_dir = local_dir/"adapter_config.json"
122
+ if os.path.exists(adapter_config_dir) and not os.path.exists(config_dir):
123
+ raise Exception("adapter_config.json is present.<br/><br/>If you are converting a LoRA adapter to GGUF, please use <a href=\"https://huggingface.co/spaces/ggml-org/gguf-my-lora\" target=\"_blank\">GGUF-my-lora</a>.")
124
+
125
  conversion_script = "convert_hf_to_gguf.py"
126
  fp16_conversion = f"python llama.cpp/{conversion_script} {local_dir} --outtype f16 --outfile {fp16}"
127
  result = subprocess.run(fp16_conversion, shell=True, capture_output=True)
 
257
  print(f"Uploaded successfully with {imatrix_q_method if use_imatrix else q_method} option!")
258
 
259
  return (
260
+ f'<h1>✅ DONE</h1><br/><br/>Find your repo here: <a href="{new_repo_url}" target="_blank" style="text-decoration:underline">{new_repo_id}</a>',
261
  "llama.png",
262
  )
263
  except Exception as e:
264
+ return (f"<h1>❌ ERROR</h1><br/><br/>{e}", "error.png")
265
 
266
 
267
  css="""/* Custom CSS to allow scrolling */