GuillaumeSalouHF HF Staff commited on
Commit
0b3bb53
·
verified ·
1 Parent(s): eac4d6e

fix: update converter for current Gradio and Hub APIs

Browse files

Upgrade the Space to Gradio 6.27.0 on Python 3.13 and migrate the Interface, queue and launch arguments. Preserve conversion concurrency 1 and queue size 10. Use CommitInfo.pr_url for the conversion result.

Validated with Python 3.13.13, a real local Gradio server, synthetic checkpoint loading and stubbed Hub uploads.

Files changed (3) hide show
  1. README.md +2 -1
  2. app.py +4 -3
  3. convert.py +2 -3
README.md CHANGED
@@ -4,7 +4,8 @@ emoji: 🎨➡️🧨
4
  colorFrom: indigo
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 3.31.0
 
8
  app_file: app.py
9
  pinned: true
10
  license: mit
 
4
  colorFrom: indigo
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 6.27.0
8
+ python_version: "3.13"
9
  app_file: app.py
10
  pinned: true
11
  license: mit
app.py CHANGED
@@ -17,7 +17,7 @@ The steps are the following:
17
  demo = gr.Interface(
18
  title="Convert any Stable Diffusion XL checkpoint to Diffusers and open a PR",
19
  description=DESCRIPTION,
20
- allow_flagging="never",
21
  article="Check out the [Diffusers repo on GitHub](https://github.com/huggingface/diffusers)",
22
  inputs=[
23
  gr.Text(max_lines=1, label="your_hf_token"),
@@ -26,6 +26,7 @@ demo = gr.Interface(
26
  ],
27
  outputs=[gr.Markdown(label="output")],
28
  fn=convert,
29
- ).queue(max_size=10, concurrency_count=1)
 
30
 
31
- demo.launch(show_api=True)
 
17
  demo = gr.Interface(
18
  title="Convert any Stable Diffusion XL checkpoint to Diffusers and open a PR",
19
  description=DESCRIPTION,
20
+ flagging_mode="never",
21
  article="Check out the [Diffusers repo on GitHub](https://github.com/huggingface/diffusers)",
22
  inputs=[
23
  gr.Text(max_lines=1, label="your_hf_token"),
 
26
  ],
27
  outputs=[gr.Markdown(label="output")],
28
  fn=convert,
29
+ concurrency_limit=1,
30
+ ).queue(max_size=10)
31
 
32
+ demo.launch()
convert.py CHANGED
@@ -58,12 +58,11 @@ def convert(token: str, model_id: str, filename: str, progress=gr.Progress()):
58
  folder = convert_single(model_id, filename, folder, progress, token)
59
  progress(0.7, desc="Uploading to Hub")
60
  new_pr = api.upload_folder(folder_path=folder, path_in_repo="./", repo_id=model_id, repo_type="model", token=token, commit_message=pr_title, commit_description=COMMIT_MESSAGE.format(model_id), create_pr=True)
61
- pr_number = new_pr.split("%2F")[-1].split("/")[0]
62
- link = f"Pr created at: {'https://huggingface.co/' + os.path.join(model_id, 'discussions', pr_number)}"
63
  progress(1, desc="Done")
64
  except Exception as e:
65
  raise gr.exceptions.Error(str(e))
66
  finally:
67
  shutil.rmtree(folder)
68
 
69
- return link
 
58
  folder = convert_single(model_id, filename, folder, progress, token)
59
  progress(0.7, desc="Uploading to Hub")
60
  new_pr = api.upload_folder(folder_path=folder, path_in_repo="./", repo_id=model_id, repo_type="model", token=token, commit_message=pr_title, commit_description=COMMIT_MESSAGE.format(model_id), create_pr=True)
61
+ link = f"Pr created at: {new_pr.pr_url}"
 
62
  progress(1, desc="Done")
63
  except Exception as e:
64
  raise gr.exceptions.Error(str(e))
65
  finally:
66
  shutil.rmtree(folder)
67
 
68
+ return link