roubaofeipi commited on
Commit
0df3aff
1 Parent(s): 7d73d78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -13,7 +13,7 @@ import argparse
13
  import gradio as gr
14
  import spaces
15
  from huggingface_hub import hf_hub_url
16
- import requests
17
 
18
  def parse_args():
19
  parser = argparse.ArgumentParser()
@@ -204,12 +204,15 @@ with gr.Blocks() as demo:
204
 
205
 
206
 
207
- def download_and_save_model(model_name_or_path, save_directory):
208
- from transformers import AutoModel
209
- model = AutoModel.from_pretrained(model_name_or_path)
210
- model.save_pretrained(save_directory)
211
- print(f"Model saved to {save_directory}", model_name_or_path)
 
 
212
  def download_model():
 
213
  urls = [
214
  'https://huggingface.co/stabilityai/StableWurst/resolve/main/stage_a.safetensors',
215
  'https://huggingface.co/stabilityai/StableWurst/resolve/main/previewer.safetensors',
@@ -219,7 +222,7 @@ def download_model():
219
  'https://huggingface.co/roubaofeipi/UltraPixel/blob/main/ultrapixel_t2i.safetensors'
220
  ]
221
  for file_url in urls:
222
- download_and_save_model(file_url, 'models')
223
  if __name__ == "__main__":
224
 
225
  args = parse_args()
 
13
  import gradio as gr
14
  import spaces
15
  from huggingface_hub import hf_hub_url
16
+ import subprocess
17
 
18
  def parse_args():
19
  parser = argparse.ArgumentParser()
 
204
 
205
 
206
 
207
+ def download_with_wget(url, save_path):
208
+
209
+ try:
210
+ subprocess.run(['wget', url, '-O', save_path], check=True)
211
+ print(f"Downloaded to {save_path}")
212
+ except subprocess.CalledProcessError as e:
213
+ print(f"Error downloading file: {e}")
214
  def download_model():
215
+
216
  urls = [
217
  'https://huggingface.co/stabilityai/StableWurst/resolve/main/stage_a.safetensors',
218
  'https://huggingface.co/stabilityai/StableWurst/resolve/main/previewer.safetensors',
 
222
  'https://huggingface.co/roubaofeipi/UltraPixel/blob/main/ultrapixel_t2i.safetensors'
223
  ]
224
  for file_url in urls:
225
+ download_with_wget(file_url, 'models')
226
  if __name__ == "__main__":
227
 
228
  args = parse_args()