Update app.py
Browse files
app.py
CHANGED
|
@@ -30,6 +30,7 @@ STATE_FILE_NAME = f"{FLOW_ID}_state.json"
|
|
| 30 |
|
| 31 |
# Using the full list from the user's original code for actual deployment
|
| 32 |
CAPTION_SERVERS = [
|
|
|
|
| 33 |
"https://fred808-pil-4-1.hf.space/analyze",
|
| 34 |
"https://fred808-pil-4-2.hf.space/analyze",
|
| 35 |
"https://fred808-pil-4-3.hf.space/analyze",
|
|
@@ -66,6 +67,42 @@ CAPTION_SERVERS = [
|
|
| 66 |
"https://fredalone-fredalone-t27vig.hf.space/analyze",
|
| 67 |
"https://fredalone-fredalone-gahbxh.hf.space/analyze",
|
| 68 |
"https://fredalone-fredalone-kw2po4.hf.space/analyze",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
"https://fredalone-fredalone-8h285h.hf.space/analyze"
|
| 70 |
]
|
| 71 |
MODEL_TYPE = "Florence-2-large"
|
|
@@ -120,11 +157,15 @@ state_lock = asyncio.Lock()
|
|
| 120 |
# --- Persistence Functions ---
|
| 121 |
|
| 122 |
def get_hf_api():
|
| 123 |
-
"""Helper to get HfApi instance."""
|
|
|
|
|
|
|
| 124 |
return HfApi(token=HF_TOKEN)
|
| 125 |
|
| 126 |
def get_hf_fs():
|
| 127 |
-
"""Helper to get HfFileSystem instance."""
|
|
|
|
|
|
|
| 128 |
return HfFileSystem(token=HF_TOKEN)
|
| 129 |
|
| 130 |
async def load_state_from_hf():
|
|
|
|
| 30 |
|
| 31 |
# Using the full list from the user's original code for actual deployment
|
| 32 |
CAPTION_SERVERS = [
|
| 33 |
+
# Using the full list from the user's original code for actual deployment
|
| 34 |
"https://fred808-pil-4-1.hf.space/analyze",
|
| 35 |
"https://fred808-pil-4-2.hf.space/analyze",
|
| 36 |
"https://fred808-pil-4-3.hf.space/analyze",
|
|
|
|
| 67 |
"https://fredalone-fredalone-t27vig.hf.space/analyze",
|
| 68 |
"https://fredalone-fredalone-gahbxh.hf.space/analyze",
|
| 69 |
"https://fredalone-fredalone-kw2po4.hf.space/analyze",
|
| 70 |
+
"https://fredalone-fredalone-8h285h.hf.space",
|
| 71 |
+
"https://fred808-pil-4-2.hf.space/analyze",
|
| 72 |
+
"https://fred808-pil-4-3.hf.space/analyze",
|
| 73 |
+
"https://fred1012-fred1012-gw0j2h.hf.space/analyze",
|
| 74 |
+
"https://fred1012-fred1012-wqs6c2.hf.space/analyze",
|
| 75 |
+
"https://fred1012-fred1012-oncray.hf.space/analyze",
|
| 76 |
+
"https://fred1012-fred1012-4goge7.hf.space/analyze",
|
| 77 |
+
"https://fred1012-fred1012-z0eh7m.hf.space/analyze",
|
| 78 |
+
"https://fred1012-fred1012-u95rte.hf.space/analyze",
|
| 79 |
+
"https://fred1012-fred1012-igje22.hf.space/analyze",
|
| 80 |
+
"https://fred1012-fred1012-ibkuf8.hf.space/analyze",
|
| 81 |
+
"https://fred1012-fred1012-nwqthy.hf.space/analyze",
|
| 82 |
+
"https://fred1012-fred1012-4ldqj4.hf.space/analyze",
|
| 83 |
+
"https://fred1012-fred1012-pivlzg.hf.space/analyze",
|
| 84 |
+
"https://fred1012-fred1012-ptlc5u.hf.space/analyze",
|
| 85 |
+
"https://fred1012-fred1012-u7lh57.hf.space/analyze",
|
| 86 |
+
"https://fred1012-fred1012-q8djv1.hf.space/analyze",
|
| 87 |
+
"https://fredalone-fredalone-ozugrp.hf.space/analyze",
|
| 88 |
+
"https://fredalone-fredalone-9brxj2.hf.space/analyze",
|
| 89 |
+
"https://fredalone-fredalone-p8vq9a.hf.space/analyze",
|
| 90 |
+
"https://fredalone-fredalone-vbli2y.hf.space/analyze",
|
| 91 |
+
"https://fredalone-fredalone-uggger.hf.space/analyze",
|
| 92 |
+
"https://fredalone-fredalone-nmi7e8.hf.space/analyze",
|
| 93 |
+
"https://fredalone-fredalone-d1f26d.hf.space/analyze",
|
| 94 |
+
"https://fredalone-fredalone-461jp2.hf.space/analyze",
|
| 95 |
+
"https://fredalone-fredalone-3enfg4.hf.space/analyze",
|
| 96 |
+
"https://fredalone-fredalone-dqdbpv.hf.space/analyze",
|
| 97 |
+
"https://fredalone-fredalone-ivtjua.hf.space/analyze",
|
| 98 |
+
"https://fredalone-fredalone-6bezt2.hf.space/analyze",
|
| 99 |
+
"https://fredalone-fredalone-e0wfnk.hf.space/analyze",
|
| 100 |
+
"https://fredalone-fredalone-zu2t7j.hf.space/analyze",
|
| 101 |
+
"https://fredalone-fredalone-dqtv1o.hf.space/analyze",
|
| 102 |
+
"https://fredalone-fredalone-wclyog.hf.space/analyze",
|
| 103 |
+
"https://fredalone-fredalone-t27vig.hf.space/analyze",
|
| 104 |
+
"https://fredalone-fredalone-gahbxh.hf.space/analyze",
|
| 105 |
+
"https://fredalone-fredalone-kw2po4.hf.space/analyze",
|
| 106 |
"https://fredalone-fredalone-8h285h.hf.space/analyze"
|
| 107 |
]
|
| 108 |
MODEL_TYPE = "Florence-2-large"
|
|
|
|
| 157 |
# --- Persistence Functions ---
|
| 158 |
|
| 159 |
def get_hf_api():
|
| 160 |
+
"""Helper to get HfApi instance, raising error if token is missing."""
|
| 161 |
+
if not HF_TOKEN:
|
| 162 |
+
raise ValueError("HF_TOKEN environment variable is not set. Cannot access Hugging Face.")
|
| 163 |
return HfApi(token=HF_TOKEN)
|
| 164 |
|
| 165 |
def get_hf_fs():
|
| 166 |
+
"""Helper to get HfFileSystem instance, raising error if token is missing."""
|
| 167 |
+
if not HF_TOKEN:
|
| 168 |
+
raise ValueError("HF_TOKEN environment variable is not set. Cannot access Hugging Face.")
|
| 169 |
return HfFileSystem(token=HF_TOKEN)
|
| 170 |
|
| 171 |
async def load_state_from_hf():
|