Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,16 @@ repos = [
|
|
| 11 |
"hsuwill000/LCM_SoteMix_OpenVINO_CPU_Space_TAESD",
|
| 12 |
"hsuwill000/LCM_SoteMix_OpenVINO_CPU_Space_TAESD_0"
|
| 13 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Counter for image filenames to avoid overwriting
|
| 16 |
count = 0
|
| 17 |
repo_index = 0 # This will keep track of the current repository
|
|
@@ -20,7 +29,7 @@ repo_index = 0 # This will keep track of the current repository
|
|
| 20 |
def infer_gradio(prompt: str):
|
| 21 |
global count, repo_index
|
| 22 |
# Create a Client instance to communicate with the Hugging Face space
|
| 23 |
-
client =
|
| 24 |
|
| 25 |
# Prepare the inputs for the prediction
|
| 26 |
inputs = {
|
|
|
|
| 11 |
"hsuwill000/LCM_SoteMix_OpenVINO_CPU_Space_TAESD",
|
| 12 |
"hsuwill000/LCM_SoteMix_OpenVINO_CPU_Space_TAESD_0"
|
| 13 |
]
|
| 14 |
+
class CustomClient(Client):
|
| 15 |
+
def __init__(self, *args, timeout=30, **kwargs):
|
| 16 |
+
super().__init__(*args, **kwargs)
|
| 17 |
+
self.timeout = timeout
|
| 18 |
|
| 19 |
+
def _request(self, method, url, **kwargs):
|
| 20 |
+
# 设置 timeout 参数
|
| 21 |
+
kwargs['timeout'] = self.timeout
|
| 22 |
+
return super()._request(method, url, **kwargs)
|
| 23 |
+
|
| 24 |
# Counter for image filenames to avoid overwriting
|
| 25 |
count = 0
|
| 26 |
repo_index = 0 # This will keep track of the current repository
|
|
|
|
| 29 |
def infer_gradio(prompt: str):
|
| 30 |
global count, repo_index
|
| 31 |
# Create a Client instance to communicate with the Hugging Face space
|
| 32 |
+
client = CustomClient(repos[repo_index], hf_token=api_key,timeout=300)
|
| 33 |
|
| 34 |
# Prepare the inputs for the prediction
|
| 35 |
inputs = {
|