Spaces:
vilarin
/
Running on Zero

vilarin commited on
Commit
9f5b615
·
verified ·
1 Parent(s): 80d8317

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -53,15 +53,14 @@ def scrape_lora_link(url):
53
  return filename
54
  else:
55
  return None
56
-
57
  except requests.RequestException as e:
58
  raise gr.Error(f"An error occurred while fetching the URL: {e}")
59
- return None
60
 
61
  def enable_lora(lora_scale,lora_add):
62
  if not lora_add:
63
  gr.Info("No Lora Loaded, Use basemodel")
64
  else:
 
65
  url = f'https://huggingface.co/{lora_add}/tree/main'
66
  lora_name = scrape_lora_link(url)
67
  if lora_name:
@@ -69,7 +68,11 @@ def enable_lora(lora_scale,lora_add):
69
  pipe.fuse_lora(lora_scale=lora_scale)
70
  gr.Info(f"{lora_add} Loaded")
71
  else:
72
- gr.Warning(f"{lora_add} Load fail, check again.")
 
 
 
 
73
 
74
  @spaces.GPU()
75
  def generate_image(
@@ -223,6 +226,4 @@ with gr.Blocks(css=CSS, js=JS, theme="Nymbo/Nymbo_Theme") as demo:
223
  api_name="run",
224
  )
225
 
226
-
227
-
228
  demo.queue().launch()
 
53
  return filename
54
  else:
55
  return None
 
56
  except requests.RequestException as e:
57
  raise gr.Error(f"An error occurred while fetching the URL: {e}")
 
58
 
59
  def enable_lora(lora_scale,lora_add):
60
  if not lora_add:
61
  gr.Info("No Lora Loaded, Use basemodel")
62
  else:
63
+ pipe.unload_lora_weights()
64
  url = f'https://huggingface.co/{lora_add}/tree/main'
65
  lora_name = scrape_lora_link(url)
66
  if lora_name:
 
68
  pipe.fuse_lora(lora_scale=lora_scale)
69
  gr.Info(f"{lora_add} Loaded")
70
  else:
71
+ try:
72
+ pipe.load_lora_weights(lora_add)
73
+ pipe.fuse_lora(lora_scale=lora_scale)
74
+ except:
75
+ raise gr.Error(f"{lora_add} Load fail, check again.")
76
 
77
  @spaces.GPU()
78
  def generate_image(
 
226
  api_name="run",
227
  )
228
 
 
 
229
  demo.queue().launch()