multimodalart HF staff commited on
Commit
0688e12
1 Parent(s): 31e1648

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -29,12 +29,12 @@ css = '''
29
  maximum_concepts = 3
30
 
31
  #Pre download the files
32
- model_v1 = snapshot_download(repo_id="multimodalart/sd-fine-tunable")
33
- model_v2 = snapshot_download(repo_id="stabilityai/stable-diffusion-2")
34
- model_v2_512 = snapshot_download(repo_id="stabilityai/stable-diffusion-2-base")
35
- safety_checker = snapshot_download(repo_id="multimodalart/sd-sc")
36
-
37
- model_to_load = model_v1
38
 
39
  with zipfile.ZipFile("mix.zip", 'r') as zip_ref:
40
  zip_ref.extractall(".")
@@ -57,13 +57,14 @@ def swap_text(option, base):
57
  return [f"You are going to train a `style`, upload 10-20 images of the style you are planning on training on. You can use services like <a style='text-decoration: underline' href='https://www.birme.net/?target_width={resize_width}&target_height={resize_width}'>birme</a> for smart cropping. Name the files with the words you would like {mandatory_liability}:", '''<img src="file/trsl_style.png" />''', f"You should name your concept with a unique made up word that has low chance of the model already knowing it (e.g.: `{instance_prompt_example}` here). Images will be automatically cropped to {resize_width}x{resize_width}", freeze_for, gr.update(visible=False)]
58
 
59
  def swap_base_model(selected_model):
60
- global model_to_load
61
- if(selected_model == "v1-5"):
62
- model_to_load = model_v1
63
- elif(selected_model == "v2-768"):
64
- model_to_load = model_v2
65
- else:
66
- model_to_load = model_v2_512
 
67
 
68
  def count_files(*inputs):
69
  file_counter = 0
 
29
  maximum_concepts = 3
30
 
31
  #Pre download the files
32
+ if(not is_shared_ui):
33
+ model_v1 = snapshot_download(repo_id="multimodalart/sd-fine-tunable")
34
+ model_v2 = snapshot_download(repo_id="stabilityai/stable-diffusion-2")
35
+ model_v2_512 = snapshot_download(repo_id="stabilityai/stable-diffusion-2-base")
36
+ safety_checker = snapshot_download(repo_id="multimodalart/sd-sc")
37
+ model_to_load = model_v1
38
 
39
  with zipfile.ZipFile("mix.zip", 'r') as zip_ref:
40
  zip_ref.extractall(".")
 
57
  return [f"You are going to train a `style`, upload 10-20 images of the style you are planning on training on. You can use services like <a style='text-decoration: underline' href='https://www.birme.net/?target_width={resize_width}&target_height={resize_width}'>birme</a> for smart cropping. Name the files with the words you would like {mandatory_liability}:", '''<img src="file/trsl_style.png" />''', f"You should name your concept with a unique made up word that has low chance of the model already knowing it (e.g.: `{instance_prompt_example}` here). Images will be automatically cropped to {resize_width}x{resize_width}", freeze_for, gr.update(visible=False)]
58
 
59
  def swap_base_model(selected_model):
60
+ if(not is_shared_ui):
61
+ global model_to_load
62
+ if(selected_model == "v1-5"):
63
+ model_to_load = model_v1
64
+ elif(selected_model == "v2-768"):
65
+ model_to_load = model_v2
66
+ else:
67
+ model_to_load = model_v2_512
68
 
69
  def count_files(*inputs):
70
  file_counter = 0