sayakpaul HF Staff commited on
Commit
0296fb6
Β·
1 Parent(s): 8d702cb
Files changed (2) hide show
  1. app.py +23 -4
  2. convert_diffusion_to_gguf.py +2 -5
app.py CHANGED
@@ -7,18 +7,32 @@ from pathlib import Path
7
 
8
  log_stream = StringIO()
9
 
 
10
  def upload(args):
11
  url = ""
12
  if args.host_repo_id and args.hf_token:
13
  repo_id = create_repo(args.host_repo_id, repo_type="model", exist_ok=True, token=args.hf_token).repo_id
14
- info = upload_file(repo_id=repo_id, path_in_repo=str(args.outfile), path_or_fileobj=str(args.outfile), token=args.token)
 
 
15
  url = info.commit_url
16
  print(f"Uploaded to {url}")
17
 
18
  return url
19
 
20
 
21
- def go_gguf(model_repo_id, subfolder, arch, outtype, outfile_name, bigendian, verbose, host_repo_id, hf_token, progress=gr.Progress(track_tqdm=True)):
 
 
 
 
 
 
 
 
 
 
 
22
  log_stream.truncate(0)
23
  log_stream.seek(0)
24
  args = Namespace(
@@ -41,7 +55,10 @@ def go_gguf(model_repo_id, subfolder, arch, outtype, outfile_name, bigendian, ve
41
  if url:
42
  return log_stream.getvalue(), f"### βœ… Success!\n\nUploaded to: [{url}]({url})"
43
  else:
44
- return log_stream.getvalue(), "### βœ… Conversion Complete!\n\n(File was not uploaded as no repo/token was provided)"
 
 
 
45
  except Exception as e:
46
  return log_stream.getvalue(), str(e)
47
 
@@ -75,7 +92,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
75
 
76
  with gr.Column(scale=2):
77
  gr.Markdown("### πŸ“ Logs")
78
- logs_output = gr.Textbox(label="Conversion Logs", lines=25, max_lines=25, interactive=False, autoscroll=True)
 
 
79
  gr.Markdown("### πŸš€ Result")
80
  url_output = gr.Markdown()
81
 
 
7
 
8
  log_stream = StringIO()
9
 
10
+
11
  def upload(args):
12
  url = ""
13
  if args.host_repo_id and args.hf_token:
14
  repo_id = create_repo(args.host_repo_id, repo_type="model", exist_ok=True, token=args.hf_token).repo_id
15
+ info = upload_file(
16
+ repo_id=repo_id, path_in_repo=str(args.outfile), path_or_fileobj=str(args.outfile), token=args.hf_token
17
+ )
18
  url = info.commit_url
19
  print(f"Uploaded to {url}")
20
 
21
  return url
22
 
23
 
24
+ def go_gguf(
25
+ model_repo_id,
26
+ subfolder,
27
+ arch,
28
+ outtype,
29
+ outfile_name,
30
+ bigendian,
31
+ verbose,
32
+ host_repo_id,
33
+ hf_token,
34
+ progress=gr.Progress(track_tqdm=True),
35
+ ):
36
  log_stream.truncate(0)
37
  log_stream.seek(0)
38
  args = Namespace(
 
55
  if url:
56
  return log_stream.getvalue(), f"### βœ… Success!\n\nUploaded to: [{url}]({url})"
57
  else:
58
+ return (
59
+ log_stream.getvalue(),
60
+ "### βœ… Conversion Complete!\n\n(File was not uploaded as no repo/token was provided)",
61
+ )
62
  except Exception as e:
63
  return log_stream.getvalue(), str(e)
64
 
 
92
 
93
  with gr.Column(scale=2):
94
  gr.Markdown("### πŸ“ Logs")
95
+ logs_output = gr.Textbox(
96
+ label="Conversion Logs", lines=25, max_lines=25, interactive=False, autoscroll=True
97
+ )
98
  gr.Markdown("### πŸš€ Result")
99
  url_output = gr.Markdown()
100
 
convert_diffusion_to_gguf.py CHANGED
@@ -309,10 +309,7 @@ def convert(args):
309
  logging.info("Hub repo ID detected.")
310
  allow_patterns = f"{args.subfolder}/*.*" if args.subfolder else None
311
  local_dir = snapshot_download(
312
- repo_id=str(args.model),
313
- local_dir=args.cache_dir,
314
- allow_patterns=allow_patterns,
315
- token=args.hf_token
316
  )
317
  repo_id = str(args.model)
318
  local_dir = Path(local_dir)
@@ -354,4 +351,4 @@ def convert(args):
354
  )
355
  if merged_state_dict is not None:
356
  os.remove(filepath)
357
- logging.info(f"Removed the intermediate {filepath}.")
 
309
  logging.info("Hub repo ID detected.")
310
  allow_patterns = f"{args.subfolder}/*.*" if args.subfolder else None
311
  local_dir = snapshot_download(
312
+ repo_id=str(args.model), local_dir=args.cache_dir, allow_patterns=allow_patterns, token=args.hf_token
 
 
 
313
  )
314
  repo_id = str(args.model)
315
  local_dir = Path(local_dir)
 
351
  )
352
  if merged_state_dict is not None:
353
  os.remove(filepath)
354
+ logging.info(f"Removed the intermediate {filepath}.")