up
Browse files- app.py +10 -4
- convert_diffusion_to_gguf.py +3 -5
app.py
CHANGED
@@ -5,18 +5,18 @@ from argparse import Namespace
|
|
5 |
from pathlib import Path
|
6 |
|
7 |
|
8 |
-
def upload(args
|
9 |
url = ""
|
10 |
if args.host_repo_id and args.hf_token:
|
11 |
repo_id = create_repo(args.host_repo_id, repo_type="model", exist_ok=True, token=args.hf_token).repo_id
|
12 |
-
info = upload_file(repo_id=repo_id, path_in_repo=str(outfile), path_or_fileobj=str(outfile), token=args.token)
|
13 |
url = info.commit_url
|
14 |
print(f"Uploaded to {url}")
|
15 |
|
16 |
return url
|
17 |
|
18 |
|
19 |
-
def go_gguf(model_repo_id, subfolder, arch, outtype, outfile_name, bigendian, verbose, host_repo_id, hf_token):
|
20 |
args = Namespace(
|
21 |
model=Path(model_repo_id),
|
22 |
subfolder=subfolder,
|
@@ -30,8 +30,14 @@ def go_gguf(model_repo_id, subfolder, arch, outtype, outfile_name, bigendian, ve
|
|
30 |
cache_dir=None,
|
31 |
)
|
32 |
try:
|
|
|
33 |
convert(args)
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
35 |
except Exception as e:
|
36 |
return str(e)
|
37 |
|
|
|
5 |
from pathlib import Path
|
6 |
|
7 |
|
8 |
+
def upload(args):
|
9 |
url = ""
|
10 |
if args.host_repo_id and args.hf_token:
|
11 |
repo_id = create_repo(args.host_repo_id, repo_type="model", exist_ok=True, token=args.hf_token).repo_id
|
12 |
+
info = upload_file(repo_id=repo_id, path_in_repo=str(args.outfile), path_or_fileobj=str(args.outfile), token=args.token)
|
13 |
url = info.commit_url
|
14 |
print(f"Uploaded to {url}")
|
15 |
|
16 |
return url
|
17 |
|
18 |
|
19 |
+
def go_gguf(model_repo_id, subfolder, arch, outtype, outfile_name, bigendian, verbose, host_repo_id, hf_token, progress=gr.Progress(track_tqdm=True)):
|
20 |
args = Namespace(
|
21 |
model=Path(model_repo_id),
|
22 |
subfolder=subfolder,
|
|
|
30 |
cache_dir=None,
|
31 |
)
|
32 |
try:
|
33 |
+
progress(0.1, desc="Starting conversion... (This may take a while depending on model size)")
|
34 |
convert(args)
|
35 |
+
progress(0.8, desc="✅ Conversion Complete. Starting upload...")
|
36 |
+
url = upload(args)
|
37 |
+
if url:
|
38 |
+
return f"### ✅ Success!\n\nUploaded to: [{url}]({url})"
|
39 |
+
else:
|
40 |
+
return "### ✅ Conversion Complete!\n\n(File was not uploaded as no repo/token was provided)"
|
41 |
except Exception as e:
|
42 |
return str(e)
|
43 |
|
convert_diffusion_to_gguf.py
CHANGED
@@ -321,10 +321,6 @@ def convert(args):
|
|
321 |
args.model = Path(filepath)
|
322 |
is_diffusers = True
|
323 |
|
324 |
-
if merged_state_dict is not None:
|
325 |
-
os.remove(filepath)
|
326 |
-
logging.info(f"Removed the intermediate {filepath}.")
|
327 |
-
|
328 |
if args.model.suffix != ".safetensors":
|
329 |
logging.error(f"Model path {args.model} is not a safetensors file.")
|
330 |
sys.exit(1)
|
@@ -351,7 +347,9 @@ def convert(args):
|
|
351 |
logger.info(
|
352 |
f"Conversion complete. Output written to {outfile}, architecture: {args.arch}, quantization: {qconfig.qtype.name}"
|
353 |
)
|
354 |
-
|
|
|
|
|
355 |
|
356 |
def main() -> None:
|
357 |
args = parse_args()
|
|
|
321 |
args.model = Path(filepath)
|
322 |
is_diffusers = True
|
323 |
|
|
|
|
|
|
|
|
|
324 |
if args.model.suffix != ".safetensors":
|
325 |
logging.error(f"Model path {args.model} is not a safetensors file.")
|
326 |
sys.exit(1)
|
|
|
347 |
logger.info(
|
348 |
f"Conversion complete. Output written to {outfile}, architecture: {args.arch}, quantization: {qconfig.qtype.name}"
|
349 |
)
|
350 |
+
if merged_state_dict is not None:
|
351 |
+
os.remove(filepath)
|
352 |
+
logging.info(f"Removed the intermediate {filepath}.")
|
353 |
|
354 |
def main() -> None:
|
355 |
args = parse_args()
|