gstaff commited on
Commit
29eeb38
·
1 Parent(s): e6202b4

Make LCM client adaptive.

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -22,7 +22,21 @@ if not HF_TOKEN:
22
  API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
23
  headers = {"Authorization": f"Bearer {HF_TOKEN}"}
24
 
25
- client = Client("https://latent-consistency-super-fast-lcm-lora-sd1-5.hf.space/--replicas/0867lltlv/")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
 
28
  def init_speech_to_text_model() -> Pipeline:
 
22
  API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
23
  headers = {"Authorization": f"Bearer {HF_TOKEN}"}
24
 
25
+ def configure_image_client():
26
+ url = "https://latent-consistency-super-fast-lcm-lora-sd1-5.hf.space/?view=api"
27
+ try:
28
+ response = requests.get(url)
29
+ response.raise_for_status()
30
+ content_text = response.text
31
+ pattern = r'"root":"(https://latent-consistency-super-fast-lcm-lora-sd1-5.hf.space/.*?)"'
32
+ match = re.findall(pattern, content_text)[0]
33
+ return Client(match)
34
+ except requests.RequestException as e:
35
+ print(f"Error fetching URL content: {e}")
36
+ raise e
37
+
38
+
39
+ client = configure_image_client()
40
 
41
 
42
  def init_speech_to_text_model() -> Pipeline: