MonsterMMORPG commited on
Commit
e731c90
·
1 Parent(s): bf5edb4

Upload web-ui.py

Browse files
Files changed (1) hide show
  1. web-ui.py +28 -5
web-ui.py CHANGED
@@ -37,17 +37,25 @@ static_model_names = [
37
  "stablediffusionapi/realcartoon3d",
38
  "stablediffusionapi/disney-pixar-cartoon",
39
  "stablediffusionapi/pastel-mix-stylized-anime",
40
- "stablediffusionapi/anything-v5",
41
  "SG161222/Realistic_Vision_V2.0",
42
  "SG161222/Realistic_Vision_V4.0_noVAE",
43
  "SG161222/Realistic_Vision_V5.1_noVAE",
44
- r"C:\Users\King\Downloads\New folder\3D Animation Diffusion"
45
  ]
46
 
47
  # Cache for loaded models
48
  model_cache = {}
49
  max_cache_size = args.cache_limit
50
 
 
 
 
 
 
 
 
 
51
  # Function to load and cache model
52
  def load_model(model_name):
53
  if model_name in model_cache:
@@ -167,6 +175,12 @@ with gr.Blocks() as demo:
167
  output_gallery = gr.Gallery(label="Generated Images")
168
  output_text = gr.Textbox(label="Output Info")
169
  display_seed = gr.Textbox(label="Used Seed", interactive=False)
 
 
 
 
 
 
170
 
171
  generate_btn.click(
172
  generate_image,
@@ -174,17 +188,26 @@ with gr.Blocks() as demo:
174
  outputs=[output_gallery, output_text, display_seed],
175
  )
176
 
 
 
 
 
 
 
 
177
  def start_ngrok():
 
178
  time.sleep(10) # Delay for 10 seconds to ensure Gradio starts first
 
179
  ngrok.set_auth_token(args.ngrok_token)
180
  public_url = ngrok.connect(port=7860) # Adjust to your Gradio app's port
181
  print(f"ngrok tunnel started at {public_url}")
182
 
183
  if __name__ == "__main__":
184
- if args.ngrok_token:
185
  # Start ngrok in a daemon thread with a delay
186
- ngrok_thread = threading.Thread(target=start_ngrok, daemon=True)
187
- ngrok_thread.start()
188
 
189
  # Launch the Gradio app
190
  demo.launch(share=args.share, inbrowser=True)
 
37
  "stablediffusionapi/realcartoon3d",
38
  "stablediffusionapi/disney-pixar-cartoon",
39
  "stablediffusionapi/pastel-mix-stylized-anime",
40
+ "stablediffusionapi/anything-v5",
41
  "SG161222/Realistic_Vision_V2.0",
42
  "SG161222/Realistic_Vision_V4.0_noVAE",
43
  "SG161222/Realistic_Vision_V5.1_noVAE",
44
+ #r"G:\model\model_diffusers"
45
  ]
46
 
47
  # Cache for loaded models
48
  model_cache = {}
49
  max_cache_size = args.cache_limit
50
 
51
+ def convert_model(checkpoint_path, output_path):
52
+ try:
53
+ pipe = StableDiffusionPipeline.from_single_file(checkpoint_path)
54
+ pipe.save_pretrained(output_path)
55
+ return f"Model converted and saved to {output_path}"
56
+ except Exception as e:
57
+ return f"Error: {str(e)}"
58
+
59
  # Function to load and cache model
60
  def load_model(model_name):
61
  if model_name in model_cache:
 
175
  output_gallery = gr.Gallery(label="Generated Images")
176
  output_text = gr.Textbox(label="Output Info")
177
  display_seed = gr.Textbox(label="Used Seed", interactive=False)
178
+
179
+ with gr.Row():
180
+ checkpoint_path_input = gr.Textbox(label="Enter Checkpoint File Path .e.g G:\model\model.safetensors", )
181
+ output_path_input = gr.Textbox(label="Enter Output Folder Path, e.g. G:\model\model_diffusers")
182
+ convert_btn = gr.Button("Convert Model")
183
+
184
 
185
  generate_btn.click(
186
  generate_image,
 
188
  outputs=[output_gallery, output_text, display_seed],
189
  )
190
 
191
+ convert_btn.click(
192
+ convert_model,
193
+ inputs=[checkpoint_path_input, output_path_input],
194
+ outputs=[gr.Text(label="Conversion Status")],
195
+ )
196
+
197
+ #sadly doesnt work
198
  def start_ngrok():
199
+ print("1")
200
  time.sleep(10) # Delay for 10 seconds to ensure Gradio starts first
201
+ print("2")
202
  ngrok.set_auth_token(args.ngrok_token)
203
  public_url = ngrok.connect(port=7860) # Adjust to your Gradio app's port
204
  print(f"ngrok tunnel started at {public_url}")
205
 
206
  if __name__ == "__main__":
207
+ #if args.ngrok_token:
208
  # Start ngrok in a daemon thread with a delay
209
+ # ngrok_thread = threading.Thread(target=start_ngrok, daemon=False)
210
+ # ngrok_thread.start()
211
 
212
  # Launch the Gradio app
213
  demo.launch(share=args.share, inbrowser=True)