anzorq commited on
Commit
65ebbd2
1 Parent(s): 08e29b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -62,11 +62,14 @@ def convert_and_push(radio_model_names, input_model, ckpt_name, token):
62
  )
63
 
64
  # 3. Push to the model repo
 
65
  upload_folder(
66
  folder_path=model_id,
67
  repo_id=model_id,
68
  token=token,
69
  create_pr=True,
 
 
70
  )
71
 
72
  # # 4. Delete the downloaded checkpoint file, yaml files, and the converted model folder
@@ -76,14 +79,20 @@ def convert_and_push(radio_model_names, input_model, ckpt_name, token):
76
  for f in glob.glob("*.yaml*"):
77
  subprocess.run(["rm", "-rf", f])
78
 
79
- return "Success"
 
80
 
81
  except Exception as e:
82
  return error_str(e)
83
 
84
-
 
 
 
 
85
  with gr.Blocks() as demo:
86
 
 
87
  with gr.Row():
88
 
89
  with gr.Column(scale=11):
@@ -92,9 +101,9 @@ with gr.Blocks() as demo:
92
  input_token = gr.Textbox(
93
  max_lines=1,
94
  label="Enter your Hugging Face token",
95
- placeholder="hf_...",
96
  )
97
- gr.Markdown("You can get a token [here](https://huggingface.co/settings/tokens).")
98
  with gr.Group(visible=False) as group_model:
99
  radio_model_names = gr.Radio(label="Choose a model")
100
  input_model = gr.Textbox(
@@ -144,5 +153,11 @@ with gr.Blocks() as demo:
144
  scroll_to_output=True
145
  )
146
 
 
 
 
 
 
 
147
  demo.queue()
148
  demo.launch()
 
62
  )
63
 
64
  # 3. Push to the model repo
65
+ commit_message="Add Diffusers weights"
66
  upload_folder(
67
  folder_path=model_id,
68
  repo_id=model_id,
69
  token=token,
70
  create_pr=True,
71
+ commit_message=commit_message,
72
+ commit_description=f"Add Diffusers weights converted from checkpoint {ckpt_name} in revision {revision}",
73
  )
74
 
75
  # # 4. Delete the downloaded checkpoint file, yaml files, and the converted model folder
 
79
  for f in glob.glob("*.yaml*"):
80
  subprocess.run(["rm", "-rf", f])
81
 
82
+ return f"""Successfully converted the checkpoint and opened a PR to add the weights to the model repo.
83
+ You can view and merge the PR [here]({hf_utils.get_pr_url(HfApi(token=token), model_id, commit_message)})."""
84
 
85
  except Exception as e:
86
  return error_str(e)
87
 
88
+
89
+ DESCRIPTION = """### Convert a stable diffusion checkpoint to Diffusers🧨
90
+ With this space, you can easily convert a CompVis stable diffusion checkpoint to Diffusers and automatically create a pull request to the model repo.
91
+ You can choose to convert a checkpoint from one of your models, or from any other model on the Hub."""
92
+
93
  with gr.Blocks() as demo:
94
 
95
+ gr.Markdown(DESCRIPTION)
96
  with gr.Row():
97
 
98
  with gr.Column(scale=11):
 
101
  input_token = gr.Textbox(
102
  max_lines=1,
103
  label="Enter your Hugging Face token",
104
+ placeholder="READ permission is enough",
105
  )
106
+ gr.Markdown("You can get a token [here](https://huggingface.co/settings/tokens)")
107
  with gr.Group(visible=False) as group_model:
108
  radio_model_names = gr.Radio(label="Choose a model")
109
  input_model = gr.Textbox(
 
153
  scroll_to_output=True
154
  )
155
 
156
+ # gr.Markdown("""<img src="https://raw.githubusercontent.com/huggingface/diffusers/main/docs/source/imgs/diffusers_library.jpg" width="150"/>""")
157
+ gr.HTML("""
158
+ <p>Space by: <a href="https://twitter.com/hahahahohohe"><img src="https://img.shields.io/twitter/follow/hahahahohohe?label=%40anzorq&style=social" alt="Twitter Follow"></a></p><br>
159
+ <p><img src="https://visitor-badge.glitch.me/badge?page_id=anzorq.sd-to-diffusers" alt="visitors"></p>
160
+ """)
161
+
162
  demo.queue()
163
  demo.launch()