lichorosario commited on
Commit
931f2d6
·
1 Parent(s): 1dcbd47

feat: Update app.py to use new Tile-Upscaler client

Browse files
Files changed (1) hide show
  1. app.py +36 -10
app.py CHANGED
@@ -13,17 +13,20 @@ job = None
13
  custom_model_url = "https://fffiloni-sd-xl-custom-model.hf.space"
14
  tile_upscaler_url = "https://gokaygokay-tileupscalerv2.hf.space"
15
 
16
- try:
17
- client_custom_model = Client(custom_model_url)
18
- print(f"Loaded custom model from {custom_model_url}")
19
- except ValueError as e:
20
- print(f"Failed to load custom model: {e}")
21
 
22
- try:
23
- client_tile_upscaler = Client(tile_upscaler_url)
24
- print(f"Loaded custom model from {tile_upscaler_url}")
25
- except ValueError as e:
26
- print(f"Failed to load custom model: {e}")
 
 
 
 
 
 
27
 
28
 
29
  def infer(selected_index, prompt, style_prompt, inf_steps, guidance_scale, width, height, seed, lora_weight, progress=gr.Progress(track_tqdm=True)):
@@ -37,6 +40,29 @@ def infer(selected_index, prompt, style_prompt, inf_steps, guidance_scale, width
37
  custom_model = selected_lora["repo"]
38
  trigger_word = selected_lora["trigger_word"]
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  result = client_custom_model.submit(
41
  custom_model=custom_model,
42
  api_name="/load_model"
 
13
  custom_model_url = "https://fffiloni-sd-xl-custom-model.hf.space"
14
  tile_upscaler_url = "https://gokaygokay-tileupscalerv2.hf.space"
15
 
16
+ client_custom_model = None
17
+ client_tile_upscaler = None
 
 
 
18
 
19
+ # try:
20
+ # client_custom_model = Client(custom_model_url)
21
+ # print(f"Loaded custom model from {custom_model_url}")
22
+ # except ValueError as e:
23
+ # print(f"Failed to load custom model: {e}")
24
+
25
+ # try:
26
+ # client_tile_upscaler = Client(tile_upscaler_url)
27
+ # print(f"Loaded custom model from {tile_upscaler_url}")
28
+ # except ValueError as e:
29
+ # print(f"Failed to load custom model: {e}")
30
 
31
 
32
  def infer(selected_index, prompt, style_prompt, inf_steps, guidance_scale, width, height, seed, lora_weight, progress=gr.Progress(track_tqdm=True)):
 
40
  custom_model = selected_lora["repo"]
41
  trigger_word = selected_lora["trigger_word"]
42
 
43
+ global client_custom_model
44
+ global client_tile_upscaler
45
+
46
+ if client_custom_model is None:
47
+ try:
48
+ client_custom_model = Client(custom_model_url)
49
+ print(f"Loaded custom model from {custom_model_url}")
50
+ except ValueError as e:
51
+ print(f"Failed to load custom model: {e}")
52
+ client_custom_model = None
53
+ raise gr.Error("Failed to load client for " + custom_model_url)
54
+
55
+ if client_tile_upscaler is None:
56
+ try:
57
+ client_tile_upscaler = Client(tile_upscaler_url)
58
+ print(f"Loaded custom model from {tile_upscaler_url}")
59
+ except ValueError as e:
60
+ print(f"Failed to load custom model: {e}")
61
+ client_custom_model = None
62
+ raise gr.Error("Failed to load client for " + tile_upscaler_url)
63
+
64
+
65
+
66
  result = client_custom_model.submit(
67
  custom_model=custom_model,
68
  api_name="/load_model"